1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-21 15:25:36 +03:00

Fixup OSD builds without MAX7456

This commit is contained in:
Martin Budden 2016-11-17 07:11:58 +00:00
parent 5362709f03
commit efd859f14d
3 changed files with 45 additions and 26 deletions

View file

@ -1035,7 +1035,11 @@ static bool mspFcProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProcessFn
#ifdef OSD #ifdef OSD
sbufWriteU8(dst, 1); // OSD supported sbufWriteU8(dst, 1); // OSD supported
// send video system (AUTO/PAL/NTSC) // send video system (AUTO/PAL/NTSC)
#ifdef USE_MAX7456
sbufWriteU8(dst, masterConfig.vcdProfile.video_system); sbufWriteU8(dst, masterConfig.vcdProfile.video_system);
#else
sbufWriteU8(dst, 0);
#endif
sbufWriteU8(dst, masterConfig.osdProfile.units); sbufWriteU8(dst, masterConfig.osdProfile.units);
sbufWriteU8(dst, masterConfig.osdProfile.rssi_alarm); sbufWriteU8(dst, masterConfig.osdProfile.rssi_alarm);
sbufWriteU16(dst, masterConfig.osdProfile.cap_alarm); sbufWriteU16(dst, masterConfig.osdProfile.cap_alarm);
@ -1197,9 +1201,6 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
#ifdef GPS #ifdef GPS
uint8_t wp_no; uint8_t wp_no;
int32_t lat = 0, lon = 0, alt = 0; int32_t lat = 0, lon = 0, alt = 0;
#endif
#ifdef OSD
uint8_t addr, font_data[64];
#endif #endif
switch (cmdMSP) { switch (cmdMSP) {
case MSP_SELECT_SETTING: case MSP_SELECT_SETTING:
@ -1532,29 +1533,43 @@ static mspResult_e mspFcProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
#ifdef OSD #ifdef OSD
case MSP_SET_OSD_CONFIG: case MSP_SET_OSD_CONFIG:
addr = sbufReadU8(src); {
// set all the other settings const uint8_t addr = sbufReadU8(src);
if ((int8_t)addr == -1) { // set all the other settings
masterConfig.vcdProfile.video_system = sbufReadU8(src); if ((int8_t)addr == -1) {
masterConfig.osdProfile.units = sbufReadU8(src); #ifdef USE_MAX7456
masterConfig.osdProfile.rssi_alarm = sbufReadU8(src); masterConfig.vcdProfile.video_system = sbufReadU8(src);
masterConfig.osdProfile.cap_alarm = sbufReadU16(src); #else
masterConfig.osdProfile.time_alarm = sbufReadU16(src); sbufReadU8(src); // Skip video system
masterConfig.osdProfile.alt_alarm = sbufReadU16(src); #endif
} masterConfig.osdProfile.units = sbufReadU8(src);
// set a position setting masterConfig.osdProfile.rssi_alarm = sbufReadU8(src);
else { masterConfig.osdProfile.cap_alarm = sbufReadU16(src);
masterConfig.osdProfile.item_pos[addr] = sbufReadU16(src); masterConfig.osdProfile.time_alarm = sbufReadU16(src);
masterConfig.osdProfile.alt_alarm = sbufReadU16(src);
} else {
// set a position setting
masterConfig.osdProfile.item_pos[addr] = sbufReadU16(src);
}
} }
break; break;
case MSP_OSD_CHAR_WRITE: case MSP_OSD_CHAR_WRITE:
addr = sbufReadU8(src);
for (int i = 0; i < 54; i++) {
font_data[i] = sbufReadU8(src);
}
#ifdef USE_MAX7456 #ifdef USE_MAX7456
// !!TODO - replace this with a device independent implementation {
max7456WriteNvm(addr, font_data); uint8_t font_data[64];
const uint8_t addr = sbufReadU8(src);
for (int i = 0; i < 54; i++) {
font_data[i] = sbufReadU8(src);
}
// !!TODO - replace this with a device independent implementation
max7456WriteNvm(addr, font_data);
}
#else
// just discard the data
sbufReadU8(src);
for (int i = 0; i < 54; i++) {
sbufReadU8(src);
}
#endif #endif
break; break;
#endif #endif

View file

@ -619,6 +619,7 @@ static void osdRefresh(uint32_t currentTime)
if (!displayIsGrabbed(osdDisplayPort)) { if (!displayIsGrabbed(osdDisplayPort)) {
osdUpdateAlarms(); osdUpdateAlarms();
osdDrawElements(); osdDrawElements();
displayHeartbeat(osdDisplayPort); // heartbeat to stop Minim OSD going back into native mode
#ifdef OSD_CALLS_CMS #ifdef OSD_CALLS_CMS
} else { } else {
cmsUpdate(currentTime); cmsUpdate(currentTime);
@ -641,9 +642,14 @@ void osdUpdate(uint32_t currentTime)
#endif // MAX7456_DMA_CHANNEL_TX #endif // MAX7456_DMA_CHANNEL_TX
// redraw values in buffer // redraw values in buffer
if (counter++ % 5 == 0) { #ifdef USE_MAX7456
#define DRAW_FREQ_DENOM 5
#else
#define DRAW_FREQ_DENOM 10 // MWOSD @ 115200 baud
#endif
if (counter++ % DRAW_FREQ_DENOM == 0) {
osdRefresh(currentTime); osdRefresh(currentTime);
} else { // rest of time redraw screen 10 chars per idle to don't lock the main idle } else { // rest of time redraw screen 10 chars per idle so it doesn't lock the main idle
displayDrawScreen(osdDisplayPort); displayDrawScreen(osdDisplayPort);
} }

View file

@ -412,8 +412,6 @@ void init(void)
displayPort_t *osdDisplayPort = max7456DisplayPortInit(&masterConfig.vcdProfile); displayPort_t *osdDisplayPort = max7456DisplayPortInit(&masterConfig.vcdProfile);
#else #else
displayPort_t *osdDisplayPort = displayPortMspInit(); displayPort_t *osdDisplayPort = displayPortMspInit();
// grab the OSD to stop the minim OSD writing to it autonomously
displayGrab(osdDisplayPort);
#endif #endif
osdInit(osdDisplayPort); osdInit(osdDisplayPort);
} }