File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,11 @@ int batteryPercentFromMilliVolts(uint16_t batteryMilliVolts) {
1515 const uint8_t stepPct = 10 ; // distance between table entries (100 → 90 → ... → 0)
1616 const size_t n = kOcvTableSize ; // should be 11
1717
18+ if (NUM_CELLS_IN_SERIES > 1 ) {
19+ // Adjust the input voltage to per-cell basis
20+ batteryMilliVolts /= NUM_CELLS_IN_SERIES;
21+ }
22+
1823 if (n != 11 || batteryMilliVolts <= 0 ) {
1924 // Error: invalid OCV_ARRAY table size or voltage
2025 return -1 ;
Original file line number Diff line number Diff line change 3131 #endif
3232#endif
3333
34+ /**
35+ * Number of cells in series (for multi-cell battery packs)
36+ * Default to 1 if not defined.
37+ */
38+ #ifndef NUM_CELLS_IN_SERIES
39+ #define NUM_CELLS_IN_SERIES 1
40+ #endif
41+
3442
3543/**
3644 * Convert a battery voltage (in millivolts) to approximate state-of-charge (%),
You can’t perform that action at this time.
0 commit comments