From e41c11d0a1620cb794908ceb81c5de2fad968d38 Mon Sep 17 00:00:00 2001 From: MickiusMousius Date: Mon, 18 Dec 2023 10:30:50 +1030 Subject: [PATCH] fix bad indexing of lookup table --- app/module/drivers/sensor/battery/battery_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/module/drivers/sensor/battery/battery_common.c b/app/module/drivers/sensor/battery/battery_common.c index 0733116a..f0adaf60 100644 --- a/app/module/drivers/sensor/battery/battery_common.c +++ b/app/module/drivers/sensor/battery/battery_common.c @@ -50,7 +50,7 @@ uint8_t lithium_ion_mv_to_pct(int16_t batt_mv) { return battery_lookup[0].percent; } - for (int i = 0; i < ARRAY_SIZE(battery_lookup); i++) { + for (int i = 1; i < ARRAY_SIZE(battery_lookup); i++) { struct lookup_point one = battery_lookup[i - 1]; struct lookup_point two = battery_lookup[i]; if (batt_mv >= two.millivolts) {