Beispiel #1
0
void TouchInit(void)
{
    TPCalibrateParam calibrate;

    TP_Init();

	if(!TP_GetUserInfo(&calibrate))
		OS_Panic("Failed to initialize touch panel");

	TP_SetCalibrateParam(&calibrate);
}
Beispiel #2
0
int main(void)
{
	u8 key,fontok=0; 
   	Stm32_Clock_Init(9);	//系统时钟设置
	delay_init(72);			//延时初始化
	uart_init(72,115200); 	//串口1初始化 
	LCD_Init();				//初始化液晶 
	LED_Init();         	//LED初始化	 
	KEY_Init();				//按键初始化	 
	usmart_dev.init(72);	//usmart初始化	
 	USART2_Init(36,115200);	//初始化串口2 
	TP_Init();				//初始化触摸屏
	mem_init(SRAMIN);		//初始化内部内存池	    
 	exfuns_init();			//为fatfs相关变量申请内存  
  	f_mount(0,fs[0]); 		//挂载SD卡 
	key=KEY_Scan(0);  
	if(key==KEY_RIGHT)		//强制校准
	{
		LCD_Clear(WHITE);	//清屏
		TP_Adjust();  		//屏幕校准 
		TP_Save_Adjdata();	  
		LCD_Clear(WHITE);	//清屏
	}
	fontok=font_init();		//检查字库是否OK
	if(fontok||key==KEY_DOWN)//需要更新字库				 
	{
		LCD_Clear(WHITE);		   	//清屏
 		POINT_COLOR=RED;			//设置字体为红色	   	   	  
		LCD_ShowString(60,50,200,16,16,"ALIENTEK STM32");
		while(SD_Initialize())		//检测SD卡
		{
			LCD_ShowString(60,70,200,16,16,"SD Card Failed!");
			delay_ms(200);
			LCD_Fill(60,70,200+60,70+16,WHITE);
			delay_ms(200);		    
		}								 						    
		LCD_ShowString(60,70,200,16,16,"SD Card OK");
		LCD_ShowString(60,90,200,16,16,"Font Updating...");
		key=update_font(20,110,16,0);//从SD卡更新
		while(key)//更新失败		
		{			 		  
			LCD_ShowString(60,110,200,16,16,"Font Update Failed!");
			delay_ms(200);
			LCD_Fill(20,110,200+20,110+16,WHITE);
			delay_ms(200);		       
		} 		  
		LCD_ShowString(60,110,200,16,16,"Font Update Success!");
		delay_ms(1500);	
		LCD_Clear(WHITE);//清屏	       
	}  
	sim900a_test();
}
Beispiel #3
0
char Proc_TP_Adj(char *NC)
{
  unsigned int temp[8]                               ;
  Color     = Green                                  ;
  Color_BK  = Black                                  ;
  TP_Init()                                          ;
  Clear_LCD(Color_BK)                                ; 
  PutStringCN24(58,120,"触摸屏校正")                 ;
  Color     = Cyan                                   ;
  PutStringCN16(30,165,"请用触控笔点测试点中心")     ;
  for(;;)
  {
    Draw_Test_Point(20,20,Yellow)                    ;
    for(;;)
    {
      if(Read_TP_Twice(&temp[0],&temp[1]))  break    ;
      if(ReadKey()==Cancel)  return 0x00             ;
    }
    DrawRectFill(0,0,40,40,Color_BK)                 ;
    Wait_Pen_Up()                                    ;
  
    Draw_Test_Point(220,20,Yellow)                   ;
    for(;;)
    {
      if(Read_TP_Twice(&temp[2],&temp[3]))  break    ;
      if(ReadKey()==Cancel)  return 0x00             ;
    }
    DrawRectFill(200,0,40,40,Color_BK)               ;
    Wait_Pen_Up()                                    ;
    
    Draw_Test_Point(20,300,Yellow)                   ;
    for(;;)
    {
      if(Read_TP_Twice(&temp[4],&temp[5]))  break    ;
      if(ReadKey()==Cancel)  return 0x00             ;
    }
    DrawRectFill(0,280,40,40,Color_BK)               ;
    Wait_Pen_Up()                                    ;
    
    Draw_Test_Point(220,300,Yellow)                  ;
    for(;;)
    {
      if(Read_TP_Twice(&temp[6],&temp[7]))  break    ;       
      if(ReadKey()==Cancel)  return 0x00             ;
    }
    DrawRectFill(200,280,40,40,Color_BK)             ;
    Wait_Pen_Up()                                    ;
    if(TP_Adjust(temp))         break                ;
  }
  return 0x00                                        ;
}
Beispiel #4
0
void vTouchPanelTask(void * pvParameters) {

	TP_Init();

	while (1) {
		if (xSemaphoreTake(xSPI1_Mutex, portMAX_DELAY) == pdTRUE) {
			SPI1_SetSpeed(SPI_2MHz);
			GUI_TOUCH_Exec();
			SPI1_SetSpeed(SPI_16MHz);
			xSemaphoreGive(xSPI1_Mutex);
		}
		vTaskDelay(10/portTICK_RATE_MS);
	}
}
Beispiel #5
0
void Task_Touch(void *Tags)
{
	Coordinate  *C;
	TP_Init();
	while(1)
	{
		GUI_TOUCH_Exec();
		C=Read_Ads7846();
		if(C)
		{
				_TouchX=C->x;
				_TouchY=C->y;
		}
		Tos_TaskDelay(10);
	}
}
Beispiel #6
0
void main() {
  ANCON0 = 0;
  ANCON1 = 0;
  ANCON2 = 0;

  ANCON0.B0 = 1;            // Configure RA0 pin as analog
  ANCON0.B1 = 1;            // Configure RA1 pin as analog

  TRISA.B0 = 1;             // Set RA0 pin as input
  TRISA.B1 = 1;             // Set RA1 pin as input
  
  ADC_Init();
  T6963C_ctrlce_Direction = 0;
  T6963C_ctrlce = 0;            // Enable T6963C
  T6963C_ctrlmd_Direction = 0;
  T6963C_ctrlmd = 0;            // Column number select
  T6963C_ctrlfs_Direction = 0;
  T6963C_ctrlfs = 0;            // Wide Font

  BacklightRed_Direction   = 0; // Set backlight signals as outputs
  BacklightGreen_Direction = 0;
  BacklightBlue_Direction  = 0;
  BacklightRed   = 0;           // Turn on Red component of back light
  BacklightGreen = 0;           // Turn on Green component of back light
  BacklightBlue  = 0;           // Turn on Blue component of back light

  // Initialize T6963C
  T6963C_init(240, 128, 8);
  T6963C_graphics(1);
  T6963C_text(1);
  T6963C_cursor(0);

  TP_Init(240, 128, 0, 1);      // Initialize touch panel
  TP_Set_ADC_Threshold(500);    // Set touch panel ADC threshold

  T6963C_graphics(1);
  T6963C_text(1);

  T6963C_panelFill(0);
  T6963C_write_text("CALIBRATION", 8, 6, 1);
  Delay_ms(2000);

  T6963C_panelFill(0);
  Calibrate();
  T6963C_panelFill(0);

  T6963C_write_text("WRITE ON SCREEN", 7, 6, 1) ;
  Delay_ms(1000);
  T6963C_panelFill(0);

  //Draw menus:
  T6963C_box(0,0,42,7,T6963C_WHITE);
  T6963C_write_text(clear_msg,0,0,0);
  T6963C_box(200,0,240,7,T6963C_WHITE);
  T6963C_write_text(erase_msg,25,0,0);
  T6963C_box(57,0,65,7,T6963C_WHITE);
  T6963C_write_char('R',7,0,0);
  T6963C_box(73,0,81,7,T6963C_WHITE);
  T6963C_write_char('G',9,0,0);
  T6963C_box(89,0,97,7,T6963C_WHITE);
  T6963C_write_char('B',11,0,0);
  T6963C_box(105,0,145,7,T6963C_WHITE);
  T6963C_write_text("Light",13,0,0);

  write_erase = 1;

  while (1) {

    if (TP_Press_Detect()) {
      // get coordinates
      if (TP_Get_Coordinates(&x_coord240, &y_coord128) == 0){

        // If clear is pressed
        if ((x_coord240 < 32) && (y_coord128 < 8)) {

           T6963C_panelFill(0);

           // Draw menus:
           T6963C_box(0,0,42,7,T6963C_WHITE);
           T6963C_write_text(clear_msg,0,0,0);
           T6963C_box(200,0,240,7,T6963C_WHITE);
           if (write_erase)
             T6963C_write_text(erase_msg,25,0,0);
           else
             T6963C_write_text(write_msg,25,0,0);

           T6963C_box(57,0,65,7,T6963C_WHITE);
           T6963C_write_char('R',7,0,0);
           T6963C_box(73,0,81,7,T6963C_WHITE);
           T6963C_write_char('G',9,0,0);
           T6963C_box(89,0,97,7,T6963C_WHITE);
           T6963C_write_char('B',11,0,0);
           T6963C_box(105,0,145,7,T6963C_WHITE);
           T6963C_write_text("Light",13,0,0);
         }

        // If write/erase is pressed:
        if ((x_coord240 > 201) && (y_coord128 < 8)) {
           if (write_erase) {
             write_erase = 0;
             T6963C_write_text(write_msg,25,0,0);
             Delay_ms(200);
             }
           else {
             write_erase = 1;
             T6963C_write_text(erase_msg,25,0,0);
             Delay_ms(200);
             }
           }

        // If R button is pressed:
        if ((x_coord240 >= 57) && (x_coord240 <= 65) && (y_coord128 <= 7)) {
          PORTC.F2 = !PORTC.F2;   // Red
          Delay_ms(100);
        }

        // If G button is pressed:
        if ((x_coord240 >= 73) && (x_coord240 <= 81) && (y_coord128 <= 7)) {
          PORTC.F1 = !PORTC.F1;   // Green
          Delay_ms(100);
        }

        // If B button is pressed:
        if ((x_coord240 >= 89) && (x_coord240 <= 97) && (y_coord128 <= 7)) {
          PORTG.F0 = !PORTG.F0;   // Blue
          Delay_ms(100);
        }
        // If backlight button is pressed:
        if ((x_coord240 >= 105) && (x_coord240 <= 146) && (y_coord128 <= 7)) {
          PORTC.F2 = !PORTC.F2;   // Red
          PORTC.F1 = !PORTC.F1;   // Green
          PORTG.F0 = !PORTG.F0;   // Blue
          Delay_ms(100);
        }

        // Draw on the screen
        if (y_coord128 > 8)
        {
          if (write_erase) T6963C_dot(x_coord240, y_coord128, T6963C_WHITE);
          else T6963C_dot(x_coord240, y_coord128, T6963C_BLACK);
        }
      }
    }
  }
}
Beispiel #7
0
//---------------------------------------------------------------------------//
//                                                                           //
//函数:void Key_TP_Task(void)                                               //
//描述:键盘与触摸屏扫描,编辑控件光标闪烁                                   //
//		                                                             //
//---------------------------------------------------------------------------//
void Key_TP_Task(void)
{
  unsigned char flicker_cnt = 0                             ;
  char key = 0xFF,last_key = 0xFF, down_cnt = 0, tp_cnt = 0 ;
  char rx_char                                              ;
  union 
  {
    unsigned int  pos[2]                                    ;
    char byte[4]                                            ;
  }TPoint                                                   ;
  char event                                                ;
  Init_KeyPad()                                             ; 
  TP_Init()                                                 ;
  OS_CREATEMB(&MBKeyTP, 1, sizeof(MBKeyTPBuffer),
              &MBKeyTPBuffer                     )          ; // 创建键盘、触摸屏消息邮箱
  OS_CREATEMB(&MBRX,1,sizeof(MBRXBuffer),&MBRXBuffer)       ; // 创建端口接收邮箱
  for(;;)
  {
    event  = 0x00                                           ;
    if(++flicker_cnt>50)                                      // 界面闪烁元素
    {
      flicker_cnt = 0x00                                    ;
      event = EVENT_FLICKER                                 ;
    }
    key = ReadKey()                                         ; // 按键扫描
    if(key!=last_key&&key!=0xFF)
      down_cnt  =  0                                        ;
    else if(key!=last_key&&key==0xFF)
    {
      if(down_cnt>3)
        event    |= EVENT_KEY_PRESSED                       ;
    }
    else if(key==last_key&&key!=0xFF)
      if(++down_cnt>4) down_cnt = 4                         ;
    OS_Use(&SemaSPI)                                        ;
    Init_TPSPI()                                            ;
    if(!Read_TP_Twice(&TPoint.pos[0],&TPoint.pos[1]))         // 触摸屏扫描         
    {
      if(tp_cnt>3)
        event  |= EVENT_TP_PRESSED                          ;
      tp_cnt   = 0                                          ;
    }
    else 
    {
      if(++tp_cnt>8)      tp_cnt     = 8                    ;
      if(tp_cnt>4)
      {
        Convert_Pos( TPoint.pos[0], TPoint.pos[1],   
                    &TPoint.pos[0],&TPoint.pos[1] )         ;
        event  |= EVENT_TP_TOUCHED                          ;
      }
    }
    OS_Unuse(&SemaSPI)                                      ;
    
    if(OS_GetMessageCnt(&MBRX))
    {
      OS_GetMail(&MBRX,&rx_char)                            ;
      event    |= RX_RECEIVED                               ;
    }
    if(event)                                                 // 发送系统消息
    {
      if(  !OS_GetSuspendCnt(&LCD_TASK_TCB)
         ||!OS_GetSuspendCnt(&MENU_OP_TASK_TCB))
      {
        OS_PutMail1(&MBKeyTP, &event)                       ;
        OS_PutMail1(&MBKeyTP, &last_key)                    ;
        OS_PutMail1(&MBKeyTP, &rx_char)                     ;
        OS_PutMail1(&MBKeyTP, &TPoint.byte[0])              ;
        OS_PutMail1(&MBKeyTP, &TPoint.byte[1])              ;
        OS_PutMail1(&MBKeyTP, &TPoint.byte[2])              ;
        OS_PutMail1(&MBKeyTP, &TPoint.byte[3])              ; 
      }
    }
    last_key = key                                          ;
    OS_Delay(10)                                            ;
  }
}