Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* TFT module connections */
- char TFT_DataPort at LATE;
- sbit TFT_RST at LATD7_bit;
- sbit TFT_BLED at LATD2_bit;
- sbit TFT_RS at LATD9_bit;
- sbit TFT_CS at LATD10_bit;
- sbit TFT_RD at LATD5_bit;
- sbit TFT_WR at LATD4_bit;
- char TFT_DataPort_Direction at TRISE;
- sbit TFT_RST_Direction at TRISD7_bit;
- sbit TFT_BLED_Direction at TRISD2_bit;
- sbit TFT_RS_Direction at TRISD9_bit;
- sbit TFT_CS_Direction at TRISD10_bit;
- sbit TFT_RD_Direction at TRISD5_bit;
- sbit TFT_WR_Direction at TRISD4_bit;
- /* End TFT module connections */
- int i, j;
- int cnt, speed = 0;
- unsigned int tempAdcValue;
- void main() {
- /* Setting output frequency to 140MHz */
- PLLFBD = 70; // PLL multiplier M=70
- CLKDIV = 0x0000;
- // PLL prescaler N1=2, PLL postscaler N2=2
- ANSELA = 0x0000;
- TRISA = 0x00F0;
- LATA = 0x0000;
- ANSELB = 0x0001; /* Conf. RB0 as analog - DSPIC specific. */
- TRISB0_bit = 1; /* Set PORTB.B0 as input (AN0) */
- ADC1_Init(); /* Default config of ADC module */
- /* Init TFT */
- TFT_Set_Default_Mode();
- TFT_Init_ILI9341_8bit_Custom(320, 240);
- Delay_10ms();
- /* Fill TFT screen with a color */
- TFT_Fill_Screen(CL_White);
- TFT_Set_Pen(CL_BLACK,5);
- /*TFT_V_Line(100, 150, 10);
- TFT_V_Line(100, 150, 50);
- TFT_H_Line(10+cnt,50,150);
- TFT_H_Line(10+cnt,50,100);*/
- while(1)
- {
- tempAdcValue = ADC1_Get_Sample(0);
- if ( (tempAdcValue > 0) && (tempAdcValue <= 255))
- {
- speed = 1;
- }
- if ( (tempAdcValue > 255) && (tempAdcValue <= 512))
- {
- speed = 5;
- }
- if ( tempAdcValue > 512)
- {
- speed = 10;
- }
- // Vdelay_ms(tempAdcValue);
- if((PORTA & 0x0020) == 0){
- cnt+=speed;
- TFT_Fill_Screen(CL_White);
- TFT_V_Line(100, 150, 10+cnt);
- /*TFT_V_Line(100, 150, 50+cnt);
- TFT_H_Line(10+cnt,50+cnt,150);
- TFT_H_Line(10+cnt,50+cnt,100);*/
- Delay_100ms();
- }
- if((PORTA & 0x0010) == 0){
- cnt-=speed;
- TFT_Fill_Screen(CL_White);
- TFT_V_Line(100, 150, 10+cnt);
- /* TFT_V_Line(100, 150, 50+cnt);
- TFT_H_Line(10+cnt,50+cnt,150);
- TFT_H_Line(10+cnt,50+cnt,100);*/
- Delay_100ms();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement