1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 14:25:20 +03:00

Merge pull request #9878 from dkustec/cell_stat_value_instead_batt

This commit is contained in:
Michael Keller 2021-02-18 00:51:42 +13:00 committed by GitHub
commit 26b74c3350
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 9 deletions

View file

@ -1476,6 +1476,7 @@ const clivalue_t valueTable[] = {
{ "osd_rcchannels", VAR_INT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = OSD_RCCHANNELS_COUNT, PG_OSD_CONFIG, offsetof(osdConfig_t, rcChannels) },
{ "osd_camera_frame_width", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { OSD_CAMERA_FRAME_MIN_WIDTH, OSD_CAMERA_FRAME_MAX_WIDTH }, PG_OSD_CONFIG, offsetof(osdConfig_t, camera_frame_width) },
{ "osd_camera_frame_height", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { OSD_CAMERA_FRAME_MIN_HEIGHT, OSD_CAMERA_FRAME_MAX_HEIGHT }, PG_OSD_CONFIG, offsetof(osdConfig_t, camera_frame_height) },
{ "osd_stat_avg_cell_value", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, stat_show_cell_value) },
{ "osd_task_frequency", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { OSD_TASK_FREQUENCY_MIN, OSD_TASK_FREQUENCY_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, task_frequency) },
{ "osd_menu_background", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_CMS_BACKGROUND }, PG_OSD_CONFIG, offsetof(osdConfig_t, cms_background_type) },
#endif // end of #ifdef USE_OSD

View file

@ -340,6 +340,7 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
osdConfig->camera_frame_width = 24;
osdConfig->camera_frame_height = 11;
osdConfig->stat_show_cell_value = false;
osdConfig->task_frequency = OSD_TASK_FREQUENCY_DEFAULT;
osdConfig->cms_background_type = DISPLAY_BACKGROUND_TRANSPARENT;
}
@ -477,6 +478,11 @@ static int32_t getAverageEscRpm(void)
}
#endif
static uint16_t getStatsVoltage(void)
{
return osdConfig()->stat_show_cell_value ? getBatteryAverageCellVoltage() : getBatteryVoltage();
}
static void osdUpdateStats(void)
{
int16_t value = 0;
@ -492,7 +498,7 @@ static void osdUpdateStats(void)
}
#endif
value = getBatteryVoltage();
value = getStatsVoltage();
if (stats.min_voltage > value) {
stats.min_voltage = value;
}
@ -687,19 +693,23 @@ static bool osdDisplayStat(int statistic, uint8_t displayRow)
case OSD_STAT_MIN_BATTERY:
tfp_sprintf(buff, "%d.%02d%c", stats.min_voltage / 100, stats.min_voltage % 100, SYM_VOLT);
osdDisplayStatisticLabel(displayRow, "MIN BATTERY", buff);
osdDisplayStatisticLabel(displayRow, osdConfig()->stat_show_cell_value? "MIN AVG CELL" : "MIN BATTERY", buff);
return true;
case OSD_STAT_END_BATTERY:
tfp_sprintf(buff, "%d.%02d%c", stats.end_voltage / 100, stats.end_voltage % 100, SYM_VOLT);
osdDisplayStatisticLabel(displayRow, "END BATTERY", buff);
return true;
case OSD_STAT_BATTERY:
tfp_sprintf(buff, "%d.%02d%c", getBatteryVoltage() / 100, getBatteryVoltage() % 100, SYM_VOLT);
osdDisplayStatisticLabel(displayRow, "BATTERY", buff);
osdDisplayStatisticLabel(displayRow, osdConfig()->stat_show_cell_value ? "END AVG CELL" : "END BATTERY", buff);
return true;
case OSD_STAT_BATTERY:
{
const uint16_t statsVoltage = getStatsVoltage();
tfp_sprintf(buff, "%d.%02d%c", statsVoltage / 100, statsVoltage % 100, SYM_VOLT);
osdDisplayStatisticLabel(displayRow, osdConfig()->stat_show_cell_value ? "AVG BATT CELL" : "BATTERY", buff);
return true;
}
break;
case OSD_STAT_MIN_RSSI:
itoa(stats.min_rssi, buff, 10);
strcat(buff, "%");
@ -907,7 +917,7 @@ STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
|| !VISIBLE(osdElementConfig()->item_pos[OSD_WARNINGS]))) { // suppress stats if runaway takeoff triggered disarm and WARNINGS element is visible
osdStatsEnabled = true;
resumeRefreshAt = currentTimeUs + (60 * REFRESH_1S);
stats.end_voltage = getBatteryVoltage();
stats.end_voltage = getStatsVoltage();
osdStatsRowCount = 0; // reset to 0 so it will be recalculated on the next stats refresh
}

View file

@ -301,6 +301,7 @@ typedef struct osdConfig_s {
uint8_t camera_frame_height; // The height of the box for the camera frame element
uint16_t task_frequency;
uint8_t cms_background_type; // For supporting devices, determines whether the CMS background is transparent or opaque
uint8_t stat_show_cell_value;
} osdConfig_t;
PG_DECLARE(osdConfig_t, osdConfig);