mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Separate OSD warnings from OSD task and make available via MSP
Provides a properly implemented way for MSP query type OSD implementations (like DJI) to display OSD warnings. Separates the warnings generation from the OSD task and shares common code to make the text available for the OSD and/or via MSP. Eliminates the need to implement hacks and workarounds like using the `CRAFT_NAME` field to display warnings. Since the warnings logic is now separate, the OSD task does not need to be running unlike other hacks. Adds the `MSP2_GET_OSD_WARNINGS` message formatted as follows: ``` byte description 0 Display attributes including blink (see displayPortAttr_e in drivers/display.h) 1 Length of warning text 2-n Warning text characters ```
This commit is contained in:
parent
21eea5db21
commit
84b6730cdd
9 changed files with 417 additions and 288 deletions
|
@ -112,6 +112,7 @@
|
|||
|
||||
#include "osd/osd.h"
|
||||
#include "osd/osd_elements.h"
|
||||
#include "osd/osd_warnings.h"
|
||||
|
||||
#include "pg/beeper.h"
|
||||
#include "pg/board.h"
|
||||
|
@ -1211,6 +1212,28 @@ static bool mspProcessOutCommand(int16_t cmdMSP, sbuf_t *dst)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef USE_OSD
|
||||
case MSP2_GET_OSD_WARNINGS:
|
||||
{
|
||||
bool isBlinking;
|
||||
uint8_t displayAttr;
|
||||
char warningsBuffer[OSD_FORMAT_MESSAGE_BUFFER_SIZE];
|
||||
|
||||
renderOsdWarning(warningsBuffer, &isBlinking, &displayAttr);
|
||||
const uint8_t warningsLen = strlen(warningsBuffer);
|
||||
|
||||
if (isBlinking) {
|
||||
displayAttr |= DISPLAYPORT_ATTR_BLINK;
|
||||
}
|
||||
sbufWriteU8(dst, displayAttr); // see displayPortAttr_e
|
||||
sbufWriteU8(dst, warningsLen); // length byte followed by the actual characters
|
||||
for (unsigned i = 0; i < warningsLen; i++) {
|
||||
sbufWriteU8(dst, warningsBuffer[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
case MSP_RC:
|
||||
for (int i = 0; i < rxRuntimeState.channelCount; i++) {
|
||||
sbufWriteU16(dst, rcData[i]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue