widbattpwr: scale time based on (estimated) remaining battery mAh

master
Rob Pilling 2024-07-05 12:42:27 +01:00
parent 487652cc1a
commit f943effe39
2 changed files with 3 additions and 2 deletions

View File

@ -43,7 +43,7 @@
txt = "".concat(batt, "%");
}
else {
var hrs = 200000 / usage;
var hrs = 175000 * batt / (100 * usage);
var days = hrs / 24;
txt = days >= 1 ? "".concat(Math.round(Math.min(days, 99)), "d") : "".concat(Math.round(hrs), "h");
}

View File

@ -47,7 +47,8 @@
if(showPct){
txt = `${batt}%`;
}else{
const hrs = 200000 / usage;
// 175mAh, scaled based on battery (batt/100), scaled down based on usage
const hrs = 175000 * batt / (100 * usage);
const days = hrs / 24;
txt = days >= 1 ? `${Math.round(Math.min(days, 99))}d` : `${Math.round(hrs)}h`;
}