Added ESC temperature warning, fixed ESC warning issue with motor count > 8. (#5583)

This commit is contained in:
Michael Keller 2018-04-04 01:04:18 +12:00 committed by GitHub
parent 494e42610e
commit 07cce64572
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 16 deletions

View File

@ -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_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_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_rol", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 90 }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahMaxRoll) },

View File

@ -141,7 +141,7 @@ static bool lastArmState;
static displayPort_t *osdDisplayPort;
#ifdef USE_ESC_SENSOR
static escSensorData_t *escData;
static escSensorData_t *escDataCombined;
#endif
#define AH_SYMBOL_COUNT 9
@ -672,21 +672,34 @@ static bool osdDrawSingleElement(uint8_t item)
}
#ifdef USE_ESC_SENSOR
// Show warning if we lose motor output
if (enabledWarnings & OSD_WARNING_ESC_FAIL && ARMING_FLAG(ARMED)) {
// Show warning if we lose motor output or the ESC is overheating
if (feature(FEATURE_ESC_SENSOR) && enabledWarnings & OSD_WARNING_ESC_FAIL) {
char escErrMsg[OSD_FORMAT_MESSAGE_BUFFER_SIZE];
unsigned pos = 0;
const char *title = "ESC";
// center justify message
int pos = 0;
while (pos < 4 - getMotorCount()/2) {
while (pos < (OSD_WARNINGS_MAX_SIZE - (strlen(title) + getMotorCount())) / 2) {
escErrMsg[pos++] = ' ';
}
strcpy(escErrMsg + pos, "ESC");
pos += strlen("ESC");
for (int i = 0; i < getMotorCount(); i++) {
escSensorData_t *escDatai = getEscSensorData(i);
escErrMsg[pos++] = escDatai->rpm == 0 ? '0' + i + 1 : ' ';
strcpy(escErrMsg + pos, title);
pos += strlen(title);
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';
osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, escErrMsg);
break;
}
@ -773,11 +786,15 @@ static bool osdDrawSingleElement(uint8_t item)
#ifdef USE_ESC_SENSOR
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;
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;
#endif
@ -923,6 +940,8 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
osdConfig->rssi_alarm = 20;
osdConfig->cap_alarm = 2200;
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->ahMaxRoll = 40; // 40 degrees
@ -1036,6 +1055,17 @@ void osdUpdateAlarms(void)
} else {
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)
@ -1051,6 +1081,7 @@ void osdResetAlarms(void)
CLR_BLINK(OSD_ITEM_TIMER_1);
CLR_BLINK(OSD_ITEM_TIMER_2);
CLR_BLINK(OSD_REMAINING_TIME_ESTIMATE);
CLR_BLINK(OSD_ESC_TMP);
}
static void osdResetStats(void)
@ -1343,7 +1374,7 @@ STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
#ifdef USE_ESC_SENSOR
if (feature(FEATURE_ESC_SENSOR)) {
escData = getEscSensorData(ESC_SENSOR_COMBINED);
escDataCombined = getEscSensorData(ESC_SENSOR_COMBINED);
}
#endif

View File

@ -141,6 +141,9 @@ typedef enum {
OSD_WARNING_ESC_FAIL = (1 << 6)
} osdWarningsFlags_e;
#define ESC_RPM_ALARM_OFF -1
#define ESC_TEMP_ALARM_OFF INT8_MIN
typedef struct osdConfig_s {
uint16_t item_pos[OSD_ITEM_COUNT];
@ -157,13 +160,13 @@ typedef struct osdConfig_s {
uint8_t ahMaxPitch;
uint8_t ahMaxRoll;
bool enabled_stats[OSD_STAT_COUNT];
int8_t esc_temp_alarm;
int16_t esc_rpm_alarm;
} osdConfig_t;
extern timeUs_t resumeRefreshAt;
PG_DECLARE(osdConfig_t, osdConfig);
extern uint32_t resumeRefreshAt;
extern timeUs_t resumeRefreshAt;
struct displayPort_s;
void osdInit(struct displayPort_s *osdDisplayPort);