1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 00:35:39 +03:00

added osdDrawPrearmStrings

This commit is contained in:
limonspb 2024-04-28 21:39:42 -05:00 committed by limon.spb
parent a7cda11eb5
commit 1c5d65e50b
4 changed files with 65 additions and 1 deletions

View file

@ -1773,6 +1773,11 @@ const clivalue_t valueTable[] = {
{ "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) },
{ "extra_land_now_warning", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, extraLandNowWarning) },
{ "extra_prearm_1", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, extraPrearm1) },
{ "extra_prearm_2", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, extraPrearm2) },
{ "extra_prearm_3", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, MAX_NAME_LENGTH, STRING_FLAGS_NONE }, PG_PILOT_CONFIG, offsetof(pilotConfig_t, extraPrearm3) },
#endif
// PG_POSITION

View file

@ -120,6 +120,9 @@ PG_RESET_TEMPLATE(pilotConfig_t, pilotConfig,
.extraLowBatteryWarning = "AINT LEAVING",
.extraArmedWarning = "LETS GO",
.extraLandNowWarning = ">> LAND NOW <<",
.extraPrearm1 = "SCULLY",
.extraPrearm2 = "ONE",
.extraPrearm3 = "LOVE",
);
PG_REGISTER_WITH_RESET_TEMPLATE(systemConfig_t, systemConfig, PG_SYSTEM_CONFIG, 3);
@ -226,6 +229,10 @@ void makeStringsUpperCase(void)
toUpperCase(pilotConfigMutable()->extraTurtleModeWarning, pilotConfig()->extraTurtleModeWarning, MAX_NAME_LENGTH);
toUpperCase(pilotConfigMutable()->extraLowBatteryWarning, pilotConfig()->extraLowBatteryWarning, MAX_NAME_LENGTH);
toUpperCase(pilotConfigMutable()->extraArmedWarning, pilotConfig()->extraArmedWarning, MAX_NAME_LENGTH);
toUpperCase(pilotConfigMutable()->extraPrearm1, pilotConfig()->extraPrearm1, MAX_NAME_LENGTH);
toUpperCase(pilotConfigMutable()->extraPrearm2, pilotConfig()->extraPrearm2, MAX_NAME_LENGTH);
toUpperCase(pilotConfigMutable()->extraPrearm3, pilotConfig()->extraPrearm3, MAX_NAME_LENGTH);
}
static void validateAndFixConfig(void)

View file

@ -41,6 +41,10 @@ typedef struct pilotConfig_s {
char extraLowBatteryWarning[MAX_NAME_LENGTH + 1];
char extraArmedWarning[MAX_NAME_LENGTH + 1];
char extraLandNowWarning[MAX_NAME_LENGTH + 1];
char extraPrearm1[MAX_NAME_LENGTH + 1];
char extraPrearm2[MAX_NAME_LENGTH + 1];
char extraPrearm3[MAX_NAME_LENGTH + 1];
} pilotConfig_t;
PG_DECLARE(pilotConfig_t, pilotConfig);

View file

@ -2250,7 +2250,8 @@ bool osdDrawNextActiveElement(displayPort_t *osdDisplayPort)
}
#ifdef USE_SPEC_PREARM_SCREEN
bool osdDrawSpec(displayPort_t *osdDisplayPort)
bool osdDrawSpecReal(displayPort_t *osdDisplayPort)
{
static enum {RPM, POLES, MIXER, THR, MOTOR, BAT, VER} specState = RPM;
static int currentRow;
@ -2337,6 +2338,53 @@ bool osdDrawSpec(displayPort_t *osdDisplayPort)
return false;
}
bool osdDrawPrearmStrings(displayPort_t *osdDisplayPort)
{
const uint8_t midRow = osdDisplayPort->rows / 2;
const uint8_t midCol = osdDisplayPort->cols / 2;
char buff[OSD_ELEMENT_BUFFER_LENGTH] = "";
int len = 0;
static int currentRow;
static int state = 0;
switch (state) {
default:
case 0:
state++;
currentRow = midRow - 2;
len = tfp_sprintf(buff, "%s", pilotConfig()->extraPrearm1);
displayWrite(osdDisplayPort, midCol - (len / 2), currentRow++, DISPLAYPORT_SEVERITY_NORMAL, buff);
break;
case 1:
state++;
len = tfp_sprintf(buff, "%s", pilotConfig()->extraPrearm1);
displayWrite(osdDisplayPort, midCol - (len / 2), currentRow++, DISPLAYPORT_SEVERITY_NORMAL, buff);
break;
case 2:
state = 0;
len = tfp_sprintf(buff, "%s", pilotConfig()->extraPrearm1);
displayWrite(osdDisplayPort, midCol - (len / 2), currentRow++, DISPLAYPORT_SEVERITY_NORMAL, buff);
return true;
}
return false;
}
bool osdDrawSpec(displayPort_t *osdDisplayPort)
{
const uint8_t throttleValue = calculateThrottlePercent();
if (throttleValue > 80) {
return osdDrawPrearmStrings(osdDisplayPort);
} else {
return osdDrawSpecReal(osdDisplayPort);
}
}
#endif // USE_SPEC_PREARM_SCREEN
void osdDrawActiveElementsBackground(displayPort_t *osdDisplayPort)