Skip to content

fw/services/battery: add optional 80% charge limit to extend battery lifespan#1156

Open
spr4bhu wants to merge 2 commits intocoredevices:mainfrom
spr4bhu:battery-charge-limit
Open

fw/services/battery: add optional 80% charge limit to extend battery lifespan#1156
spr4bhu wants to merge 2 commits intocoredevices:mainfrom
spr4bhu:battery-charge-limit

Conversation

@spr4bhu
Copy link
Copy Markdown
Contributor

@spr4bhu spr4bhu commented Apr 25, 2026

This PR adds a software charge limit feature that stops charging at 80% and resumes at 77% (3% hysteresis) to reduce lithium battery degradation from sustained high charge levels. The feature is exposed as a user-facing toggle in System settings, off by default.

Changes:

  • Add battery_charge_limit module that calls battery_set_charge_enable() to disable/re-enable charging based on battery percentage thresholds; includes a 60s rate limit to prevent rapid charger cycling and a 60s periodic timer to cover gaps in fuel gauge event delivery when charging is disabled

  • Add charge_limit_enabled pref (persistent on/off setting via SettingsFile, default false) with getter/setter following the existing stationary_mode_enabled pattern

  • Add "Charge Limit (80%)" toggle row in System settings menu, mirroring the existing "Stand-By Mode" toggle

  • Hook battery_charge_limit_evaluate() into battery_monitor_handle_state_change_event() and battery_charge_limit_init() into battery_monitor_init()

  • Register battery_charge_limit.c in services/battery/wscript_build

    Resolves Ability to limit battery charge to X% #722

Signed-off-by: Shashvat Prabhu <shashvatprabhu2006@gmail.com>
@spr4bhu spr4bhu force-pushed the battery-charge-limit branch from 7c3ae43 to a9117f6 Compare April 25, 2026 10:14
@EspressoTini
Copy link
Copy Markdown

Amazing, i have been meaning to circle back on this. Thank you so much!

@ericmigi
Copy link
Copy Markdown
Collaborator

Awesome. Thanks for the PR! Need to add this behind one of the features that only enables the setting to be shown on the phone side. We're reducing how many settings are shown on the Watch UI and encouraging people to add the setting on the phone side.

@jplexer do you have an example that we can show to folks on how to add this on both sides?

@jplexer
Copy link
Copy Markdown
Member

jplexer commented Apr 27, 2026

fw side it needs to be added to the settings blob db whitelist (like: 4d8abd9)

On the mobile side I do not know, @sjp4 definitely knows more there

Comment on lines +12 to +13
#define CHARGE_LIMIT_PCT 80
#define CHARGE_RESUME_PCT 77
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While plugged in, if not charging, the watch will run from USB power, so the battery will not drain. I guess you can simply disable the charger and forget about any hysteresis.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Made the changes, thanks.

Signed-off-by: Shashvat Prabhu <shashvatprabhu2006@gmail.com>
@spr4bhu spr4bhu force-pushed the battery-charge-limit branch from 93cd021 to 49c9c2a Compare April 28, 2026 10:54
@spr4bhu spr4bhu requested a review from gmarull April 28, 2026 11:15
@spr4bhu
Copy link
Copy Markdown
Contributor Author

spr4bhu commented Apr 28, 2026

@sjp4 can I have the format on how the features are to be added on phone side

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.

Ability to limit battery charge to X%

5 participants