Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 12 months ago.
STM32F469 Gestures problem
Hi guys.
I'm trying to program gestures in my software, but so far without success. This is my program. Can anyone tell me what I'm doing wrong?
Thanks.
include the mbed library with this snippet
#include "mbed.h" #include "TS_DISCO_F469NI.h" #include "LCD_DISCO_F469NI.h" #include "rtos.h" #include "fonts.h" LCD_DISCO_F469NI lcd; TS_DISCO_F469NI ts; DigitalOut led1(LED1); DigitalOut led2(LED2); DigitalOut led3(LED3); DigitalOut led4(LED4); Serial pc(USBTX, USBRX); // tx, rx Thread thread[3]; void led2_thread() { while (true) { led2 = !led2; wait(1); } } int main() { //Serial pc.baud(9600); thread[0].start(led2_thread); led4=led1=led2=1; TS_StateTypeDef TS_State; TS_StateTypeDef TS_State_2; uint16_t x, y; uint8_t text[30]; uint8_t status; uint8_t idx; uint8_t cleared = 0; uint8_t prev_nb_touches = 0; BSP_LCD_SetFont(&Font24); status = ts.Init(lcd.GetXSize(), lcd.GetYSize()); if (status != TS_OK) { lcd.Clear(LCD_COLOR_RED); lcd.SetBackColor(LCD_COLOR_RED); lcd.SetTextColor(LCD_COLOR_WHITE); lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE); } else { lcd.Clear(LCD_COLOR_GREEN); lcd.SetBackColor(LCD_COLOR_GREEN); lcd.SetTextColor(LCD_COLOR_WHITE); lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE); } wait(1); lcd.SetBackColor(LCD_COLOR_BLUE); lcd.SetTextColor(LCD_COLOR_WHITE); while(1) { ts.GetState(&TS_State); if (TS_State.touchDetected) { led3 = !led3; wait(.1); } // HERE IS THE PROBLEM ts.Get_GestureId(&TS_State_2); if (TS_State_2.gestureId==GEST_ID_MOVE_RIGHT) { led1 = !led1; wait(.1); } } }
1 Answer
6 years, 12 months ago.
Dont know if that solves the problem, but you should use Thread::wait (milisec) instead of the blocking wait() for the LED which could freeze up your main handling the touchscreen.