1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 08:15:30 +03:00

Merge pull request #9644 from etracer65/osd_battery_usage_div0

Prevent division by 0 error in battery usage OSD element
This commit is contained in:
Michael Keller 2020-03-28 14:00:32 +13:00 committed by GitHub
commit fee4f6f9f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1014,7 +1014,7 @@ static void osdElementMainBatteryUsage(osdElementParms_t *element)
const float value = constrain(batteryConfig()->batteryCapacity - getMAhDrawn(), 0, batteryConfig()->batteryCapacity);
// 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
element->buff[0] = SYM_PB_START;