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

Merge pull request #3133 from DanNixon/osd_stats

Allow customisation of the OSD stats screen
This commit is contained in:
borisbstyle 2017-05-23 14:07:19 +02:00 committed by GitHub
commit 29917db6f2
4 changed files with 114 additions and 32 deletions

View file

@ -775,6 +775,9 @@ static bool mspCommonProcessOutCommand(uint8_t cmdMSP, sbuf_t *dst, mspPostProce
for (int i = 0; i < OSD_ITEM_COUNT; i++) {
sbufWriteU16(dst, osdConfig()->item_pos[i]);
}
for (int i = 0; i < OSD_STAT_COUNT; i++ ) {
sbufWriteU8(dst, osdConfig()->enabled_stats[i]);
}
#endif
break;
}
@ -2039,8 +2042,9 @@ static mspResult_e mspCommonProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
case MSP_SET_OSD_CONFIG:
{
const uint8_t addr = sbufReadU8(src);
// set all the other settings
if ((int8_t)addr == -1) {
/* Set general OSD settings */
#ifdef USE_MAX7456
vcdProfileMutable()->video_system = sbufReadU8(src);
#else
@ -2055,10 +2059,17 @@ static mspResult_e mspCommonProcessInCommand(uint8_t cmdMSP, sbuf_t *src)
#endif
} else {
#if defined(OSD)
// set a position setting
const uint16_t pos = sbufReadU16(src);
if (addr < OSD_ITEM_COUNT) {
osdConfigMutable()->item_pos[addr] = pos;
const uint16_t value = sbufReadU16(src);
/* Get screen index, 0 is post flight statsitsics, 1 and above are in flight OSD screens */
const uint8_t screen = (sbufBytesRemaining(src) >= 1) ? sbufReadU8(src) : 1;
if (screen == 0 && addr < OSD_STAT_COUNT) {
/* Set statistic item enable */
osdConfigMutable()->enabled_stats[addr] = value;
} else if (addr < OSD_ITEM_COUNT) {
/* Set element positions */
osdConfigMutable()->item_pos[addr] = value;
}
#else
return MSP_RESULT_ERROR;