diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 1de00bd055..8ccc07dd5e 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -64,6 +64,9 @@ #include "flight/altitude.h" #include "flight/imu.h" +#ifdef USE_ESC_SENSOR +#include "flight/mixer.h" +#endif #include "flight/pid.h" #include "io/asyncfatfs/asyncfatfs.h" @@ -668,6 +671,27 @@ static bool osdDrawSingleElement(uint8_t item) break; } +#ifdef USE_ESC_SENSOR + // Show warning if we lose motor output + if (enabledWarnings & OSD_WARNING_ESC_FAIL && ARMING_FLAG(ARMED)) { + char escErrMsg[OSD_FORMAT_MESSAGE_BUFFER_SIZE]; + // center justify message + int pos = 0; + while (pos < 4 - 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 : ' '; + } + escErrMsg[pos] = '\0'; + osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, escErrMsg); + break; + } +#endif + // Visual beeper if (enabledWarnings & OSD_WARNING_VISUAL_BEEPER && showVisualBeeper) { osdFormatMessage(buff, OSD_FORMAT_MESSAGE_BUFFER_SIZE, " * * * *"); diff --git a/src/main/io/osd.h b/src/main/io/osd.h index 8661602f9c..96ccb480c7 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -137,7 +137,8 @@ typedef enum { OSD_WARNING_BATTERY_WARNING = (1 << 2), OSD_WARNING_BATTERY_CRITICAL = (1 << 3), OSD_WARNING_VISUAL_BEEPER = (1 << 4), - OSD_WARNING_CRASH_FLIP = (1 << 5) + OSD_WARNING_CRASH_FLIP = (1 << 5), + OSD_WARNING_ESC_FAIL = (1 << 6) } osdWarningsFlags_e; typedef struct osdConfig_s {