diff --git a/examples/companion_radio/ui-new/UITask.cpp b/examples/companion_radio/ui-new/UITask.cpp index f0f9ed1d..a02b0288 100644 --- a/examples/companion_radio/ui-new/UITask.cpp +++ b/examples/companion_radio/ui-new/UITask.cpp @@ -419,38 +419,34 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i if (_display != NULL) { if (!_display->isOn()) _display->turnOn(); _auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer - _next_refresh = 0; // trigger refresh + _next_refresh = 100; // trigger refresh } } void UITask::userLedHandler() { #ifdef PIN_STATUS_LED - static int state = 0; - static int next_change = 0; - static int last_increment = 0; - int cur_time = millis(); - if (cur_time > next_change) { - if (state == 0) { - state = 1; + if (cur_time > next_led_change) { + if (led_state == 0) { + led_state = 1; if (_msgcount > 0) { - last_increment = LED_ON_MSG_MILLIS; + last_led_increment = LED_ON_MSG_MILLIS; } else { - last_increment = LED_ON_MILLIS; + last_led_increment = LED_ON_MILLIS; } - next_change = cur_time + last_increment; + next_led_change = cur_time + last_led_increment; } else { - state = 0; - next_change = cur_time + LED_CYCLE_MILLIS - last_increment; + led_state = 0; + next_led_change = cur_time + LED_CYCLE_MILLIS - last_led_increment; } - digitalWrite(PIN_STATUS_LED, state); + digitalWrite(PIN_STATUS_LED, led_state); } #endif } void UITask::setCurrScreen(UIScreen* c) { curr = c; - _next_refresh = 0; + _next_refresh = 100; } /* @@ -520,18 +516,17 @@ void UITask::loop() { } #endif #if defined(DISP_BACKLIGHT) && defined(BACKLIGHT_BTN) - static int next_btn_check = 0; - if (millis() > next_btn_check) { + if (millis() > next_backlight_btn_check) { bool touch_state = digitalRead(PIN_BUTTON2); digitalWrite(DISP_BACKLIGHT, !touch_state); - next_btn_check = millis() + 300; + next_backlight_btn_check = millis() + 300; } #endif if (c != 0 && curr) { curr->handleInput(c); _auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer - _next_refresh = 0; // trigger refresh + _next_refresh = 100; // trigger refresh } userLedHandler(); diff --git a/examples/companion_radio/ui-new/UITask.h b/examples/companion_radio/ui-new/UITask.h index f9e01550..3a27e55f 100644 --- a/examples/companion_radio/ui-new/UITask.h +++ b/examples/companion_radio/ui-new/UITask.h @@ -26,6 +26,12 @@ class UITask : public AbstractUITask { unsigned long _alert_expiry; int _msgcount; unsigned long ui_started_at, next_batt_chck; + int next_backlight_btn_check = 0; +#ifdef PIN_STATUS_LED + int led_state = 0; + int next_led_change = 0; + int last_led_increment = 0; +#endif UIScreen* splash; UIScreen* home; diff --git a/src/helpers/ui/GxEPDDisplay.cpp b/src/helpers/ui/GxEPDDisplay.cpp index 9ba7d074..49022d74 100644 --- a/src/helpers/ui/GxEPDDisplay.cpp +++ b/src/helpers/ui/GxEPDDisplay.cpp @@ -28,7 +28,7 @@ bool GxEPDDisplay::begin() { void GxEPDDisplay::turnOn() { if (!_init) begin(); -#if defined(DISP_BACKLIGHT) && !defined(BACLIGHT_BTN) +#if defined(DISP_BACKLIGHT) && !defined(BACKLIGHT_BTN) digitalWrite(DISP_BACKLIGHT, HIGH); #endif _isOn = true; diff --git a/variants/techo/platformio.ini b/variants/techo/platformio.ini index 260be35f..f748fdfe 100644 --- a/variants/techo/platformio.ini +++ b/variants/techo/platformio.ini @@ -92,3 +92,4 @@ lib_deps = ${LilyGo_Techo.lib_deps} densaugeo/base64 @ ~1.4.0 zinggjm/GxEPD2 @ 1.6.2 + bakercp/CRC32 @ ^2.0.0