mirror of https://github.com/espruino/BangleApps
powermanager - Allow forcing monotonic battery voltage/percentage
parent
8ed8d91518
commit
aa53046f59
|
@ -1 +1,2 @@
|
|||
0.01: New App!
|
||||
0.02: Allow forcing monotonic battery voltage/percentage
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"warnEnabled": false,
|
||||
"warn": 96
|
||||
"warn": 96,
|
||||
"forceMonoVoltage": false,
|
||||
"forceMonoPercentage": false
|
||||
}
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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);
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue