1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-26 09:45:37 +03:00

Validate that the battery min cell voltage is less than the max cell voltage

Resets to defaults if not.

If the min/max were set to the same value then this will lead to div-by-zero errors.

If the min was set to a greater value then this would lead to negative values and underflow in the battery remaining calculations. This would affect the OSD, dashboard, various telemetries, LED strip, and the Configurator.
This commit is contained in:
Bruce Luckcuck 2021-01-11 11:34:46 -05:00
parent 38c792c1c5
commit fbf1ef7bbc
3 changed files with 11 additions and 2 deletions

View file

@ -96,8 +96,8 @@ PG_REGISTER_WITH_RESET_TEMPLATE(batteryConfig_t, batteryConfig, PG_BATTERY_CONFI
PG_RESET_TEMPLATE(batteryConfig_t, batteryConfig,
// voltage
.vbatmaxcellvoltage = 430,
.vbatmincellvoltage = 330,
.vbatmaxcellvoltage = VBAT_CELL_VOLTAGE_DEFAULT_MAX,
.vbatmincellvoltage = VBAT_CELL_VOLTAGE_DEFAULT_MIN,
.vbatwarningcellvoltage = 350,
.vbatnotpresentcellvoltage = 300, //A cell below 3 will be ignored
.voltageMeterSource = DEFAULT_VOLTAGE_METER_SOURCE,

View file

@ -32,6 +32,8 @@
#define VBAT_CELL_VOTAGE_RANGE_MIN 100
#define VBAT_CELL_VOTAGE_RANGE_MAX 500
#define VBAT_CELL_VOLTAGE_DEFAULT_MIN 330
#define VBAT_CELL_VOLTAGE_DEFAULT_MAX 430
#define MAX_AUTO_DETECT_CELL_COUNT 8