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 13 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.

@RKBoss6 RKBoss6 marked this pull request as draft June 26, 2025 01:27
@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Jul 22, 2025

I've renamed the monotonic percentage and voltage to be stable percentage, because it is not truly monotonic, and in my mind, it makes much more sense this way. To not break existing user's settings, I only changed the display name. Under the hood, it's still saved as monotonic.

@RKBoss6 RKBoss6 marked this pull request as ready for review July 22, 2025 15:58
@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Jul 23, 2025

@bobrippling @stweedo What do you guys think, should it be monotonic, or does stable make sense here? Just making sure everyone else is fine with the change, and it doesn't just make sense to me...

@bobrippling
Copy link
Collaborator

@bobrippling @stweedo What do you guys think, should it be monotonic, or does stable make sense here? Just making sure everyone else is fine with the change, and it doesn't just make sense to me...

Gonna be honest with you, I don't know what monotonic means and wouldn't expect the average bangle user to either, so I would vote for stable or bounded too

@RKBoss6
Copy link
Contributor Author

RKBoss6 commented Jul 30, 2025

@bobrippling Yeah, I had to look it up when I came across it as well 🤣, stable seems much more user-friendly to me. Monotonic is how smartphones' battery meters work, only going in one direction unless charging, and while this stabilizes it, it doesn't prevent fluctuations, so stable seems like a much better choice here..

@bobrippling
Copy link
Collaborator

Nice, yeah that makes sense to me - happy to merge if you are (looks like there's a small linting thing left to sort)

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.

4 participants