1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 12:55:19 +03:00

Funny OSD

This commit is contained in:
Ivan Efimov 2022-12-29 11:02:30 -06:00 committed by limon.spb
parent d9044b5322
commit ffa9a0ee48
9 changed files with 46 additions and 9 deletions

View file

@ -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

View file

@ -22,6 +22,7 @@
#include <stdint.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#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

View file

@ -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);

View file

@ -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);

View file

@ -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)

View file

@ -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);

View file

@ -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;

View file

@ -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)

View file

@ -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)