Skip to content

feat: power saving - #22

Merged
ww24 merged 3 commits into
masterfrom
feat/power-saving
Oct 18, 2026
Merged

ww24 merged 3 commits into
masterfrom
feat/power-saving

Conversation

@ww24

@ww24 ww24 commented Oct 18, 2026

Copy link
Copy Markdown
Owner

This pull request adds an auto power-off feature and improves battery and display management for the device. The main changes include support for toggling auto power-off, improved battery status handling, adjustable display brightness with dimming, and more efficient screen updates.

Auto Power-Off Feature:

  • Added a new auto_power_off setting to the Display class, with persistent storage and a UI icon. Users can toggle this feature using a long press on Button B. [1] [2] [3] [4] [5] [6]

Battery and Display Management:

  • Implemented periodic battery status updates with retry logic for invalid readings, and display of battery voltage/current (with device-specific handling). [1] [2] [3]
  • Added display dimming after inactivity and restored brightness on user interaction.

UI and State Handling:

  • Optimized screen redraws to occur only when necessary, improving performance. [1] [2]
  • Updated event handling logic to track activity, manage brightness, and handle power-off conditions.

Code Quality Improvements:

  • Replaced hardcoded strings with class constants for preference keys and improved code structure for maintainability. [1] [2]

These changes collectively enhance power management, user experience, and code maintainability.

@ww24 ww24 self-assigned this Oct 18, 2026
@ww24
ww24 requested a balanced review from Copilot October 18, 2026 12:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Shutter-button activity does not restore brightness or reset the dimming timer.

1 open issue
What changed in this PR

Adds power-saving controls to the remote shutter device and reduces unnecessary display updates.

Changes:

  • Adds persistent auto power-off, toggled by holding Button B.
  • Introduces inactivity dimming and periodic battery reads with retries.
  • Redraws the screen only when its state changes.
File Description
src/​m5stick.cpp Implements power timers, battery polling, and conditional redraws.
src/​Display.cpp Persists auto power-off settings and renders its icon and device-specific battery details.
include/​Display.hpp Declares auto power-off state and controls.

Review effort: Balanced

Comment thread src/m5stick.cpp
}

if (M5.BtnA.isPressed() || M5.BtnA.wasPressed() || M5.BtnA.wasReleased()) {
last_activity_ms = now;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is by design. The shutter button (BtnA) is expected to be used frequently, and since the screen display remains unchanged, it was determined that there is no need to adjust the brightness; therefore, this behavior is exactly as intended.

@ww24
ww24 force-pushed the feat/power-saving branch from 1bde3e2 to 92a8a58 Compare October 18, 2026 16:39
@ww24
ww24 merged commit 25a6a05 into master Oct 18, 2026
1 check passed
@ww24
ww24 deleted the feat/power-saving branch October 18, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants