companion_radio: Add optional KEEP_DISPLAY_ON_USB flag to keep display on while powered 🤖🤖#2643
Open
disq wants to merge 1 commit into
Open
companion_radio: Add optional KEEP_DISPLAY_ON_USB flag to keep display on while powered 🤖🤖#2643disq wants to merge 1 commit into
KEEP_DISPLAY_ON_USB flag to keep display on while powered 🤖🤖#2643disq wants to merge 1 commit into
Conversation
|
Not a diss to the intent of the PR, but FWIW, OLEDs suffer screen burn-in ridiculously quick. Freedom to choose one's destiny of course, but the default should probably be off but an option. Samsung tried to solve this by rotating pixels around the display on their OLED watches subtly, so burn-in would be more equal, but it's so complicated on finite display life. On the LCD nodes like the Heltec T096 though, bring it on! |
…ered 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. But OLEDs are vulnerable to burn-in with static content, so this behaviour is gated behind a new build flag KEEP_DISPLAY_ON_USB. Default is unchanged from upstream — the display blanks after AUTO_OFF_MILLIS on USB or battery. Variants that ship with an LCD instead of an OLED (e.g. heltec_t096) can opt in by adding -D KEEP_DISPLAY_ON_USB to their env, gaining always-on-while-powered without exposing OLED users to burn-in risk. When the flag is enabled, the implementation refreshes _auto_off every loop iteration while externally powered, so the timer naturally counts a fresh AUTO_OFF_MILLIS window from the moment power is removed — no instantaneous-blank-on-unplug. 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>
31cacac to
bb781ff
Compare
Author
|
@NickDunklee Good point :) Updated the PR: the keep-on-while-powered behaviour is now gated behind |
KEEP_DISPLAY_ON_USB flag to keep display on while powered 🤖🤖
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
Optional build flag
KEEP_DISPLAY_ON_USBthat suppresses the companion radio'sAUTO_OFF_MILLISscreen-blanking timer only while the board reportsisExternalPowered() == true. Default is unchanged — the display still blanks afterAUTO_OFF_MILLISon every existing build. The flag is purely opt-in; LCD-based variants (e.g.heltec_t096) can add-D KEEP_DISPLAY_ON_USBto their env to gain always-on-while-powered behaviour. OLED-based variants stay on the safe default to avoid burn-in.Why opt-in and not on by default
OLED panels burn in quickly with static content, so unconditionally keeping the screen on while USB-powered would degrade those displays. Thanks to the reviewer for raising this — defaulting to off and exposing it as a flag is the right shape. LCD targets where burn-in isn't a concern can opt in per-env without imposing the risk on every existing board.
Implementation
When
KEEP_DISPLAY_ON_USBis defined, each companion UI flavour'sloop()refreshes_auto_offevery tick thatboard.isExternalPowered()is true:The refresh-while-powered pattern (rather than just guarding the
turnOff()call) means the timer counts a fresh fullAUTO_OFF_MILLISwindow from the moment USB is unplugged — no instant blank on unplug, no surprise. When the flag is not defined, the block compiles out and the build is byte-identical to upstream.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 are unaffected even if a downstream env adds-D KEEP_DISPLAY_ON_USB.NRF52BoardoverridesisExternalPowered()only whenNRF52_POWER_MANAGEMENTis defined (RAK3401, RAK4631, etc.).Testing
Verified on RAK3401 + companion_radio_ble (no env change — flag undefined):
Same build with
-D KEEP_DISPLAY_ON_USBadded to the env:AUTO_OFF_MILLIS.🤖 Generated with Claude Code