mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 15:25:36 +03:00
Added ESC temperature warning, fixed ESC warning issue with motor count > 8. (#5583)
This commit is contained in:
parent
494e42610e
commit
07cce64572
3 changed files with 52 additions and 16 deletions
|
@ -799,6 +799,8 @@ const clivalue_t valueTable[] = {
|
||||||
{ "osd_rssi_alarm", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 100 }, PG_OSD_CONFIG, offsetof(osdConfig_t, rssi_alarm) },
|
{ "osd_rssi_alarm", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 100 }, PG_OSD_CONFIG, offsetof(osdConfig_t, rssi_alarm) },
|
||||||
{ "osd_cap_alarm", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, 20000 }, PG_OSD_CONFIG, offsetof(osdConfig_t, cap_alarm) },
|
{ "osd_cap_alarm", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, 20000 }, PG_OSD_CONFIG, offsetof(osdConfig_t, cap_alarm) },
|
||||||
{ "osd_alt_alarm", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, 10000 }, PG_OSD_CONFIG, offsetof(osdConfig_t, alt_alarm) },
|
{ "osd_alt_alarm", VAR_UINT16 | MASTER_VALUE, .config.minmax = { 0, 10000 }, PG_OSD_CONFIG, offsetof(osdConfig_t, alt_alarm) },
|
||||||
|
{ "osd_esc_temp_alarm", VAR_INT8 | MASTER_VALUE, .config.minmax = { INT8_MIN, INT8_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, esc_temp_alarm) },
|
||||||
|
{ "osd_esc_rpm_alarm", VAR_INT16 | MASTER_VALUE, .config.minmax = { ESC_RPM_ALARM_OFF, INT16_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, esc_rpm_alarm) },
|
||||||
|
|
||||||
{ "osd_ah_max_pit", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 90 }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahMaxPitch) },
|
{ "osd_ah_max_pit", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 90 }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahMaxPitch) },
|
||||||
{ "osd_ah_max_rol", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 90 }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahMaxRoll) },
|
{ "osd_ah_max_rol", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 90 }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahMaxRoll) },
|
||||||
|
|
|
@ -141,7 +141,7 @@ static bool lastArmState;
|
||||||
static displayPort_t *osdDisplayPort;
|
static displayPort_t *osdDisplayPort;
|
||||||
|
|
||||||
#ifdef USE_ESC_SENSOR
|
#ifdef USE_ESC_SENSOR
|
||||||
static escSensorData_t *escData;
|
static escSensorData_t *escDataCombined;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AH_SYMBOL_COUNT 9
|
#define AH_SYMBOL_COUNT 9
|
||||||
|
@ -672,21 +672,34 @@ static bool osdDrawSingleElement(uint8_t item)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_ESC_SENSOR
|
#ifdef USE_ESC_SENSOR
|
||||||
// Show warning if we lose motor output
|
// Show warning if we lose motor output or the ESC is overheating
|
||||||
if (enabledWarnings & OSD_WARNING_ESC_FAIL && ARMING_FLAG(ARMED)) {
|
if (feature(FEATURE_ESC_SENSOR) && enabledWarnings & OSD_WARNING_ESC_FAIL) {
|
||||||
char escErrMsg[OSD_FORMAT_MESSAGE_BUFFER_SIZE];
|
char escErrMsg[OSD_FORMAT_MESSAGE_BUFFER_SIZE];
|
||||||
|
unsigned pos = 0;
|
||||||
|
|
||||||
|
const char *title = "ESC";
|
||||||
|
|
||||||
// center justify message
|
// center justify message
|
||||||
int pos = 0;
|
while (pos < (OSD_WARNINGS_MAX_SIZE - (strlen(title) + getMotorCount())) / 2) {
|
||||||
while (pos < 4 - getMotorCount()/2) {
|
|
||||||
escErrMsg[pos++] = ' ';
|
escErrMsg[pos++] = ' ';
|
||||||
}
|
}
|
||||||
strcpy(escErrMsg + pos, "ESC");
|
|
||||||
pos += strlen("ESC");
|
strcpy(escErrMsg + pos, title);
|
||||||
for (int i = 0; i < getMotorCount(); i++) {
|
pos += strlen(title);
|
||||||
escSensorData_t *escDatai = getEscSensorData(i);
|
|
||||||
escErrMsg[pos++] = escDatai->rpm == 0 ? '0' + i + 1 : ' ';
|
unsigned i = 0;
|
||||||
|
while (i < getMotorCount() && pos < OSD_FORMAT_MESSAGE_BUFFER_SIZE - 1) {
|
||||||
|
escSensorData_t *escData = getEscSensorData(i);
|
||||||
|
const bool escWarning = (ARMING_FLAG(ARMED) && osdConfig()->esc_rpm_alarm != ESC_RPM_ALARM_OFF && escData->rpm <= osdConfig()->esc_rpm_alarm) ||
|
||||||
|
(osdConfig()->esc_temp_alarm != ESC_TEMP_ALARM_OFF && escData->temperature >= osdConfig()->esc_temp_alarm);
|
||||||
|
|
||||||
|
escErrMsg[pos++] = escWarning ? '1' + i : ' ';
|
||||||
|
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
escErrMsg[pos] = '\0';
|
escErrMsg[pos] = '\0';
|
||||||
|
|
||||||
osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, escErrMsg);
|
osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, escErrMsg);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -773,11 +786,15 @@ static bool osdDrawSingleElement(uint8_t item)
|
||||||
|
|
||||||
#ifdef USE_ESC_SENSOR
|
#ifdef USE_ESC_SENSOR
|
||||||
case OSD_ESC_TMP:
|
case OSD_ESC_TMP:
|
||||||
tfp_sprintf(buff, "%3d%c", osdConvertTemperatureToSelectedUnit(escData->temperature * 10) / 10, osdGetTemperatureSymbolForSelectedUnit());
|
if (feature(FEATURE_ESC_SENSOR)) {
|
||||||
|
tfp_sprintf(buff, "%3d%c", osdConvertTemperatureToSelectedUnit(escDataCombined->temperature * 10) / 10, osdGetTemperatureSymbolForSelectedUnit());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OSD_ESC_RPM:
|
case OSD_ESC_RPM:
|
||||||
tfp_sprintf(buff, "%5d", escData == NULL ? 0 : escData->rpm);
|
if (feature(FEATURE_ESC_SENSOR)) {
|
||||||
|
tfp_sprintf(buff, "%5d", escDataCombined == NULL ? 0 : escDataCombined->rpm);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -923,6 +940,8 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
||||||
osdConfig->rssi_alarm = 20;
|
osdConfig->rssi_alarm = 20;
|
||||||
osdConfig->cap_alarm = 2200;
|
osdConfig->cap_alarm = 2200;
|
||||||
osdConfig->alt_alarm = 100; // meters or feet depend on configuration
|
osdConfig->alt_alarm = 100; // meters or feet depend on configuration
|
||||||
|
osdConfig->esc_temp_alarm = ESC_TEMP_ALARM_OFF; // off by default
|
||||||
|
osdConfig->esc_rpm_alarm = ESC_RPM_ALARM_OFF; // off by default
|
||||||
|
|
||||||
osdConfig->ahMaxPitch = 20; // 20 degrees
|
osdConfig->ahMaxPitch = 20; // 20 degrees
|
||||||
osdConfig->ahMaxRoll = 40; // 40 degrees
|
osdConfig->ahMaxRoll = 40; // 40 degrees
|
||||||
|
@ -1036,6 +1055,17 @@ void osdUpdateAlarms(void)
|
||||||
} else {
|
} else {
|
||||||
CLR_BLINK(OSD_ALTITUDE);
|
CLR_BLINK(OSD_ALTITUDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_ESC_SENSOR
|
||||||
|
if (feature(FEATURE_ESC_SENSOR)) {
|
||||||
|
// This works because the combined ESC data contains the maximum temperature seen amongst all ESCs
|
||||||
|
if (osdConfig()->esc_temp_alarm != ESC_TEMP_ALARM_OFF && escDataCombined->temperature >= osdConfig()->esc_temp_alarm) {
|
||||||
|
SET_BLINK(OSD_ESC_TMP);
|
||||||
|
} else {
|
||||||
|
CLR_BLINK(OSD_ESC_TMP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void osdResetAlarms(void)
|
void osdResetAlarms(void)
|
||||||
|
@ -1051,6 +1081,7 @@ void osdResetAlarms(void)
|
||||||
CLR_BLINK(OSD_ITEM_TIMER_1);
|
CLR_BLINK(OSD_ITEM_TIMER_1);
|
||||||
CLR_BLINK(OSD_ITEM_TIMER_2);
|
CLR_BLINK(OSD_ITEM_TIMER_2);
|
||||||
CLR_BLINK(OSD_REMAINING_TIME_ESTIMATE);
|
CLR_BLINK(OSD_REMAINING_TIME_ESTIMATE);
|
||||||
|
CLR_BLINK(OSD_ESC_TMP);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void osdResetStats(void)
|
static void osdResetStats(void)
|
||||||
|
@ -1343,7 +1374,7 @@ STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
|
||||||
|
|
||||||
#ifdef USE_ESC_SENSOR
|
#ifdef USE_ESC_SENSOR
|
||||||
if (feature(FEATURE_ESC_SENSOR)) {
|
if (feature(FEATURE_ESC_SENSOR)) {
|
||||||
escData = getEscSensorData(ESC_SENSOR_COMBINED);
|
escDataCombined = getEscSensorData(ESC_SENSOR_COMBINED);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -141,6 +141,9 @@ typedef enum {
|
||||||
OSD_WARNING_ESC_FAIL = (1 << 6)
|
OSD_WARNING_ESC_FAIL = (1 << 6)
|
||||||
} osdWarningsFlags_e;
|
} osdWarningsFlags_e;
|
||||||
|
|
||||||
|
#define ESC_RPM_ALARM_OFF -1
|
||||||
|
#define ESC_TEMP_ALARM_OFF INT8_MIN
|
||||||
|
|
||||||
typedef struct osdConfig_s {
|
typedef struct osdConfig_s {
|
||||||
uint16_t item_pos[OSD_ITEM_COUNT];
|
uint16_t item_pos[OSD_ITEM_COUNT];
|
||||||
|
|
||||||
|
@ -157,13 +160,13 @@ typedef struct osdConfig_s {
|
||||||
uint8_t ahMaxPitch;
|
uint8_t ahMaxPitch;
|
||||||
uint8_t ahMaxRoll;
|
uint8_t ahMaxRoll;
|
||||||
bool enabled_stats[OSD_STAT_COUNT];
|
bool enabled_stats[OSD_STAT_COUNT];
|
||||||
|
int8_t esc_temp_alarm;
|
||||||
|
int16_t esc_rpm_alarm;
|
||||||
} osdConfig_t;
|
} osdConfig_t;
|
||||||
|
|
||||||
extern timeUs_t resumeRefreshAt;
|
|
||||||
|
|
||||||
PG_DECLARE(osdConfig_t, osdConfig);
|
PG_DECLARE(osdConfig_t, osdConfig);
|
||||||
|
|
||||||
extern uint32_t resumeRefreshAt;
|
extern timeUs_t resumeRefreshAt;
|
||||||
|
|
||||||
struct displayPort_s;
|
struct displayPort_s;
|
||||||
void osdInit(struct displayPort_s *osdDisplayPort);
|
void osdInit(struct displayPort_s *osdDisplayPort);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue