mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 17:55:30 +03:00
Prevent division by 0 error in battery usage OSD element
If the `bat_capacity` was set to 0 (the default) then it would result in a division by 0.
This commit is contained in:
parent
5b374c6fe0
commit
13f83ee4a4
1 changed files with 1 additions and 1 deletions
|
@ -1014,7 +1014,7 @@ static void osdElementMainBatteryUsage(osdElementParms_t *element)
|
||||||
const float value = constrain(batteryConfig()->batteryCapacity - getMAhDrawn(), 0, batteryConfig()->batteryCapacity);
|
const float value = constrain(batteryConfig()->batteryCapacity - getMAhDrawn(), 0, batteryConfig()->batteryCapacity);
|
||||||
|
|
||||||
// Calculate mAh used progress
|
// Calculate mAh used progress
|
||||||
const uint8_t mAhUsedProgress = ceilf((value / (batteryConfig()->batteryCapacity / MAIN_BATT_USAGE_STEPS)));
|
const uint8_t mAhUsedProgress = (batteryConfig()->batteryCapacity) ? ceilf((value / (batteryConfig()->batteryCapacity / MAIN_BATT_USAGE_STEPS))) : 0;
|
||||||
|
|
||||||
// Create empty battery indicator bar
|
// Create empty battery indicator bar
|
||||||
element->buff[0] = SYM_PB_START;
|
element->buff[0] = SYM_PB_START;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue