mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 03:20:00 +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:
parent
b2ce402635
commit
2541e5913a
1 changed files with 4 additions and 3 deletions
|
@ -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) {
|
||||
const float speed = (float)osdGetSpeedToSelectedUnit(gpsSol.groundSpeed);
|
||||
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;
|
||||
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 {
|
||||
tfp_sprintf(element->buff, "----%c/%c", SYM_MAH, unitSymbol);
|
||||
tfp_sprintf(element->buff, "----%c/%c", SYM_NONE, unitSymbol);
|
||||
}
|
||||
}
|
||||
#endif // USE_GPS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue