From ad05c872fe1a0d925f478106bfb56e731f3ce53c Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Tue, 30 Nov 2021 14:16:13 +0000 Subject: powermgmt: Add battery current measurement This allows targets to report the actual discharging or charging current if they are able to. Change-Id: I0b538e6ac94346f1434e45f83c8da8c1260a53a3 --- uisimulator/common/powermgmt-sim.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'uisimulator/common/powermgmt-sim.c') diff --git a/uisimulator/common/powermgmt-sim.c b/uisimulator/common/powermgmt-sim.c index 5d669bcae2..1535971e29 100644 --- a/uisimulator/common/powermgmt-sim.c +++ b/uisimulator/common/powermgmt-sim.c @@ -43,6 +43,7 @@ static bool charging = false; static unsigned int batt_millivolts = BATT_MAXMVOLT; static unsigned int batt_percent = 100; static unsigned int batt_runtime = BATT_MAXRUNTIME; +static unsigned int batt_current = 0; void powermgmt_init_target(void) {} @@ -97,6 +98,8 @@ static void battery_status_update(void) batt_percent = (batt_millivolts - BATT_MINMVOLT) / (BATT_MAXMVOLT - BATT_MINMVOLT); batt_runtime = batt_percent * BATT_MAXRUNTIME; + /* current is completely bogus... */ + batt_current = charging ? BATT_CHARGE_STEP : BATT_DISCHARGE_STEP; } const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { 3200 }; @@ -132,6 +135,14 @@ int _battery_time(void) } #endif +#if (CONFIG_BATTERY_MEASURE & CURRENT_MEASURE) +int _battery_current(void) +{ + battery_status_update(); + return batt_current; +} +#endif + #if CONFIG_CHARGING unsigned int power_input_status(void) { -- cgit v1.2.3