companion_radio: wake display on USB connect 🤖🤖#2656
Open
disq wants to merge 1 commit into
Open
Conversation
Light up the screen when external (USB) power is newly connected, as if a key had been pressed. A new _was_ext_powered member tracks the previous power state so the wake only fires on the rising edge, and it is seeded from the current state in begin() so booting while already powered does not trigger a spurious wake. The wake only acts when the screen is currently off, so an already-lit display is left untouched (no timer extension, no injected input). By default the screen auto-offs normally afterwards; the existing KEEP_DISPLAY_ON_USB opt-in is what keeps it lit while powered, and the two compose cleanly. Applied consistently across the ui-new, ui-orig and ui-tiny variants. isExternalPowered() is only implemented on NRF52, so this is effectively NRF52-only and inert on other targets. Co-Authored-By: Claude Opus 4.8 <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.
What
Light up the screen when external (USB) power is newly connected, as if a key had been pressed.
_was_ext_poweredmember tracks the previous power state, so the wake only fires on the rising edge (ext_powered && !_was_ext_powered).begin(), so booting while already powered does not trigger a spurious wake.!_display->isOn()), so an already-lit display is left untouched — no timer extension, no injected input.KEEP_DISPLAY_ON_USBis what keeps it lit while powered; the two compose cleanly.Applied consistently across all three companion_radio UI variants:
ui-new,ui-orig,ui-tiny(mirroring the existingKEEP_DISPLAY_ON_USBplacement).Why
When a device is sitting with its screen off and you plug it into USB, it's natural to expect the display to wake so you can see status — without having to also press a button.
Notes for reviewers
isExternalPowered()is only implemented on NRF52 (VBUS detect); it returnsfalseon other platforms, so this feature is effectively NRF52-only and inert elsewhere — no behavior change on ESP32 targets.#define), unlikeKEEP_DISPLAY_ON_USB: a momentary wake doesn't carry the OLED burn-in risk that gated the keep-on feature. Happy to gate it behind a flag if preferred.GAT562_30S_Mesh_Kit_companion_radio_usb(ui-new) andXiao_nrf52_companion_radio_usb(ui-orig). TheLilyGo_T-Echo_Cardenv (ui-tiny) has a pre-existinggenericBuzzerlink error unrelated to this change (fails identically on the unmodified tree); the ui-tiny code is structurally identical to ui-new.🤖 Generated with Claude Code