Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/companion_radio/ui-new/UITask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
_display = display;
_sensors = sensors;
_auto_off = millis() + AUTO_OFF_MILLIS;
_was_ext_powered = board.isExternalPowered(); // don't fire wake-on-connect if booted while powered

#if defined(PIN_USER_BTN)
user_btn.begin();
Expand Down Expand Up @@ -775,6 +776,15 @@ void UITask::loop() {
}
#endif

// Wake the display when external (USB) power is newly connected, as if a key
// was pressed. Only acts when the screen is currently off, so an already-lit
// display is left untouched (it still auto-offs unless KEEP_DISPLAY_ON_USB).
bool ext_powered = board.isExternalPowered();
if (ext_powered && !_was_ext_powered && _display != NULL && !_display->isOn()) {
c = checkDisplayOn(c);
}
_was_ext_powered = ext_powered;

if (c != 0 && curr) {
curr->handleInput(c);
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
Expand Down
1 change: 1 addition & 0 deletions examples/companion_radio/ui-new/UITask.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class UITask : public AbstractUITask {
int _msgcount;
unsigned long ui_started_at, next_batt_chck;
int next_backlight_btn_check = 0;
bool _was_ext_powered = false; // tracks USB/external power edge for wake-on-connect
#ifdef PIN_STATUS_LED
int led_state = 0;
int next_led_change = 0;
Expand Down
13 changes: 13 additions & 0 deletions examples/companion_radio/ui-orig/UITask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
_display = display;
_sensors = sensors;
_auto_off = millis() + AUTO_OFF_MILLIS;
_was_ext_powered = board.isExternalPowered(); // don't fire wake-on-connect if booted while powered
clearMsgPreview();
_node_prefs = node_prefs;
if (_display != NULL) {
Expand Down Expand Up @@ -329,6 +330,18 @@ void UITask::loop() {
if (buzzer.isPlaying()) buzzer.loop();
#endif

// Wake the display when external (USB) power is newly connected, as if a
// button was pressed. Only acts when the screen is currently off, so an
// already-lit display is left untouched (it still auto-offs unless
// KEEP_DISPLAY_ON_USB).
bool ext_powered = board.isExternalPowered();
if (ext_powered && !_was_ext_powered && _display != NULL && !_display->isOn()) {
_display->turnOn();
_auto_off = millis() + AUTO_OFF_MILLIS;
_need_refresh = true;
}
_was_ext_powered = ext_powered;

if (_display != NULL && _display->isOn()) {
static bool _firstBoot = true;
if(_firstBoot && (millis() - ui_started_at) >= BOOT_SCREEN_MILLIS) {
Expand Down
1 change: 1 addition & 0 deletions examples/companion_radio/ui-orig/UITask.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class UITask : public AbstractUITask {
int _msgcount;
bool _need_refresh = true;
bool _displayWasOn = false; // Track display state before button press
bool _was_ext_powered = false; // tracks USB/external power edge for wake-on-connect
unsigned long ui_started_at;

// Button handlers
Expand Down
10 changes: 10 additions & 0 deletions examples/companion_radio/ui-tiny/UITask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ void UITask::begin(DisplayDriver* display, SensorManager* sensors, NodePrefs* no
_display = display;
_sensors = sensors;
_auto_off = millis() + AUTO_OFF_MILLIS;
_was_ext_powered = board.isExternalPowered(); // don't fire wake-on-connect if booted while powered
_cached_batt_mv = getBattMilliVolts();

#if defined(PIN_USER_BTN)
Expand Down Expand Up @@ -653,6 +654,15 @@ void UITask::loop() {
}
#endif

// Wake the display when external (USB) power is newly connected, as if a key
// was pressed. Only acts when the screen is currently off, so an already-lit
// display is left untouched (it still auto-offs unless KEEP_DISPLAY_ON_USB).
bool ext_powered = board.isExternalPowered();
if (ext_powered && !_was_ext_powered && _display != NULL && !_display->isOn()) {
c = checkDisplayOn(c);
}
_was_ext_powered = ext_powered;

if (c != 0 && curr) {
curr->handleInput(c);
_auto_off = millis() + AUTO_OFF_MILLIS; // extend auto-off timer
Expand Down
1 change: 1 addition & 0 deletions examples/companion_radio/ui-tiny/UITask.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class UITask : public AbstractUITask {
int _msgcount;
unsigned long ui_started_at, next_batt_chck;
int next_backlight_btn_check = 0;
bool _was_ext_powered = false; // tracks USB/external power edge for wake-on-connect
uint16_t _cached_batt_mv;
#ifdef PIN_STATUS_LED
int led_state = 0;
Expand Down