1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-21 15:25:36 +03:00

Merge pull request #6656 from timman2er/add_stat_esc_max_temp_rpm

added esc max temp and rpm to OSD
This commit is contained in:
Michael Keller 2018-10-08 01:03:20 +13:00 committed by GitHub
commit 2f1643924e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 0 deletions

View file

@ -1057,6 +1057,8 @@ const clivalue_t valueTable[] = {
{ "osd_stat_bbox", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_BLACKBOX, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
{ "osd_stat_bb_no", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_BLACKBOX_NUMBER, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
{ "osd_stat_max_g_force", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_MAX_G_FORCE, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
{ "osd_stat_max_esc_temp", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_MAX_ESC_TEMP, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
{ "osd_stat_max_esc_rpm", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_MAX_ESC_RPM, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
#endif

View file

@ -139,6 +139,8 @@ typedef struct statistic_s {
int32_t max_altitude;
int16_t max_distance;
float max_g_force;
int16_t max_esc_temp;
int32_t max_esc_rpm;
} statistic_t;
static statistic_t stats;
@ -1301,6 +1303,8 @@ static void osdResetStats(void)
stats.max_distance = 0;
stats.armed_time = 0;
stats.max_g_force = 0;
stats.max_esc_temp = 0;
stats.max_esc_rpm = 0;
}
static void osdUpdateStats(void)
@ -1353,6 +1357,18 @@ static void osdUpdateStats(void)
}
}
#endif
#ifdef USE_ESC_SENSOR
if (featureIsEnabled(FEATURE_ESC_SENSOR)) {
value = (escDataCombined->temperature * 10) / 10;
if (stats.max_esc_temp < value) {
stats.max_esc_temp = value;
}
value = calcEscRpm(escDataCombined->rpm);
if (stats.max_esc_rpm < value) {
stats.max_esc_rpm = value;
}
}
#endif
}
#ifdef USE_BLACKBOX
@ -1515,6 +1531,16 @@ static void osdShowStats(uint16_t endBatteryVoltage)
osdDisplayStatisticLabel(top++, "MAX G-FORCE", buff);
}
if (osdStatGetState(OSD_STAT_MAX_ESC_TEMP)) {
tfp_sprintf(buff, "%3d%c", osdConvertTemperatureToSelectedUnit(stats.max_esc_temp * 10) / 10, osdGetTemperatureSymbolForSelectedUnit());
osdDisplayStatisticLabel(top++, "MAX ESC TEMP", buff);
}
if (osdStatGetState(OSD_STAT_MAX_ESC_RPM)) {
itoa(stats.max_esc_rpm, buff, 10);
osdDisplayStatisticLabel(top++, "MAX ESC RPM", buff);
}
}
static void osdShowArmed(void)

View file

@ -126,6 +126,8 @@ typedef enum {
OSD_STAT_BLACKBOX,
OSD_STAT_BLACKBOX_NUMBER,
OSD_STAT_MAX_G_FORCE,
OSD_STAT_MAX_ESC_TEMP,
OSD_STAT_MAX_ESC_RPM,
OSD_STAT_COUNT // MUST BE LAST
} osd_stats_e;

View file

@ -305,6 +305,8 @@ TEST(OsdTest, TestStatsImperial)
osdStatSetState(OSD_STAT_MAX_DISTANCE, true);
osdStatSetState(OSD_STAT_BLACKBOX_NUMBER, false);
osdStatSetState(OSD_STAT_MAX_G_FORCE, false);
osdStatSetState(OSD_STAT_MAX_ESC_TEMP, false);
osdStatSetState(OSD_STAT_MAX_ESC_RPM, false);
// and
// using imperial unit system