From ffa9a0ee48d01a62b47a925dd6b7ead3ba2ca8d8 Mon Sep 17 00:00:00 2001 From: Ivan Efimov Date: Thu, 29 Dec 2022 11:02:30 -0600 Subject: [PATCH] Funny OSD --- src/main/cli/settings.c | 5 +++++ src/main/config/config.c | 18 ++++++++++++++++++ src/main/config/config.h | 5 +++++ src/main/osd/osd.c | 2 +- src/main/osd/osd_elements.c | 12 ++++++++++-- src/main/osd/osd_elements.h | 1 + src/main/osd/osd_warnings.c | 8 ++++---- src/test/unit/link_quality_unittest.cc | 2 +- src/test/unit/osd_unittest.cc | 2 +- 9 files changed, 46 insertions(+), 9 deletions(-) diff --git a/src/main/cli/settings.c b/src/main/cli/settings.c index 7c81b4cf41..88c8724958 100644 --- a/src/main/cli/settings.c +++ b/src/main/cli/settings.c @@ -1763,6 +1763,11 @@ const clivalue_t valueTable[] = { { "craft_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, craftName) }, #ifdef USE_OSD { "pilot_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, pilotName) }, + { "extra_100_throttle", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, extra100Throttle) }, + { "extra_fc_hot_warning", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, extraFcHotWarning) }, + { "extra_turtle_mode_warning", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, extraTurtleModeWarning) }, + { "extra_low_battery_warning", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, extraLowBatteryWarning) }, + { "extra_armed_warning", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, extraArmedWarning) }, #endif // PG_POSITION diff --git a/src/main/config/config.c b/src/main/config/config.c index c65faed48d..5dbccad29e 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "platform.h" @@ -94,6 +95,8 @@ #include "drivers/dshot.h" +#include "osd/osd_elements.h" + static bool configIsDirty; /* someone indicated that the config is modified and it is not yet saved */ static bool rebootRequired = false; // set if a config change requires a reboot to take effect @@ -111,6 +114,11 @@ PG_REGISTER_WITH_RESET_TEMPLATE(pilotConfig_t, pilotConfig, PG_PILOT_CONFIG, 2); PG_RESET_TEMPLATE(pilotConfig_t, pilotConfig, .craftName = { 0 }, .pilotName = { 0 }, + .extra100Throttle = "KAACK", + .extraFcHotWarning = "B*TCH IS HOT", + .extraTurtleModeWarning = "SORRY BRYAN", + .extraLowBatteryWarning = "AINT LEAVING", + .extraArmedWarning = "LETS GO", ); PG_REGISTER_WITH_RESET_TEMPLATE(systemConfig_t, systemConfig, PG_SYSTEM_CONFIG, 3); @@ -210,6 +218,15 @@ static void validateAndFixRatesSettings(void) } } +void makeStringsUpperCase(void) +{ + toUpperCase(pilotConfigMutable()->extra100Throttle, pilotConfig()->extra100Throttle, MAX_NAME_LENGTH); + toUpperCase(pilotConfigMutable()->extraFcHotWarning, pilotConfig()->extraFcHotWarning, MAX_NAME_LENGTH); + toUpperCase(pilotConfigMutable()->extraTurtleModeWarning, pilotConfig()->extraTurtleModeWarning, MAX_NAME_LENGTH); + toUpperCase(pilotConfigMutable()->extraLowBatteryWarning, pilotConfig()->extraLowBatteryWarning, MAX_NAME_LENGTH); + toUpperCase(pilotConfigMutable()->extraArmedWarning, pilotConfig()->extraArmedWarning, MAX_NAME_LENGTH); +} + static void validateAndFixConfig(void) { #if !defined(USE_QUAD_MIXER_ONLY) @@ -602,6 +619,7 @@ if (systemConfig()->configurationState == CONFIGURATION_STATE_UNCONFIGURED) { #endif validateAndfixMotorOutputReordering(motorConfigMutable()->dev.motorOutputReordering, MAX_SUPPORTED_MOTORS); + makeStringsUpperCase(); // validate that the minimum battery cell voltage is less than the maximum cell voltage // reset to defaults if not diff --git a/src/main/config/config.h b/src/main/config/config.h index 1ccd3c2faf..61c3fd170e 100644 --- a/src/main/config/config.h +++ b/src/main/config/config.h @@ -35,6 +35,11 @@ typedef enum { typedef struct pilotConfig_s { char craftName[MAX_NAME_LENGTH + 1]; char pilotName[MAX_NAME_LENGTH + 1]; + char extra100Throttle[MAX_NAME_LENGTH + 1]; + char extraFcHotWarning[MAX_NAME_LENGTH + 1]; + char extraTurtleModeWarning[MAX_NAME_LENGTH + 1]; + char extraLowBatteryWarning[MAX_NAME_LENGTH + 1]; + char extraArmedWarning[MAX_NAME_LENGTH + 1]; } pilotConfig_t; PG_DECLARE(pilotConfig_t, pilotConfig); diff --git a/src/main/osd/osd.c b/src/main/osd/osd.c index 4089166383..0609529a28 100644 --- a/src/main/osd/osd.c +++ b/src/main/osd/osd.c @@ -1198,7 +1198,7 @@ static timeDelta_t osdShowArmed(void) } else { ret = (REFRESH_1S / 2); } - displayWrite(osdDisplayPort, midCol - (strlen("ARMED") / 2), midRow, DISPLAYPORT_SEVERITY_NORMAL, "ARMED"); + displayWrite(osdDisplayPort, midCol - (strlen(pilotConfig()->extraArmedWarning) / 2), midRow, DISPLAYPORT_SEVERITY_NORMAL, pilotConfig()->extraArmedWarning); if (isFlipOverAfterCrashActive()) { displayWrite(osdDisplayPort, midCol - (strlen(CRASH_FLIP_WARNING) / 2), midRow + 1, DISPLAYPORT_SEVERITY_NORMAL, CRASH_FLIP_WARNING); diff --git a/src/main/osd/osd_elements.c b/src/main/osd/osd_elements.c index 23ebe72afb..073b801101 100644 --- a/src/main/osd/osd_elements.c +++ b/src/main/osd/osd_elements.c @@ -853,7 +853,7 @@ static void osdBackgroundCameraFrame(osdElementParms_t *element) } } -static void toUpperCase(char* dest, const char* src, unsigned int maxSrcLength) +void toUpperCase(char* dest, const char* src, unsigned int maxSrcLength) { unsigned int i; for (i = 0; i < maxSrcLength && src[i]; i++) { @@ -1642,7 +1642,15 @@ static void osdElementStickOverlay(osdElementParms_t *element) static void osdElementThrottlePosition(osdElementParms_t *element) { - tfp_sprintf(element->buff, "%c%3d", SYM_THR, calculateThrottlePercent()); + const uint8_t throttleValue = calculateThrottlePercent(); + if (strlen(pilotConfig()->extra100Throttle) == 0 || throttleValue < 100) + { + tfp_sprintf(element->buff, "%c%3d", SYM_THR, calculateThrottlePercent()); + } + else + { + tfp_sprintf(element->buff, pilotConfig()->extra100Throttle); + } } static void osdElementTimer(osdElementParms_t *element) diff --git a/src/main/osd/osd_elements.h b/src/main/osd/osd_elements.h index 9f08c5ee33..eae51ce409 100644 --- a/src/main/osd/osd_elements.h +++ b/src/main/osd/osd_elements.h @@ -72,3 +72,4 @@ bool osdElementsNeedAccelerometer(void); #ifdef USE_SPEC_PREARM_SCREEN bool osdDrawSpec(displayPort_t *osdDisplayPort); #endif // USE_SPEC_PREARM_SCREEN +void toUpperCase(char* dest, const char* src, unsigned int maxSrcLength); diff --git a/src/main/osd/osd_warnings.c b/src/main/osd/osd_warnings.c index 4b5e57ccb2..378b581b32 100644 --- a/src/main/osd/osd_warnings.c +++ b/src/main/osd/osd_warnings.c @@ -137,7 +137,7 @@ void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr) // Warn when in flip over after crash mode if (osdWarnGetState(OSD_WARNING_CRASH_FLIP) && IS_RC_MODE_ACTIVE(BOXFLIPOVERAFTERCRASH)) { if (isFlipOverAfterCrashActive()) { // if was armed in crash flip mode - tfp_sprintf(warningText, CRASH_FLIP_WARNING); + tfp_sprintf(warningText, pilotConfig()->extraTurtleModeWarning); *displayAttr = DISPLAYPORT_SEVERITY_INFO; return; } else if (!ARMING_FLAG(ARMED)) { // if disarmed, but crash flip mode is activated @@ -207,7 +207,7 @@ void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr) #endif // USE_RX_LINK_QUALITY_INFO if (osdWarnGetState(OSD_WARNING_BATTERY_CRITICAL) && batteryState == BATTERY_CRITICAL) { - tfp_sprintf(warningText, " LAND NOW"); + tfp_sprintf(warningText, ">>> LAND NOW <<<"); *displayAttr = DISPLAYPORT_SEVERITY_CRITICAL; *blinking = true; return; @@ -259,7 +259,7 @@ void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr) #ifdef USE_ADC_INTERNAL const int16_t coreTemperature = getCoreTemperatureCelsius(); if (osdWarnGetState(OSD_WARNING_CORE_TEMPERATURE) && coreTemperature >= osdConfig()->core_temp_alarm) { - tfp_sprintf(warningText, "CORE %c: %3d%c", SYM_TEMPERATURE, osdConvertTemperatureToSelectedUnit(coreTemperature), osdGetTemperatureSymbolForSelectedUnit()); + tfp_sprintf(warningText, "%s %c: %3d%c", pilotConfig()->extraFcHotWarning, SYM_TEMPERATURE, osdConvertTemperatureToSelectedUnit(coreTemperature), osdGetTemperatureSymbolForSelectedUnit()); *displayAttr = DISPLAYPORT_SEVERITY_WARNING; *blinking = true; return; @@ -378,7 +378,7 @@ void renderOsdWarning(char *warningText, bool *blinking, uint8_t *displayAttr) #endif if (osdWarnGetState(OSD_WARNING_BATTERY_WARNING) && batteryState == BATTERY_WARNING) { - tfp_sprintf(warningText, "LOW BATTERY"); + tfp_sprintf(warningText, pilotConfig()->extraLowBatteryWarning); *displayAttr = DISPLAYPORT_SEVERITY_WARNING; *blinking = true; return; diff --git a/src/test/unit/link_quality_unittest.cc b/src/test/unit/link_quality_unittest.cc index fae1992215..3886d2f086 100644 --- a/src/test/unit/link_quality_unittest.cc +++ b/src/test/unit/link_quality_unittest.cc @@ -137,7 +137,7 @@ void doTestArm(bool testEmpty = true) // then // arming alert displayed - displayPortTestBufferSubstring(13, 8, "ARMED"); + displayPortTestBufferSubstring(13, 8, "%s", pilotConfig()->extraArmedWarning); // given // armed alert times out (0.5 seconds) diff --git a/src/test/unit/osd_unittest.cc b/src/test/unit/osd_unittest.cc index f89bdd35d0..ff8884f4f7 100644 --- a/src/test/unit/osd_unittest.cc +++ b/src/test/unit/osd_unittest.cc @@ -168,7 +168,7 @@ void doTestArm(bool testEmpty = true) // then // arming alert displayed - displayPortTestBufferSubstring(13, 8, "ARMED"); + displayPortTestBufferSubstring(13, 8, "%s", pilotConfig()->extraArmedWarning); // given // armed alert times out (0.5 seconds)