|
@@ -38,6 +38,7 @@
|
38
|
38
|
#define LEDC_BASE_FREQ 5000
|
39
|
39
|
|
40
|
40
|
#define LDR_PIN 34
|
|
41
|
+#define BTN_PIN 0
|
41
|
42
|
|
42
|
43
|
#define TOUCH_LEFT 180
|
43
|
44
|
#define TOUCH_RIGHT 3750
|
|
@@ -226,6 +227,8 @@ void ui_init(void) {
|
226
|
227
|
ledcAttachPin(TFT_BL, LEDC_CHANNEL_0);
|
227
|
228
|
ledcAnalogWrite(LEDC_CHANNEL_0, 255);
|
228
|
229
|
|
|
230
|
+ pinMode(BTN_PIN, INPUT);
|
|
231
|
+
|
229
|
232
|
pinMode(LDR_PIN, ANALOG);
|
230
|
233
|
analogSetAttenuation(ADC_0db);
|
231
|
234
|
analogReadResolution(12);
|
|
@@ -315,6 +318,10 @@ void ui_progress(enum ui_state state) {
|
315
|
318
|
void ui_run(void) {
|
316
|
319
|
unsigned long now = millis();
|
317
|
320
|
|
|
321
|
+ if (!digitalRead(BTN_PIN)) {
|
|
322
|
+ ui_page = UI_INFO;
|
|
323
|
+ }
|
|
324
|
+
|
318
|
325
|
if (now >= (last_ldr + LDR_CHECK_MS)) {
|
319
|
326
|
last_ldr = now;
|
320
|
327
|
int ldr = analogRead(LDR_PIN);
|
|
@@ -345,12 +352,10 @@ void ui_run(void) {
|
345
|
352
|
last_touch_time = millis();
|
346
|
353
|
|
347
|
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
|
357
|
ui_page = (enum ui_pages)((ui_page + 1) % UI_NUM_PAGES);
|
353
|
|
- }
|
|
358
|
+ } while ((ui_page == UI_START) || (ui_page == UI_INFO));
|
354
|
359
|
tft.fillScreen(TFT_BLACK);
|
355
|
360
|
|
356
|
361
|
ui_draw_menu();
|
|
@@ -421,12 +426,10 @@ void ui_run(void) {
|
421
|
426
|
}
|
422
|
427
|
writeMQTT_UI();
|
423
|
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
|
431
|
ui_page = (enum ui_pages)((ui_page + 1) % UI_NUM_PAGES);
|
429
|
|
- }
|
|
432
|
+ } while ((ui_page == UI_START) || (ui_page == UI_INFO));
|
430
|
433
|
tft.fillScreen(TFT_BLACK);
|
431
|
434
|
}
|
432
|
435
|
|