add battery percent function

This commit is contained in:
Babz 2021-09-12 20:32:04 +02:00
parent 10b1d237d7
commit 9c20e635a2
2 changed files with 7 additions and 0 deletions

View File

@ -9,4 +9,10 @@ static void battery_wrapper(void) { battery_voltage = _battery(1); }
int get_battery_voltage(void) {
gint_world_switch(GINT_CALL(battery_wrapper));
return battery_voltage;
}
int get_battery_percent(void) {
int cv = get_battery_voltage();
float v = cv * 100.0;
return (int)(100.0 * v / 5.0);
}

View File

@ -2,5 +2,6 @@
#define UNS_BATTERY_H
int get_battery_voltage(void);
int get_battery_percent(void);
#endif // #ifndef UNS_BATTERY_H