Browse Source

enter ui info page with physical instead of touch button

Thomas Buck 5 months ago
parent
commit
7c8c313742
1 changed files with 13 additions and 10 deletions
  1. 13
    10
      src/ui.cpp

+ 13
- 10
src/ui.cpp View File

38
 #define LEDC_BASE_FREQ 5000
38
 #define LEDC_BASE_FREQ 5000
39
 
39
 
40
 #define LDR_PIN 34
40
 #define LDR_PIN 34
41
+#define BTN_PIN 0
41
 
42
 
42
 #define TOUCH_LEFT 180
43
 #define TOUCH_LEFT 180
43
 #define TOUCH_RIGHT 3750
44
 #define TOUCH_RIGHT 3750
226
     ledcAttachPin(TFT_BL, LEDC_CHANNEL_0);
227
     ledcAttachPin(TFT_BL, LEDC_CHANNEL_0);
227
     ledcAnalogWrite(LEDC_CHANNEL_0, 255);
228
     ledcAnalogWrite(LEDC_CHANNEL_0, 255);
228
 
229
 
230
+    pinMode(BTN_PIN, INPUT);
231
+
229
     pinMode(LDR_PIN, ANALOG);
232
     pinMode(LDR_PIN, ANALOG);
230
     analogSetAttenuation(ADC_0db);
233
     analogSetAttenuation(ADC_0db);
231
     analogReadResolution(12);
234
     analogReadResolution(12);
315
 void ui_run(void) {
318
 void ui_run(void) {
316
     unsigned long now = millis();
319
     unsigned long now = millis();
317
 
320
 
321
+    if (!digitalRead(BTN_PIN)) {
322
+        ui_page = UI_INFO;
323
+    }
324
+
318
     if (now >= (last_ldr + LDR_CHECK_MS)) {
325
     if (now >= (last_ldr + LDR_CHECK_MS)) {
319
         last_ldr = now;
326
         last_ldr = now;
320
         int ldr = analogRead(LDR_PIN);
327
         int ldr = analogRead(LDR_PIN);
345
         last_touch_time = millis();
352
         last_touch_time = millis();
346
 
353
 
347
         if (ui_page == UI_INFO) {
354
         if (ui_page == UI_INFO) {
348
-            // switch to next page
349
-            ui_page = (enum ui_pages)((ui_page + 1) % UI_NUM_PAGES);
350
-            if (ui_page == UI_START) {
351
-                // skip init screen
355
+            // switch to next page, skip init and info screen
356
+            do {
352
                 ui_page = (enum ui_pages)((ui_page + 1) % UI_NUM_PAGES);
357
                 ui_page = (enum ui_pages)((ui_page + 1) % UI_NUM_PAGES);
353
-            }
358
+            } while ((ui_page == UI_START) || (ui_page == UI_INFO));
354
             tft.fillScreen(TFT_BLACK);
359
             tft.fillScreen(TFT_BLACK);
355
 
360
 
356
             ui_draw_menu();
361
             ui_draw_menu();
421
             }
426
             }
422
             writeMQTT_UI();
427
             writeMQTT_UI();
423
         } else if ((p.x >= BTNS_OFF_X + BTN_W + BTN_GAP) && (p.x <= BTNS_OFF_X + BTN_W + BTN_GAP + BTN_W) && (p.y >= (BTNS_OFF_Y + BTN_H * 2 + BTN_GAP * 2)) && (p.y <= (BTNS_OFF_Y + BTN_H * 2 + BTN_GAP * 2 + BTN_H))) {
428
         } else if ((p.x >= BTNS_OFF_X + BTN_W + BTN_GAP) && (p.x <= BTNS_OFF_X + BTN_W + BTN_GAP + BTN_W) && (p.y >= (BTNS_OFF_Y + BTN_H * 2 + BTN_GAP * 2)) && (p.y <= (BTNS_OFF_Y + BTN_H * 2 + BTN_GAP * 2 + BTN_H))) {
424
-            // switch to next page
425
-            ui_page = (enum ui_pages)((ui_page + 1) % UI_NUM_PAGES);
426
-            if (ui_page == UI_START) {
427
-                // skip init screen
429
+            // switch to next page, skip init and info screen
430
+            do {
428
                 ui_page = (enum ui_pages)((ui_page + 1) % UI_NUM_PAGES);
431
                 ui_page = (enum ui_pages)((ui_page + 1) % UI_NUM_PAGES);
429
-            }
432
+            } while ((ui_page == UI_START) || (ui_page == UI_INFO));
430
             tft.fillScreen(TFT_BLACK);
433
             tft.fillScreen(TFT_BLACK);
431
         }
434
         }
432
 
435
 

Loading…
Cancel
Save