mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 08:15:30 +03:00
Merge pull request #7410 from mikeller/fix_osd_conditionals
Fixed conditionals in OSD code.
This commit is contained in:
commit
96d2538b5d
1 changed files with 24 additions and 11 deletions
|
@ -158,6 +158,7 @@ typedef struct radioControls_s {
|
||||||
uint8_t right_horizontal;
|
uint8_t right_horizontal;
|
||||||
} radioControls_t;
|
} radioControls_t;
|
||||||
|
|
||||||
|
#ifdef USE_CMS
|
||||||
typedef enum radioModes_e {
|
typedef enum radioModes_e {
|
||||||
MODE1,
|
MODE1,
|
||||||
MODE2,
|
MODE2,
|
||||||
|
@ -165,7 +166,6 @@ typedef enum radioModes_e {
|
||||||
MODE4
|
MODE4
|
||||||
} radioModes_t;
|
} radioModes_t;
|
||||||
|
|
||||||
static statistic_t stats;
|
|
||||||
#ifdef USE_OSD_STICK_OVERLAY
|
#ifdef USE_OSD_STICK_OVERLAY
|
||||||
static const radioControls_t radioModes[4] = {
|
static const radioControls_t radioModes[4] = {
|
||||||
{ PITCH, YAW, THROTTLE, ROLL }, // Mode 1
|
{ PITCH, YAW, THROTTLE, ROLL }, // Mode 1
|
||||||
|
@ -174,6 +174,9 @@ static const radioControls_t radioModes[4] = {
|
||||||
{ THROTTLE, ROLL, PITCH, YAW }, // Mode 4
|
{ THROTTLE, ROLL, PITCH, YAW }, // Mode 4
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static statistic_t stats;
|
||||||
timeUs_t resumeRefreshAt = 0;
|
timeUs_t resumeRefreshAt = 0;
|
||||||
#define REFRESH_1S 1000 * 1000
|
#define REFRESH_1S 1000 * 1000
|
||||||
|
|
||||||
|
@ -194,6 +197,7 @@ static escSensorData_t *escDataCombined;
|
||||||
#define AH_SIDEBAR_WIDTH_POS 7
|
#define AH_SIDEBAR_WIDTH_POS 7
|
||||||
#define AH_SIDEBAR_HEIGHT_POS 3
|
#define AH_SIDEBAR_HEIGHT_POS 3
|
||||||
|
|
||||||
|
#ifdef USE_CMS
|
||||||
static const char compassBar[] = {
|
static const char compassBar[] = {
|
||||||
SYM_HEADING_W,
|
SYM_HEADING_W,
|
||||||
SYM_HEADING_LINE, SYM_HEADING_DIVIDED_LINE, SYM_HEADING_LINE,
|
SYM_HEADING_LINE, SYM_HEADING_DIVIDED_LINE, SYM_HEADING_LINE,
|
||||||
|
@ -255,6 +259,7 @@ static const uint8_t osdElementDisplayOrder[] = {
|
||||||
OSD_LINK_QUALITY,
|
OSD_LINK_QUALITY,
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
#endif // USE_CMS
|
||||||
|
|
||||||
PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 4);
|
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)
|
static char osdGetBatterySymbol(int cellVoltage)
|
||||||
{
|
{
|
||||||
if (getBatteryState() == BATTERY_CRITICAL) {
|
if (getBatteryState() == BATTERY_CRITICAL) {
|
||||||
|
@ -281,6 +287,7 @@ static char osdGetBatterySymbol(int cellVoltage)
|
||||||
return SYM_BATT_EMPTY - constrain(symOffset, 0, 6);
|
return SYM_BATT_EMPTY - constrain(symOffset, 0, 6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts altitude based on the current unit system.
|
* Converts altitude based on the current unit system.
|
||||||
|
@ -327,6 +334,7 @@ static void osdFormatAltitudeString(char * buff, int32_t altitudeCm)
|
||||||
buff[4] = '.';
|
buff[4] = '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_CMS
|
||||||
static void osdFormatPID(char * buff, const char * label, const pidf_t * pid)
|
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);
|
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;
|
return SYM_ARROW_SOUTH + heading;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static char osdGetTimerSymbol(osd_timer_source_e src)
|
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));
|
osdFormatTime(buff, (usePrecision ? OSD_TIMER_PRECISION(timer) : OSD_TIMER_PREC_SECOND), osdGetTimerValue(src));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_CMS
|
||||||
#ifdef USE_GPS
|
#ifdef USE_GPS
|
||||||
static void osdFormatCoordinate(char *buff, char sym, int32_t val)
|
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
|
#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
|
#ifdef USE_RTC_TIME
|
||||||
static bool osdFormatRtcDateTime(char *buffer)
|
static bool osdFormatRtcDateTime(char *buffer)
|
||||||
{
|
{
|
||||||
|
@ -456,16 +477,6 @@ static bool osdFormatRtcDateTime(char *buffer)
|
||||||
}
|
}
|
||||||
#endif
|
#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)
|
void osdStatSetState(uint8_t statIndex, bool enabled)
|
||||||
{
|
{
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
|
@ -523,6 +534,7 @@ void changeOsdProfileIndex(uint8_t profileIndex)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_CMS
|
||||||
static bool osdDrawSingleElement(uint8_t item)
|
static bool osdDrawSingleElement(uint8_t item)
|
||||||
{
|
{
|
||||||
if (!VISIBLE(osdConfig()->item_pos[item]) || BLINK(item)) {
|
if (!VISIBLE(osdConfig()->item_pos[item]) || BLINK(item)) {
|
||||||
|
@ -1395,6 +1407,7 @@ static void osdDrawElements(void)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif // USE_CMS
|
||||||
|
|
||||||
void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue