companion_radio: keep OLED on while externally powered 🤖🤖#2643
Open
disq wants to merge 1 commit into
Open
Conversation
AUTO_OFF_MILLIS is a power-save feature aimed at battery use. When the board reports isExternalPowered() == true (USB or other DC source), blanking the screen serves no purpose — there's nothing to conserve. Instead of just gating the turnOff() call on isExternalPowered() (which caused the display to blank instantly the moment power was removed, because the timer had silently expired while powered), refresh _auto_off every loop iteration that's externally powered. That way the timer naturally counts a fresh AUTO_OFF_MILLIS window from the moment USB is unplugged. Applied to all three companion_radio UI flavours (ui-new, ui-tiny, ui-orig). Boards without an isExternalPowered() override use the base-class default in MeshCore.h (returns false), so battery-powered behaviour is unchanged everywhere. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AUTO_OFF_MILLISis a power-save feature aimed at battery use. When the board reportsisExternalPowered() == true(USB or other DC source), blanking the screen serves no purpose — there's nothing to conserve. This PR makes the OLED stay on while externally powered, and starts the auto-off countdown from the moment power is removed (not from when it was applied).Approach
Inside the
_display->isOn()block of each companion UI flavour'sloop(), refresh_auto_offwheneverboard.isExternalPowered()returns true:```cpp
#if AUTO_OFF_MILLIS > 0
if (board.isExternalPowered()) {
_auto_off = millis() + AUTO_OFF_MILLIS;
}
if (millis() > _auto_off) {
_display->turnOff();
}
#endif
```
While USB-powered,
_auto_offis pushed forward every tick so the existing turn-off branch never fires. The instantisExternalPowered()goes false, the refresh stops and the timer counts down naturally — giving a full freshAUTO_OFF_MILLISwindow before the screen blanks. No instantaneous-blank-on-unplug.Applied to all three companion_radio UI flavours:
ui-new,ui-tiny,ui-orig.Safety
MeshCore.hdefinesvirtual bool isExternalPowered() { return false; }as the base-class default. Boards without an override compile to identical pre-change behaviour.NRF52Boardoverrides it only whenNRF52_POWER_MANAGEMENTis defined (RAK3401, RAK4631, etc.).Why not also
simple_repeater/simple_room_server/simple_sensorThose examples target set-and-forget battery-powered deployments by convention. Easy follow-up if maintainers want the same behaviour there.
Testing
Verified on RAK3401 + companion_radio_ble:
AUTO_OFF_MILLIS(15 s default).🤖 Generated with Claude Code