/** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) { static unsigned char TP_EXE; led++; OS_TimeMS++; if(led%2) { GPIO_SetBits(GPIOF , GPIO_Pin_6); GPIO_SetBits(GPIOF , GPIO_Pin_7); GPIO_SetBits(GPIOF , GPIO_Pin_8); GPIO_SetBits(GPIOF , GPIO_Pin_9); } else if(!(led%2)) { GPIO_ResetBits(GPIOF , GPIO_Pin_6); GPIO_ResetBits(GPIOF , GPIO_Pin_7); GPIO_ResetBits(GPIOF , GPIO_Pin_8); GPIO_ResetBits(GPIOF , GPIO_Pin_9); } else{} if(Touch_Screen_Start == 1) { TP_EXE++; if(TP_EXE==41) { GUI_TOUCH_Exec(); TP_EXE=0; } } }
int main(void) { SystemClockSetup(ClockSource_EX50M,CoreClock_100M); DelayInit(); LED_Init(LED_PinLookup_CHK60EVB, kNumOfLED); UART_DebugPortInit(UART4_RX_C14_TX_C15, 115200); DisplayCPUInfo(); GUI_Init(&CHGUI_InitStruct1); GUI_SetFontFormName("FONT_CourierNew"); while(1) { GUI_GotoXY(0, 0); GUI_TOUCH_GetState(&State); //打印物理AD坐标 GUI_printf("Phy:X:%04d Y:%04d\r\n", GUI_TOUCH_GetxPhys(), GUI_TOUCH_GetyPhys()); //打印逻辑AD坐标 GUI_printf("Log:X:%04d Y:%04d\r\n", State.x, State.y); GUI_printf("State:%01d\r\n", State.Pressed); //LCD 画笔跟踪 GUI_DrawPoint(State.x, State.y); DelayMs(10); //GUI 触摸屏处理函数 每10MS调用一次 GUI_TOUCH_Exec(); } }
void touch_task(void *pdata) { while(1) { GUI_TOUCH_Exec(); OSTimeDlyHMSM(0,0,0,10); } }
void AppTaskGUIRefresh(void *p_arg) { (void)p_arg; while(1) { // GUI_Exec(); // GUI Çл» GUI_TOUCH_Exec(); // ´¥ÃþÆÁÇл» BSP_OS_TimeDly(15); } }
void Task2_Func(void *p_arg) { (void)p_arg; while(1) { GUI_TOUCH_Exec(); // printf("**********task2\n\r"); OSTimeDly(20); } }
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); } }
int main(void) { DelayInit(); GPIO_QuickInit(HW_GPIOE, 6, kGPIO_Mode_OPP); UART_QuickInit(UART0_RX_PD06_TX_PD07, 115200); printf("spi touch screen test\r\n"); /* 初始化SPI2 接口连接触控屏的触控芯片*/ SPI_QuickInit(SPI2_SCK_PD12_SOUT_PD13_SIN_PD14, kSPI_CPOL0_CPHA0, 2*1000*1000); PORT_PinMuxConfig(HW_GPIOD, 11, kPinAlt2); /* SPI2_PCS0 */ /* 初始化触控芯片 使用CS0片选 */ ads7843_init(HW_SPI2, HW_SPI_CS0); GUI_Init();//液晶屏界面初始化 GUI_SetBkColor(GUI_WHITE); //设置背景色 GUI_SetColor(GUI_BLACK); //设置前景色 GUI_Clear(); //清屏 GUI_SetPenSize(3); //设置点的大小 GUI_DispString("Measurement of\nA/D converter values"); while (1) { GUI_PID_STATE TouchState; int xPhys, yPhys; GUI_TOUCH_GetState(&TouchState); /* 获得触控位置 */ xPhys = GUI_TOUCH_GetxPhys(); /* 获得x轴的测量值 */ yPhys = GUI_TOUCH_GetyPhys(); /* 获得y轴的测量值 */ /* 显示测量结果 */ GUI_SetColor(GUI_BLUE); GUI_DispStringAt("Analog input:\n", 0, 20); GUI_GotoY(GUI_GetDispPosY() + 2); GUI_DispString("x:"); GUI_DispDec(xPhys, 4); GUI_DispString(", y:"); GUI_DispDec(yPhys, 4); /* Display the according position */ GUI_SetColor(GUI_RED); GUI_GotoY(GUI_GetDispPosY() + 4); GUI_DispString("\nPosition:\n"); GUI_GotoY(GUI_GetDispPosY() + 2); GUI_DispString("x:"); GUI_DispDec(TouchState.x,4); GUI_DispString(", y:"); GUI_DispDec(TouchState.y,4); GUI_DrawPoint(TouchState.x, TouchState.y); GUI_TOUCH_Exec(); } }
/** * @brief This function handles SysTick Handler. * @param None * @retval None */ void SysTick_Handler(void) { static uint8_t count_time=0; OS_TimeMS ++; count_time++; if(count_time == 10) { GUI_TOUCH_Exec(); //每10ms调用一次,触发调用触摸驱动 count_time =0; } LED_Toggle(); //每100ms反转一次led }
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); } }
void TIM2_IRQHandler(void) //TIM2中断 { static u16 i=0; if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) //检查指定的TIM中断发生与否:TIM 中断源 { //PE_OUT(1); TIM_ClearITPendingBit(TIM2, TIM_IT_Update ); //清除TIMx的中断待处理位:TIM 中断源 GUI_TOUCH_Exec(); // GUI_Exec(); // Sin_Data[i]=100*sin((double)(i*3.14/40))+200;if (i == 1024) i = 0; //PE_OUT(0); // DAC_SetChannel1Data(DAC_Align_12b_R,1000+2000*sin((double)(i*3.14/40))); DAC_SetChannel1Data(DAC_Align_12b_R,10); i++; if (i == 80) i = 0; } }
/** * @brief: Task3 * @param in: None * @param out: None * * @retval: None */ static void Task3(void *p_arg) { OS_ERR err; static int tasCon = 0; while (1) { GUI_TOUCH_Exec(); printf("task3 is running\r\n"); OSTimeDly( (OS_TICK )10, (OS_OPT )OS_OPT_TIME_DLY, (OS_ERR *)&err); OSTimeDly( (OS_TICK )10, (OS_OPT )OS_OPT_TIME_DLY, (OS_ERR *)&err); if ((tasCon++ % 50) < 25) led_on(LED_3); else led_off(LED_3); } }
static void RunTouchPanelTask(void) { while (1) { GUI_TOUCH_Exec(); OSTimeDlyHMSM(0, 0, 0, 20); } }
/********************************************************************* * * _ExecTouch * * Function description: * Check for new touch event. Static x, y coordinates will be updated * by the _CheckUpdateTouch() routine. If no touch event has occurred * we do nothing. */ static void _ExecTouch(void) { GUI_TOUCH_Exec(); }