Skip to content

[Power Manager] Round battery percentage #3904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

RKBoss6
Copy link
Contributor

@RKBoss6 RKBoss6 commented Jun 24, 2025

I noticed that when monotonic percentage was selected, it displayed percentages with decimals, which was hard to read in most battery widgets, so I fixed it here.

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Jun 24, 2025

Thanks!

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Jun 25, 2025

I also have noticed that monotonic percentage is not truly monotonic, it fluctuates, instead of only going down when not charging, and up when charging.

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Jun 25, 2025

I will see if I can fix it, but anyone else is welcome to take a look as well

Copy link
Contributor

@stweedo stweedo left a comment

Choose a reason for hiding this comment

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

if (settings.forceMonoPercentage){
    var p = Math.round((E.getBattery()+E.getBattery()+E.getBattery()+E.getBattery())/4);
    var op = E.getBattery;
    E.getBattery = function() {
      var current = Math.round((op()+op()+op()+op())/4);
      if (Bangle.isCharging() && current > p) p = current;
      if (!Bangle.isCharging() && current < p) p = current;
      return p;
    };
  }

Rounding the p value right away might be slightly cleaner logic.

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.

3 participants