Przeglądaj źródła

only react to a single touch-down event, then wait until touch-up.

Thomas Buck 5 miesięcy temu
rodzic
commit
3ba034449a
1 zmienionych plików z 7 dodań i 2 usunięć
  1. 7
    2
      src/ui.cpp

+ 7
- 2
src/ui.cpp Wyświetl plik

@@ -67,6 +67,7 @@ enum ui_pages {
67 67
 };
68 68
 
69 69
 static enum ui_pages ui_page = UI_START;
70
+static bool is_touched = false;
70 71
 
71 72
 static TS_Point touchToScreen(TS_Point p) {
72 73
     p.x = map(p.x, TOUCH_LEFT, TOUCH_RIGHT, 0, LCD_WIDTH);
@@ -259,7 +260,10 @@ void ui_progress(enum ui_state state) {
259 260
 }
260 261
 
261 262
 void ui_run(void) {
262
-    if (ts.tirqTouched() && ts.touched()) {
263
+    bool touched = ts.tirqTouched() && ts.touched();
264
+
265
+    if (touched && (!is_touched)) {
266
+        is_touched = true;
263 267
         TS_Point p = touchToScreen(ts.getPoint());
264 268
 
265 269
         if ((p.x >= BTNS_OFF_X) && (p.x <= BTNS_OFF_X + BTN_W) && (p.y >= BTNS_OFF_Y) && (p.y <= BTNS_OFF_Y + BTN_H)) {
@@ -325,7 +329,8 @@ void ui_run(void) {
325 329
         }
326 330
 
327 331
         ui_draw_menu();
328
-        delay(100); // TODO
332
+    } else if ((!touched) && is_touched) {
333
+        is_touched = false;
329 334
     }
330 335
 }
331 336
 

Ładowanie…
Anuluj
Zapisz