cleanups (remove statics and typos)

This commit is contained in:
Florent
2025-09-03 17:22:11 +02:00
parent 3cdf2f9b4d
commit cb3049e706
4 changed files with 22 additions and 20 deletions

View File

@@ -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();

View File

@@ -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;

View File

@@ -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;

View File

@@ -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