show absolute battery level

This commit is contained in:
Philippe G
2021-04-04 16:06:31 -07:00
parent f6b55c5ac9
commit 3a2bfe470f
5 changed files with 8 additions and 7 deletions

View File

@@ -51,8 +51,9 @@ float battery_value_svc(void) {
*
*/
uint8_t battery_level_svc(void) {
// TODO: this is totally incorrect
return battery.avg ? (battery.avg - (3.0 * battery.cells)) / ((4.2 - 3.0) * battery.cells) * 100 : 0;
// TODO: this is vastly incorrect
int level = battery.avg ? (battery.avg - (3.0 * battery.cells)) / ((4.2 - 3.0) * battery.cells) * 100 : 0;
return level < 100 ? level : 100;
}
/****************************************************************************************