We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d2b3a16 commit 79cf7e4Copy full SHA for 79cf7e4
zephyr/program/lotus/azalea/src/battery.c
@@ -52,10 +52,17 @@ enum battery_present battery_is_present(void)
52
53
uint32_t get_system_percentage(void)
54
{
55
+ static uint32_t pre_os_percentage;
56
uint32_t memmap_cap = *(uint32_t *)host_get_memmap(EC_MEMMAP_BATT_CAP);
57
uint32_t memmap_lfcc = *(uint32_t *)host_get_memmap(EC_MEMMAP_BATT_LFCC);
-
58
- return 1000 * memmap_cap / (memmap_lfcc + 1);
+ uint32_t os_percentage = 1000 * memmap_cap / (memmap_lfcc + 1);
59
+
60
+ /* ensure this value is valid */
61
+ if (os_percentage <= 1000 && os_percentage >= 0) {
62
+ pre_os_percentage = os_percentage;
63
+ return os_percentage;
64
+ } else
65
+ return pre_os_percentage;
66
}
67
68
static void battery_percentage_control(void)
0 commit comments