Merge pull request #3958 from RKBoss6/PowerManagerfix

[Power Manager] Fix percentage not updating.
master
Gordon Williams 2025-08-05 16:08:21 +02:00 committed by GitHub
commit 1743ef8d04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 21 deletions

View File

@ -14,3 +14,4 @@
Log additional timestamp for trace log Log additional timestamp for trace log
0.11: Minor code improvements 0.11: Minor code improvements
0.12: Round monotonic percentage, rename to stable percentage/voltage 0.12: Round monotonic percentage, rename to stable percentage/voltage
0.13: Fix stable percentage not updating

View File

@ -29,8 +29,6 @@
} }
} }
setInterval(save, saveEvery); setInterval(save, saveEvery);
E.on("kill", ()=>{ E.on("kill", ()=>{
@ -77,7 +75,6 @@
})(Bangle[functionName]); })(Bangle[functionName]);
} }
let wrapDeferred = ((o,t) => (a) => { let wrapDeferred = ((o,t) => (a) => {
if (a == eval || typeof a == "string") { if (a == eval || typeof a == "string") {
return o.apply(this, arguments); return o.apply(this, arguments);
@ -133,25 +130,19 @@
handleCharging(Bangle.isCharging()); handleCharging(Bangle.isCharging());
} }
var savedBatPercent=E.getBattery();
if (settings.forceMonoPercentage){ if (settings.forceMonoPercentage){
var newPercent =Math.round((E.getBattery()+E.getBattery()+E.getBattery()+E.getBattery()+E.getBattery()+E.getBattery())/6); var p = Math.round((E.getBattery()+E.getBattery()+E.getBattery()+E.getBattery())/4);
var op = E.getBattery;
E.getBattery = function() { E.getBattery = function() {
var current = Math.round((op()+op()+op()+op())/4);
if(Bangle.isCharging()){ if (Bangle.isCharging() && current > p) p = current;
if(newPercent > savedBatPercent) if (!Bangle.isCharging() && current < p) p = current;
savedBatPercent = newPercent; return p;
}else{
if(newPercent < savedBatPercent)
savedBatPercent = newPercent;
}
return savedBatPercent;
}; };
} }
if (settings.forceMonoVoltage){ if (settings.forceMonoVoltage){
var v = (NRF.getBattery()+NRF.getBattery()+NRF.getBattery()+NRF.getBattery()+NRF.getBattery()+NRF.getBattery())/6; var v = (NRF.getBattery()+NRF.getBattery()+NRF.getBattery()+NRF.getBattery())/4;
var ov = NRF.getBattery; var ov = NRF.getBattery;
NRF.getBattery = function() { NRF.getBattery = function() {
var current = (ov()+ov()+ov()+ov())/4; var current = (ov()+ov()+ov()+ov())/4;

View File

@ -2,7 +2,7 @@
"id": "powermanager", "id": "powermanager",
"name": "Power Manager", "name": "Power Manager",
"shortName": "Power Manager", "shortName": "Power Manager",
"version": "0.12", "version": "0.13",
"description": "Allow configuration of warnings for battery charging, stabilization of voltage, stabilization of battery percentage, and battery logging.", "description": "Allow configuration of warnings for battery charging, stabilization of voltage, stabilization of battery percentage, and battery logging.",
"icon": "app.png", "icon": "app.png",
"type": "bootloader", "type": "bootloader",