1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-13 11:29:58 +03:00

Update osd_elements.c to report efficiency in Watt-hours / distance

Changes the OSD efficiency element to reports Watt-hours per unit distance. This will provide the pilot with a better representation of actual efficiency when comparing packs of various voltages and should remain more consistent with changing voltage as the pack depletes.
This commit is contained in:
BrandonsBakedBeans 2023-12-07 16:11:38 -08:00 committed by GitHub
parent b2ce402635
commit 2541e5913a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1134,14 +1134,15 @@ static void osdElementEfficiency(osdElementParms_t *element)
if (sensors(SENSOR_GPS) && ARMING_FLAG(ARMED) && STATE(GPS_FIX) && gpsSol.groundSpeed >= EFFICIENCY_MINIMUM_SPEED_CM_S) { if (sensors(SENSOR_GPS) && ARMING_FLAG(ARMED) && STATE(GPS_FIX) && gpsSol.groundSpeed >= EFFICIENCY_MINIMUM_SPEED_CM_S) {
const float speed = (float)osdGetSpeedToSelectedUnit(gpsSol.groundSpeed); const float speed = (float)osdGetSpeedToSelectedUnit(gpsSol.groundSpeed);
const float mAmperage = (float)getAmperage() * 10.f; // Current in mA const float mAmperage = (float)getAmperage() * 10.f; // Current in mA
efficiency = lrintf(pt1FilterApply(&batteryEfficiencyFilt, (mAmperage / speed))); const float batteryVoltage = getBatteryVoltage() / 100.0f;
efficiency = lrintf(pt1FilterApply(&batteryEfficiencyFilt, (mAmperage / speed) * batteryVoltage / 1000.0f)); // returns Watt-hours per distance
} }
const char unitSymbol = osdConfig()->units == UNIT_IMPERIAL ? SYM_MILES : SYM_KM; const char unitSymbol = osdConfig()->units == UNIT_IMPERIAL ? SYM_MILES : SYM_KM;
if (efficiency > 0 && efficiency <= 9999) { if (efficiency > 0 && efficiency <= 9999) {
tfp_sprintf(element->buff, "%4d%c/%c", efficiency, SYM_MAH, unitSymbol); tfp_sprintf(element->buff, "%4d%c/%c", efficiency, SYM_NONE, unitSymbol); // no Wh element, use NONE for now
} else { } else {
tfp_sprintf(element->buff, "----%c/%c", SYM_MAH, unitSymbol); tfp_sprintf(element->buff, "----%c/%c", SYM_NONE, unitSymbol);
} }
} }
#endif // USE_GPS #endif // USE_GPS