1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Watt Hours Drawn OSD Element and Post Flight Stat

The Watt hours used element was added per a feature request to give
another way of interpreting the battery usage. It was also added as a
post flight stat to show consumption similar to the mAh post flight
stat. This once again is just giving pilots another option that some may
find useful.
This commit is contained in:
Jon Mahoney 2022-09-19 23:36:23 -04:00
parent 8d909fbe99
commit a2d356dc78
8 changed files with 58 additions and 2 deletions

View file

@ -1166,6 +1166,20 @@ static void osdElementMahDrawn(osdElementParms_t *element)
tfp_sprintf(element->buff, "%4d%c", getMAhDrawn(), SYM_MAH);
}
static void osdElementWattHoursDrawn(osdElementParms_t *element)
{
const float wattHoursDrawn = getWhDrawn();
if (wattHoursDrawn < 1.0f) {
tfp_sprintf(element->buff, "%3dMWH", lrintf(wattHoursDrawn * 1000));
} else {
int wattHourWholeNumber = (int)wattHoursDrawn;
int wattHourDecimalValue = (int)((wattHoursDrawn - wattHourWholeNumber) * 100);
tfp_sprintf(element->buff, wattHourDecimalValue >= 10 ? "%3d.%2dWH" : "%3d.0%1dWH", wattHourWholeNumber, wattHourDecimalValue);
}
}
static void osdElementMainBatteryUsage(osdElementParms_t *element)
{
// Set length of indicator bar
@ -1524,6 +1538,7 @@ static const uint8_t osdElementDisplayOrder[] = {
OSD_VTX_CHANNEL,
OSD_CURRENT_DRAW,
OSD_MAH_DRAWN,
OSD_WATT_HOURS_DRAWN,
OSD_CRAFT_NAME,
OSD_ALTITUDE,
OSD_ROLL_PIDS,
@ -1610,6 +1625,7 @@ const osdElementDrawFn osdElementDrawFunction[OSD_ITEM_COUNT] = {
#endif
[OSD_CURRENT_DRAW] = osdElementCurrentDraw,
[OSD_MAH_DRAWN] = osdElementMahDrawn,
[OSD_WATT_HOURS_DRAWN] = osdElementWattHoursDrawn,
#ifdef USE_GPS
[OSD_GPS_SPEED] = osdElementGpsSpeed,
[OSD_GPS_SATS] = osdElementGpsSats,