Merge pull request #2895 from betaflight/spracingf3-osd

CF/BF - SPRacingF3 Add OSD over MSP for SPRacingF3OSD compatibility
This commit is contained in:
Martin Budden 2017-04-18 08:18:58 +01:00 committed by GitHub
commit 1374b24175
5 changed files with 45 additions and 24 deletions

View File

@ -46,7 +46,7 @@ static int grab(displayPort_t *displayPort)
UNUSED(displayPort);
#ifdef OSD
osdResetAlarms();
refreshTimeout = 0;
resumeRefreshAt = 0;
#endif
return 0;

View File

@ -54,7 +54,9 @@ static int heartbeat(displayPort_t *displayPort)
{
uint8_t subcmd[] = { 0 };
// ensure display is not released by MW OSD software
// heartbeat is used to:
// a) ensure display is not released by MW OSD software
// b) prevent OSD Slave boards from displaying a 'disconnected' status.
return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd));
}

View File

@ -127,8 +127,8 @@ typedef struct statistic_s {
static statistic_t stats;
uint16_t refreshTimeout = 0;
#define REFRESH_1S 12 // FIXME dependant on how frequently the task is scheduled
uint32_t resumeRefreshAt = 0;
#define REFRESH_1S 1000 * 1000
static uint8_t armState;
@ -621,7 +621,7 @@ void osdInit(displayPort_t *osdDisplayPortToUse)
displayResync(osdDisplayPort);
refreshTimeout = 4 * REFRESH_1S;
resumeRefreshAt = micros() + (4 * REFRESH_1S);
}
void osdUpdateAlarms(void)
@ -803,17 +803,12 @@ static void osdShowStats(void)
displayWrite(osdDisplayPort, 22, top++, buff);
}
#endif
refreshTimeout = 60 * REFRESH_1S;
}
// called when motors armed
static void osdArmMotors(void)
static void osdShowArmed(void)
{
displayClearScreen(osdDisplayPort);
displayWrite(osdDisplayPort, 12, 7, "ARMED");
refreshTimeout = REFRESH_1S / 2;
osdResetStats();
}
static void osdRefresh(timeUs_t currentTimeUs)
@ -823,10 +818,14 @@ static void osdRefresh(timeUs_t currentTimeUs)
// detect arm/disarm
if (armState != ARMING_FLAG(ARMED)) {
if (ARMING_FLAG(ARMED))
osdArmMotors(); // reset statistic etc
else
osdShowStats(); // show statistic
if (ARMING_FLAG(ARMED)) {
osdResetStats();
osdShowArmed();
resumeRefreshAt = currentTimeUs + (REFRESH_1S / 2);
} else {
osdShowStats();
resumeRefreshAt = currentTimeUs + (60 * REFRESH_1S);
}
armState = ARMING_FLAG(ARMED);
}
@ -840,13 +839,19 @@ static void osdRefresh(timeUs_t currentTimeUs)
lastSec = sec;
}
if (refreshTimeout) {
if (IS_HI(THROTTLE) || IS_HI(PITCH)) // hide statistics
refreshTimeout = 1;
refreshTimeout--;
if (!refreshTimeout)
if (resumeRefreshAt) {
if (cmp32(currentTimeUs, resumeRefreshAt) < 0) {
// in timeout period, check sticks for activity to resume display.
if (IS_HI(THROTTLE) || IS_HI(PITCH)) {
resumeRefreshAt = 0;
}
displayHeartbeat(osdDisplayPort);
return;
} else {
displayClearScreen(osdDisplayPort);
return;
resumeRefreshAt = 0;
}
}
blinkState = (currentTimeUs / 200000) % 2;
@ -855,7 +860,7 @@ static void osdRefresh(timeUs_t currentTimeUs)
if (!displayIsGrabbed(osdDisplayPort)) {
osdUpdateAlarms();
osdDrawElements();
displayHeartbeat(osdDisplayPort); // heartbeat to stop Minim OSD going back into native mode
displayHeartbeat(osdDisplayPort);
#ifdef OSD_CALLS_CMS
} else {
cmsUpdate(currentTimeUs);
@ -881,8 +886,18 @@ void osdUpdate(timeUs_t currentTimeUs)
#ifdef USE_MAX7456
#define DRAW_FREQ_DENOM 5
#else
#define DRAW_FREQ_DENOM 10 // MWOSD @ 115200 baud
#define DRAW_FREQ_DENOM 10 // MWOSD @ 115200 baud (
#endif
#ifdef USE_SLOW_MSP_DISPLAYPORT_RATE_WHEN_UNARMED
static uint32_t idlecounter = 0;
if (!ARMING_FLAG(ARMED)) {
if (idlecounter++ % 4 != 0) {
return;
}
}
#endif
if (counter++ % DRAW_FREQ_DENOM == 0) {
osdRefresh(currentTimeUs);
} else { // rest of time redraw screen 10 chars per idle so it doesn't lock the main idle

View File

@ -73,7 +73,7 @@ typedef struct osdConfig_s {
osd_unit_e units;
} osdConfig_t;
extern uint16_t refreshTimeout;
extern uint32_t resumeRefreshAt;
PG_DECLARE(osdConfig_t, osdConfig);

View File

@ -171,6 +171,10 @@
#define CURRENT_METER_ADC_PIN PA5
#define RSSI_ADC_PIN PB2
#define OSD
#define USE_OSD_OVER_MSP_DISPLAYPORT
#define USE_SLOW_MSP_DISPLAYPORT_RATE_WHEN_UNARMED
#define USE_ESC_SENSOR
#define REMAP_TIM17_DMA