|
void Touch_MainTask(void)
{
GUI_PID_STATE TouchState;
int xPhys, yPhys;
GUI_CURSOR_Show();
GUI_CURSOR_Select(&GUI_CursorCrossL);
GUI_SetBkColor(GUI_WHITE);
GUI_SetColor(GUI_BLACK);
GUI_Clear();
GUI_DispString("Measurement of\nA/D converter values");
while(1)
{
GUI_TOUCH_GetState(&TouchState); /* Get the touch position in pixel */
xPhys = GUI_TOUCH_GetxPhys(); /* Get the A/D mesurement result in x */
yPhys = GUI_TOUCH_GetyPhys(); /* Get the A/D mesurement result in y */
/* Display the measurement result */
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);
/* Wait a while */
GUI_Delay(1);
GUI_TOUCH_Exec(); //-----------------------问题1
}
}
问题1:GUI_TOUCH_Exec()代码必须放在这段代码中才能实现触摸校准运行,放在10ms定时中断中无法实现触摸校准功能;
问题2:在这段代码中增加LED闪烁:
while(1)
{
GUI_TOUCH_GetState(&TouchState); /* Get the touch position in pixel */
xPhys = GUI_TOUCH_GetxPhys(); /* Get the A/D mesurement result in x */
yPhys = GUI_TOUCH_GetyPhys(); /* Get the A/D mesurement result in y */
/* Display the measurement result */
GUI_SetColor(GUI_BLUE);
........... ...........
/* Wait a while */
GUI_Delay(1);
GUI_TOUCH_Exec();
//问题2:增加的LED闪烁代码
if (bFlag == SET) //10ms中断标志
{
static uint8_t LedCnt = 50;
bFlag = RESET;
if (--LedCnt == 0)
{
LedCnt = 50;
TEST_LED_TOGGLE;
}
}
}
测试发现LED不是0.5s闪烁,延迟很厉害,大概3~4秒,去掉GUI_Delay(1)和 GUI_TOUCH_Exec()代码也一样,只有去掉GUI_Delay(1)和 GUI_TOUCH_Exec()之前的代码才能正常闪烁,说明问题不在这两句代码,这些代码为什么阻塞如此严重? |
|