Skip to content

Commit cb3049e

Browse files
committed
cleanups (remove statics and typos)
1 parent 3cdf2f9 commit cb3049e

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

examples/companion_radio/ui-new/UITask.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -419,38 +419,34 @@ void UITask::newMsg(uint8_t path_len, const char* from_name, const char* text, i
419419
if (_display != NULL) {
420420
if (!_display->isOn()) _display->turnOn();
421421
_auto_off = millis() + AUTO_OFF_MILLIS; // extend the auto-off timer
422-
_next_refresh = 0; // trigger refresh
422+
_next_refresh = 100; // trigger refresh
423423
}
424424
}
425425

426426
void UITask::userLedHandler() {
427427
#ifdef PIN_STATUS_LED
428-
static int state = 0;
429-
static int next_change = 0;
430-
static int last_increment = 0;
431-
432428
int cur_time = millis();
433-
if (cur_time > next_change) {
434-
if (state == 0) {
435-
state = 1;
429+
if (cur_time > next_led_change) {
430+
if (led_state == 0) {
431+
led_state = 1;
436432
if (_msgcount > 0) {
437-
last_increment = LED_ON_MSG_MILLIS;
433+
last_led_increment = LED_ON_MSG_MILLIS;
438434
} else {
439-
last_increment = LED_ON_MILLIS;
435+
last_led_increment = LED_ON_MILLIS;
440436
}
441-
next_change = cur_time + last_increment;
437+
next_led_change = cur_time + last_led_increment;
442438
} else {
443-
state = 0;
444-
next_change = cur_time + LED_CYCLE_MILLIS - last_increment;
439+
led_state = 0;
440+
next_led_change = cur_time + LED_CYCLE_MILLIS - last_led_increment;
445441
}
446-
digitalWrite(PIN_STATUS_LED, state);
442+
digitalWrite(PIN_STATUS_LED, led_state);
447443
}
448444
#endif
449445
}
450446

451447
void UITask::setCurrScreen(UIScreen* c) {
452448
curr = c;
453-
_next_refresh = 0;
449+
_next_refresh = 100;
454450
}
455451

456452
/*
@@ -520,18 +516,17 @@ void UITask::loop() {
520516
}
521517
#endif
522518
#if defined(DISP_BACKLIGHT) && defined(BACKLIGHT_BTN)
523-
static int next_btn_check = 0;
524-
if (millis() > next_btn_check) {
519+
if (millis() > next_backlight_btn_check) {
525520
bool touch_state = digitalRead(PIN_BUTTON2);
526521
digitalWrite(DISP_BACKLIGHT, !touch_state);
527-
next_btn_check = millis() + 300;
522+
next_backlight_btn_check = millis() + 300;
528523
}
529524
#endif
530525

531526
if (c != 0 && curr) {
532527
curr->handleInput(c);
533528
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
534-
_next_refresh = 0; // trigger refresh
529+
_next_refresh = 100; // trigger refresh
535530
}
536531

537532
userLedHandler();

examples/companion_radio/ui-new/UITask.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ class UITask : public AbstractUITask {
2626
unsigned long _alert_expiry;
2727
int _msgcount;
2828
unsigned long ui_started_at, next_batt_chck;
29+
int next_backlight_btn_check = 0;
30+
#ifdef PIN_STATUS_LED
31+
int led_state = 0;
32+
int next_led_change = 0;
33+
int last_led_increment = 0;
34+
#endif
2935

3036
UIScreen* splash;
3137
UIScreen* home;

src/helpers/ui/GxEPDDisplay.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bool GxEPDDisplay::begin() {
2828

2929
void GxEPDDisplay::turnOn() {
3030
if (!_init) begin();
31-
#if defined(DISP_BACKLIGHT) && !defined(BACLIGHT_BTN)
31+
#if defined(DISP_BACKLIGHT) && !defined(BACKLIGHT_BTN)
3232
digitalWrite(DISP_BACKLIGHT, HIGH);
3333
#endif
3434
_isOn = true;

variants/techo/platformio.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ lib_deps =
9292
${LilyGo_Techo.lib_deps}
9393
densaugeo/base64 @ ~1.4.0
9494
zinggjm/GxEPD2 @ 1.6.2
95+
bakercp/CRC32 @ ^2.0.0

0 commit comments

Comments
 (0)