Skip to content

Commit b9e6d75

Browse files
committed
fix off by one in batt_percent loop
1 parent 5c7b341 commit b9e6d75

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/helpers/Battery.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
uint16_t batt_percent(uint8_t batt, uint16_t mv) {
55
uint16_t last = mv; // set last to mv so it can never start greater than itself
66
uint16_t p = 0;
7-
for (int i = 0; i < 102; i++) { // always 101 elements, 100 percent and 0
7+
// 101 elements including 0 percentile
8+
for (int i = 0; i < 101; i++) {
89
// if we match the current value or are between the current and last value
910
// we return the lower of the the two, giving accuracy +/- 1% soc
1011
if (mv <= last && mv >= batt_curve[i][batt]) {

0 commit comments

Comments
 (0)