mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Add option to display the OSD logo on arming (#9244)
Add option to display the OSD logo on arming
This commit is contained in:
commit
938f46ccd1
4 changed files with 37 additions and 3 deletions
|
@ -487,6 +487,11 @@ static const char * const lookupTableOsdDisplayPortDevice[] = {
|
||||||
"NONE", "AUTO", "MAX7456", "MSP",
|
"NONE", "AUTO", "MAX7456", "MSP",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef USE_OSD
|
||||||
|
static const char * const lookupTableOsdLogoOnArming[] = {
|
||||||
|
"OFF", "ON", "FIRST_ARMING",
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#define LOOKUP_TABLE_ENTRY(name) { name, ARRAYLEN(name) }
|
#define LOOKUP_TABLE_ENTRY(name) { name, ARRAYLEN(name) }
|
||||||
|
|
||||||
|
@ -606,6 +611,10 @@ const lookupTableEntry_t lookupTables[] = {
|
||||||
LOOKUP_TABLE_ENTRY(lookupTableInterpolatedSetpoint),
|
LOOKUP_TABLE_ENTRY(lookupTableInterpolatedSetpoint),
|
||||||
LOOKUP_TABLE_ENTRY(lookupTableDshotBitbangedTimer),
|
LOOKUP_TABLE_ENTRY(lookupTableDshotBitbangedTimer),
|
||||||
LOOKUP_TABLE_ENTRY(lookupTableOsdDisplayPortDevice),
|
LOOKUP_TABLE_ENTRY(lookupTableOsdDisplayPortDevice),
|
||||||
|
|
||||||
|
#ifdef USE_OSD
|
||||||
|
LOOKUP_TABLE_ENTRY(lookupTableOsdLogoOnArming),
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef LOOKUP_TABLE_ENTRY
|
#undef LOOKUP_TABLE_ENTRY
|
||||||
|
@ -1242,6 +1251,8 @@ const clivalue_t valueTable[] = {
|
||||||
{ "osd_ah_max_pit", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 90 }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahMaxPitch) },
|
{ "osd_ah_max_pit", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 90 }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahMaxPitch) },
|
||||||
{ "osd_ah_max_rol", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 90 }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahMaxRoll) },
|
{ "osd_ah_max_rol", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 90 }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahMaxRoll) },
|
||||||
{ "osd_ah_invert", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahInvert) },
|
{ "osd_ah_invert", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, ahInvert) },
|
||||||
|
{ "osd_logo_on_arming", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OSD_LOGO_ON_ARMING }, PG_OSD_CONFIG, offsetof(osdConfig_t, logo_on_arming) },
|
||||||
|
{ "osd_logo_on_arming_duration",VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 5, 50 }, PG_OSD_CONFIG, offsetof(osdConfig_t, logo_on_arming_duration) },
|
||||||
|
|
||||||
{ "osd_tim1", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, INT16_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, timers[OSD_TIMER_1]) },
|
{ "osd_tim1", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, INT16_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, timers[OSD_TIMER_1]) },
|
||||||
{ "osd_tim2", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, INT16_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, timers[OSD_TIMER_2]) },
|
{ "osd_tim2", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, INT16_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, timers[OSD_TIMER_2]) },
|
||||||
|
|
|
@ -139,6 +139,9 @@ typedef enum {
|
||||||
TABLE_INTERPOLATED_SP,
|
TABLE_INTERPOLATED_SP,
|
||||||
TABLE_DSHOT_BITBANGED_TIMER,
|
TABLE_DSHOT_BITBANGED_TIMER,
|
||||||
TABLE_OSD_DISPLAYPORT_DEVICE,
|
TABLE_OSD_DISPLAYPORT_DEVICE,
|
||||||
|
#ifdef USE_OSD
|
||||||
|
TABLE_OSD_LOGO_ON_ARMING,
|
||||||
|
#endif
|
||||||
|
|
||||||
LOOKUP_TABLE_COUNT
|
LOOKUP_TABLE_COUNT
|
||||||
} lookupTableIndex_e;
|
} lookupTableIndex_e;
|
||||||
|
|
|
@ -91,6 +91,12 @@
|
||||||
#include "hardware_revision.h"
|
#include "hardware_revision.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
OSD_LOGO_ARMING_OFF,
|
||||||
|
OSD_LOGO_ARMING_ON,
|
||||||
|
OSD_LOGO_ARMING_FIRST
|
||||||
|
} osd_logo_on_arming_e;
|
||||||
|
|
||||||
const char * const osdTimerSourceNames[] = {
|
const char * const osdTimerSourceNames[] = {
|
||||||
"ON TIME ",
|
"ON TIME ",
|
||||||
"TOTAL ARM",
|
"TOTAL ARM",
|
||||||
|
@ -332,6 +338,8 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
||||||
osdConfig->displayPortDevice = OSD_DISPLAYPORT_DEVICE_AUTO;
|
osdConfig->displayPortDevice = OSD_DISPLAYPORT_DEVICE_AUTO;
|
||||||
|
|
||||||
osdConfig->distance_alarm = 0;
|
osdConfig->distance_alarm = 0;
|
||||||
|
osdConfig->logo_on_arming = OSD_LOGO_ARMING_OFF;
|
||||||
|
osdConfig->logo_on_arming_duration = 5; // 0.5 seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
static void osdDrawLogo(int x, int y)
|
static void osdDrawLogo(int x, int y)
|
||||||
|
@ -806,10 +814,21 @@ static void osdRefreshStats(void)
|
||||||
osdShowStats(osdStatsRowCount);
|
osdShowStats(osdStatsRowCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void osdShowArmed(void)
|
static timeDelta_t osdShowArmed(void)
|
||||||
{
|
{
|
||||||
|
static bool everArmed = false;
|
||||||
|
timeDelta_t ret;
|
||||||
|
|
||||||
displayClearScreen(osdDisplayPort);
|
displayClearScreen(osdDisplayPort);
|
||||||
|
if ((osdConfig()->logo_on_arming == OSD_LOGO_ARMING_ON) || ((osdConfig()->logo_on_arming == OSD_LOGO_ARMING_FIRST) && !everArmed)) {
|
||||||
|
osdDrawLogo(3, 1);
|
||||||
|
ret = osdConfig()->logo_on_arming_duration * 1e5;
|
||||||
|
} else {
|
||||||
|
ret = (REFRESH_1S / 2);
|
||||||
|
}
|
||||||
displayWrite(osdDisplayPort, 12, 7, DISPLAYPORT_ATTR_NONE, "ARMED");
|
displayWrite(osdDisplayPort, 12, 7, DISPLAYPORT_ATTR_NONE, "ARMED");
|
||||||
|
everArmed = true;
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
|
STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
|
||||||
|
@ -825,8 +844,7 @@ STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
|
||||||
osdStatsEnabled = false;
|
osdStatsEnabled = false;
|
||||||
osdStatsVisible = false;
|
osdStatsVisible = false;
|
||||||
osdResetStats();
|
osdResetStats();
|
||||||
osdShowArmed();
|
resumeRefreshAt = osdShowArmed() + currentTimeUs;
|
||||||
resumeRefreshAt = currentTimeUs + (REFRESH_1S / 2);
|
|
||||||
} else if (isSomeStatEnabled()
|
} else if (isSomeStatEnabled()
|
||||||
&& !suppressStatsDisplay
|
&& !suppressStatsDisplay
|
||||||
&& (!(getArmingDisableFlags() & (ARMING_DISABLED_RUNAWAY_TAKEOFF | ARMING_DISABLED_CRASH_DETECTED))
|
&& (!(getArmingDisableFlags() & (ARMING_DISABLED_RUNAWAY_TAKEOFF | ARMING_DISABLED_CRASH_DETECTED))
|
||||||
|
|
|
@ -271,6 +271,8 @@ typedef struct osdConfig_s {
|
||||||
int8_t rcChannels[OSD_RCCHANNELS_COUNT]; // RC channel values to display, -1 if none
|
int8_t rcChannels[OSD_RCCHANNELS_COUNT]; // RC channel values to display, -1 if none
|
||||||
uint8_t displayPortDevice; // osdDisplayPortDevice_e
|
uint8_t displayPortDevice; // osdDisplayPortDevice_e
|
||||||
uint16_t distance_alarm;
|
uint16_t distance_alarm;
|
||||||
|
uint8_t logo_on_arming; // show the logo on arming
|
||||||
|
uint8_t logo_on_arming_duration; // display duration in 0.1s units
|
||||||
} osdConfig_t;
|
} osdConfig_t;
|
||||||
|
|
||||||
PG_DECLARE(osdConfig_t, osdConfig);
|
PG_DECLARE(osdConfig_t, osdConfig);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue