diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-11-30 14:16:13 +0000 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-12-23 11:39:58 +0000 |
commit | ad05c872fe1a0d925f478106bfb56e731f3ce53c (patch) | |
tree | 156bae0098029e193a9914b6c7049f31efa3805f /uisimulator/common/powermgmt-sim.c | |
parent | 923f92cb12ee39364ddec340de140d126ced1347 (diff) | |
download | rockbox-ad05c872fe1a0d925f478106bfb56e731f3ce53c.tar.gz rockbox-ad05c872fe1a0d925f478106bfb56e731f3ce53c.zip |
powermgmt: Add battery current measurement
This allows targets to report the actual discharging or
charging current if they are able to.
Change-Id: I0b538e6ac94346f1434e45f83c8da8c1260a53a3
Diffstat (limited to 'uisimulator/common/powermgmt-sim.c')
-rw-r--r-- | uisimulator/common/powermgmt-sim.c | 11 |
1 files changed, 11 insertions, 0 deletions
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; | |||
43 | static unsigned int batt_millivolts = BATT_MAXMVOLT; | 43 | static unsigned int batt_millivolts = BATT_MAXMVOLT; |
44 | static unsigned int batt_percent = 100; | 44 | static unsigned int batt_percent = 100; |
45 | static unsigned int batt_runtime = BATT_MAXRUNTIME; | 45 | static unsigned int batt_runtime = BATT_MAXRUNTIME; |
46 | static unsigned int batt_current = 0; | ||
46 | 47 | ||
47 | void powermgmt_init_target(void) {} | 48 | void powermgmt_init_target(void) {} |
48 | 49 | ||
@@ -97,6 +98,8 @@ static void battery_status_update(void) | |||
97 | 98 | ||
98 | batt_percent = (batt_millivolts - BATT_MINMVOLT) / (BATT_MAXMVOLT - BATT_MINMVOLT); | 99 | batt_percent = (batt_millivolts - BATT_MINMVOLT) / (BATT_MAXMVOLT - BATT_MINMVOLT); |
99 | batt_runtime = batt_percent * BATT_MAXRUNTIME; | 100 | batt_runtime = batt_percent * BATT_MAXRUNTIME; |
101 | /* current is completely bogus... */ | ||
102 | batt_current = charging ? BATT_CHARGE_STEP : BATT_DISCHARGE_STEP; | ||
100 | } | 103 | } |
101 | 104 | ||
102 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { 3200 }; | 105 | const unsigned short battery_level_dangerous[BATTERY_TYPES_COUNT] = { 3200 }; |
@@ -132,6 +135,14 @@ int _battery_time(void) | |||
132 | } | 135 | } |
133 | #endif | 136 | #endif |
134 | 137 | ||
138 | #if (CONFIG_BATTERY_MEASURE & CURRENT_MEASURE) | ||
139 | int _battery_current(void) | ||
140 | { | ||
141 | battery_status_update(); | ||
142 | return batt_current; | ||
143 | } | ||
144 | #endif | ||
145 | |||
135 | #if CONFIG_CHARGING | 146 | #if CONFIG_CHARGING |
136 | unsigned int power_input_status(void) | 147 | unsigned int power_input_status(void) |
137 | { | 148 | { |