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

Extend OSD warnings storage to 32bits; add count to MSP

Extends the possible OSD warnings elements from 16 to 32.

Adds a warnings count to MSP data to enable improved handling of warnings added to the firmware but not in the Configurator. Incremental Configurator development required.
This commit is contained in:
Bruce Luckcuck 2019-01-17 15:55:54 -05:00
parent 2fdf48b415
commit 05cc74a4ae
3 changed files with 15 additions and 5 deletions

View file

@ -766,7 +766,11 @@ static bool mspCommonProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProce
} }
// Enabled warnings // Enabled warnings
sbufWriteU16(dst, osdConfig()->enabledWarnings); // Send low word first for backwards compatibility (API < 1.41)
sbufWriteU16(dst, (uint16_t)(osdConfig()->enabledWarnings & 0xFFFF));
// API >= 1.41; send the count and 32bit warnings
sbufWriteU8(dst, OSD_WARNING_COUNT);
sbufWriteU32(dst, osdConfig()->enabledWarnings);
#endif #endif
break; break;
} }
@ -2493,8 +2497,14 @@ static mspResult_e mspCommonProcessInCommand(uint8_t cmdMSP, sbuf_t *src, mspPos
if (sbufBytesRemaining(src) >= 2) { if (sbufBytesRemaining(src) >= 2) {
/* Enabled warnings */ /* Enabled warnings */
// API < 1.41 supports only the low 16 bits
osdConfigMutable()->enabledWarnings = sbufReadU16(src); osdConfigMutable()->enabledWarnings = sbufReadU16(src);
} }
if (sbufBytesRemaining(src) >= 4) {
// 32bit version of enabled warnings (API >= 1.41)
osdConfigMutable()->enabledWarnings = sbufReadU32(src);
}
#endif #endif
} else if ((int8_t)addr == -2) { } else if ((int8_t)addr == -2) {
#if defined(USE_OSD) #if defined(USE_OSD)

View file

@ -256,7 +256,7 @@ static const uint8_t osdElementDisplayOrder[] = {
#endif #endif
}; };
PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 4); PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 5);
/** /**
* Gets the correct altitude symbol for the current unit system * Gets the correct altitude symbol for the current unit system

View file

@ -205,8 +205,8 @@ typedef enum {
OSD_WARNING_COUNT // MUST BE LAST OSD_WARNING_COUNT // MUST BE LAST
} osdWarningsFlags_e; } osdWarningsFlags_e;
// Make sure the number of warnings do not exceed the available 16bit storage // Make sure the number of warnings do not exceed the available 32bit storage
STATIC_ASSERT(OSD_WARNING_COUNT <= 16, osdwarnings_overflow); STATIC_ASSERT(OSD_WARNING_COUNT <= 32, osdwarnings_overflow);
#define ESC_RPM_ALARM_OFF -1 #define ESC_RPM_ALARM_OFF -1
#define ESC_TEMP_ALARM_OFF INT8_MIN #define ESC_TEMP_ALARM_OFF INT8_MIN
@ -225,7 +225,7 @@ typedef struct osdConfig_s {
osd_unit_e units; osd_unit_e units;
uint16_t timers[OSD_TIMER_COUNT]; uint16_t timers[OSD_TIMER_COUNT];
uint16_t enabledWarnings; uint32_t enabledWarnings;
uint8_t ahMaxPitch; uint8_t ahMaxPitch;
uint8_t ahMaxRoll; uint8_t ahMaxRoll;