powermanager - Allow forcing monotonic battery voltage/percentage

pull/1567/head
Martin Boonk 2022-03-13 20:54:06 +01:00
parent 8ed8d91518
commit aa53046f59
6 changed files with 46 additions and 3 deletions

View File

@ -1 +1,2 @@
0.01: New App!
0.02: Allow forcing monotonic battery voltage/percentage

View File

@ -1,6 +1,10 @@
# Power manager
Manages settings for charging. You can set a warning threshold to be able to disconnect the charger at a given percentage. Also allows to set the battery calibration offset.
Manages settings for charging.
Features:
* Warning threshold to be able to disconnect the charger at a given percentage
* Set the battery calibration offset.
* Force monotonic battery percentage or voltage
## Internals

View File

@ -26,4 +26,26 @@
Bangle.on("charging",handleCharging);
handleCharging(Bangle.isCharging());
}
if (settings.forceMonoPercentage){
var p = (E.getBattery()+E.getBattery()+E.getBattery()+E.getBattery())/4;
var op = E.getBattery;
E.getBattery = function() {
var current = (op()+op()+op()+op())/4;
if (Bangle.isCharging() && current > p) p = current;
if (!Bangle.isCharging() && current < p) p = current;
return p;
};
}
if (settings.forceMonoVoltage){
var v = (NRF.getBattery()+NRF.getBattery()+NRF.getBattery()+NRF.getBattery())/4;
var ov = NRF.getBattery;
NRF.getBattery = function() {
var current = (ov()+ov()+ov()+ov())/4;
if (Bangle.isCharging() && current > v) v = current;
if (!Bangle.isCharging() && current < v) v = current;
return v;
};
}
})();

View File

@ -1,4 +1,6 @@
{
"warnEnabled": false,
"warn": 96
"warn": 96,
"forceMonoVoltage": false,
"forceMonoPercentage": false
}

View File

@ -2,7 +2,7 @@
"id": "powermanager",
"name": "Power Manager",
"shortName": "Power Manager",
"version": "0.01",
"version": "0.02",
"description": "Allow configuration of warnings and thresholds for battery charging and display.",
"icon": "app.png",
"type": "bootloader",

View File

@ -24,6 +24,20 @@
'title': 'Power Manager'
},
'< Back': back,
'Monotonic percentage': {
value: !!settings.forceMonoPercentage,
format: v => settings.forceMonoPercentage ? "On" : "Off",
onchange: v => {
writeSettings("forceMonoPercentage", v);
}
},
'Monotonic voltage': {
value: !!settings.forceMonoVoltage,
format: v => settings.forceMonoVoltage ? "On" : "Off",
onchange: v => {
writeSettings("forceMonoVoltage", v);
}
},
'Charge warning': function() {
E.showMenu(submenu_chargewarn);
},