From 07f299962d66927896a1b567034273a83a2b1ce3 Mon Sep 17 00:00:00 2001 From: mikeller Date: Thu, 17 Jan 2019 01:44:16 +1300 Subject: [PATCH] Fixed conditionals in OSD code. --- src/main/io/osd.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/main/io/osd.c b/src/main/io/osd.c index b53badb4f9..7206e622ff 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -158,6 +158,7 @@ typedef struct radioControls_s { uint8_t right_horizontal; } radioControls_t; +#ifdef USE_CMS typedef enum radioModes_e { MODE1, MODE2, @@ -165,7 +166,6 @@ typedef enum radioModes_e { MODE4 } radioModes_t; -static statistic_t stats; #ifdef USE_OSD_STICK_OVERLAY static const radioControls_t radioModes[4] = { { PITCH, YAW, THROTTLE, ROLL }, // Mode 1 @@ -174,6 +174,9 @@ static const radioControls_t radioModes[4] = { { THROTTLE, ROLL, PITCH, YAW }, // Mode 4 }; #endif +#endif + +static statistic_t stats; timeUs_t resumeRefreshAt = 0; #define REFRESH_1S 1000 * 1000 @@ -194,6 +197,7 @@ static escSensorData_t *escDataCombined; #define AH_SIDEBAR_WIDTH_POS 7 #define AH_SIDEBAR_HEIGHT_POS 3 +#ifdef USE_CMS static const char compassBar[] = { SYM_HEADING_W, SYM_HEADING_LINE, SYM_HEADING_DIVIDED_LINE, SYM_HEADING_LINE, @@ -255,6 +259,7 @@ static const uint8_t osdElementDisplayOrder[] = { OSD_LINK_QUALITY, #endif }; +#endif // USE_CMS PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 4); @@ -271,6 +276,7 @@ static char osdGetMetersToSelectedUnitSymbol(void) } } +#ifdef USE_CMS static char osdGetBatterySymbol(int cellVoltage) { if (getBatteryState() == BATTERY_CRITICAL) { @@ -281,6 +287,7 @@ static char osdGetBatterySymbol(int cellVoltage) return SYM_BATT_EMPTY - constrain(symOffset, 0, 6); } } +#endif /** * Converts altitude based on the current unit system. @@ -327,6 +334,7 @@ static void osdFormatAltitudeString(char * buff, int32_t altitudeCm) buff[4] = '.'; } +#ifdef USE_CMS static void osdFormatPID(char * buff, const char * label, const pidf_t * pid) { tfp_sprintf(buff, "%s %3d %3d %3d", label, pid->P, pid->I, pid->D); @@ -358,6 +366,7 @@ static uint8_t osdGetDirectionSymbolFromHeading(int heading) return SYM_ARROW_SOUTH + heading; } +#endif static char osdGetTimerSymbol(osd_timer_source_e src) { @@ -418,6 +427,7 @@ STATIC_UNIT_TESTED void osdFormatTimer(char *buff, bool showSymbol, bool usePrec osdFormatTime(buff, (usePrecision ? OSD_TIMER_PRECISION(timer) : OSD_TIMER_PREC_SECOND), osdGetTimerValue(src)); } +#ifdef USE_CMS #ifdef USE_GPS static void osdFormatCoordinate(char *buff, char sym, int32_t val) { @@ -440,6 +450,17 @@ static void osdFormatCoordinate(char *buff, char sym, int32_t val) } #endif // USE_GPS +static void osdFormatMessage(char *buff, size_t size, const char *message) +{ + memset(buff, SYM_BLANK, size); + if (message) { + memcpy(buff, message, strlen(message)); + } + // Ensure buff is zero terminated + buff[size - 1] = '\0'; +} +#endif // USE_CMS + #ifdef USE_RTC_TIME static bool osdFormatRtcDateTime(char *buffer) { @@ -456,16 +477,6 @@ static bool osdFormatRtcDateTime(char *buffer) } #endif -static void osdFormatMessage(char *buff, size_t size, const char *message) -{ - memset(buff, SYM_BLANK, size); - if (message) { - memcpy(buff, message, strlen(message)); - } - // Ensure buff is zero terminated - buff[size - 1] = '\0'; -} - void osdStatSetState(uint8_t statIndex, bool enabled) { if (enabled) { @@ -523,6 +534,7 @@ void changeOsdProfileIndex(uint8_t profileIndex) } #endif +#ifdef USE_CMS static bool osdDrawSingleElement(uint8_t item) { if (!VISIBLE(osdConfig()->item_pos[item]) || BLINK(item)) { @@ -1395,6 +1407,7 @@ static void osdDrawElements(void) } #endif } +#endif // USE_CMS void pgResetFn_osdConfig(osdConfig_t *osdConfig) {