Merge pull request #2895 from betaflight/spracingf3-osd
CF/BF - SPRacingF3 Add OSD over MSP for SPRacingF3OSD compatibility
This commit is contained in:
commit
1374b24175
|
@ -46,7 +46,7 @@ static int grab(displayPort_t *displayPort)
|
||||||
UNUSED(displayPort);
|
UNUSED(displayPort);
|
||||||
#ifdef OSD
|
#ifdef OSD
|
||||||
osdResetAlarms();
|
osdResetAlarms();
|
||||||
refreshTimeout = 0;
|
resumeRefreshAt = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -54,7 +54,9 @@ static int heartbeat(displayPort_t *displayPort)
|
||||||
{
|
{
|
||||||
uint8_t subcmd[] = { 0 };
|
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));
|
return output(displayPort, MSP_DISPLAYPORT, subcmd, sizeof(subcmd));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,8 +127,8 @@ typedef struct statistic_s {
|
||||||
|
|
||||||
static statistic_t stats;
|
static statistic_t stats;
|
||||||
|
|
||||||
uint16_t refreshTimeout = 0;
|
uint32_t resumeRefreshAt = 0;
|
||||||
#define REFRESH_1S 12 // FIXME dependant on how frequently the task is scheduled
|
#define REFRESH_1S 1000 * 1000
|
||||||
|
|
||||||
static uint8_t armState;
|
static uint8_t armState;
|
||||||
|
|
||||||
|
@ -621,7 +621,7 @@ void osdInit(displayPort_t *osdDisplayPortToUse)
|
||||||
|
|
||||||
displayResync(osdDisplayPort);
|
displayResync(osdDisplayPort);
|
||||||
|
|
||||||
refreshTimeout = 4 * REFRESH_1S;
|
resumeRefreshAt = micros() + (4 * REFRESH_1S);
|
||||||
}
|
}
|
||||||
|
|
||||||
void osdUpdateAlarms(void)
|
void osdUpdateAlarms(void)
|
||||||
|
@ -803,17 +803,12 @@ static void osdShowStats(void)
|
||||||
displayWrite(osdDisplayPort, 22, top++, buff);
|
displayWrite(osdDisplayPort, 22, top++, buff);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
refreshTimeout = 60 * REFRESH_1S;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// called when motors armed
|
static void osdShowArmed(void)
|
||||||
static void osdArmMotors(void)
|
|
||||||
{
|
{
|
||||||
displayClearScreen(osdDisplayPort);
|
displayClearScreen(osdDisplayPort);
|
||||||
displayWrite(osdDisplayPort, 12, 7, "ARMED");
|
displayWrite(osdDisplayPort, 12, 7, "ARMED");
|
||||||
refreshTimeout = REFRESH_1S / 2;
|
|
||||||
osdResetStats();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void osdRefresh(timeUs_t currentTimeUs)
|
static void osdRefresh(timeUs_t currentTimeUs)
|
||||||
|
@ -823,10 +818,14 @@ static void osdRefresh(timeUs_t currentTimeUs)
|
||||||
|
|
||||||
// detect arm/disarm
|
// detect arm/disarm
|
||||||
if (armState != ARMING_FLAG(ARMED)) {
|
if (armState != ARMING_FLAG(ARMED)) {
|
||||||
if (ARMING_FLAG(ARMED))
|
if (ARMING_FLAG(ARMED)) {
|
||||||
osdArmMotors(); // reset statistic etc
|
osdResetStats();
|
||||||
else
|
osdShowArmed();
|
||||||
osdShowStats(); // show statistic
|
resumeRefreshAt = currentTimeUs + (REFRESH_1S / 2);
|
||||||
|
} else {
|
||||||
|
osdShowStats();
|
||||||
|
resumeRefreshAt = currentTimeUs + (60 * REFRESH_1S);
|
||||||
|
}
|
||||||
|
|
||||||
armState = ARMING_FLAG(ARMED);
|
armState = ARMING_FLAG(ARMED);
|
||||||
}
|
}
|
||||||
|
@ -840,13 +839,19 @@ static void osdRefresh(timeUs_t currentTimeUs)
|
||||||
lastSec = sec;
|
lastSec = sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refreshTimeout) {
|
if (resumeRefreshAt) {
|
||||||
if (IS_HI(THROTTLE) || IS_HI(PITCH)) // hide statistics
|
if (cmp32(currentTimeUs, resumeRefreshAt) < 0) {
|
||||||
refreshTimeout = 1;
|
// in timeout period, check sticks for activity to resume display.
|
||||||
refreshTimeout--;
|
if (IS_HI(THROTTLE) || IS_HI(PITCH)) {
|
||||||
if (!refreshTimeout)
|
resumeRefreshAt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
displayHeartbeat(osdDisplayPort);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
displayClearScreen(osdDisplayPort);
|
displayClearScreen(osdDisplayPort);
|
||||||
return;
|
resumeRefreshAt = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
blinkState = (currentTimeUs / 200000) % 2;
|
blinkState = (currentTimeUs / 200000) % 2;
|
||||||
|
@ -855,7 +860,7 @@ static void osdRefresh(timeUs_t currentTimeUs)
|
||||||
if (!displayIsGrabbed(osdDisplayPort)) {
|
if (!displayIsGrabbed(osdDisplayPort)) {
|
||||||
osdUpdateAlarms();
|
osdUpdateAlarms();
|
||||||
osdDrawElements();
|
osdDrawElements();
|
||||||
displayHeartbeat(osdDisplayPort); // heartbeat to stop Minim OSD going back into native mode
|
displayHeartbeat(osdDisplayPort);
|
||||||
#ifdef OSD_CALLS_CMS
|
#ifdef OSD_CALLS_CMS
|
||||||
} else {
|
} else {
|
||||||
cmsUpdate(currentTimeUs);
|
cmsUpdate(currentTimeUs);
|
||||||
|
@ -881,8 +886,18 @@ void osdUpdate(timeUs_t currentTimeUs)
|
||||||
#ifdef USE_MAX7456
|
#ifdef USE_MAX7456
|
||||||
#define DRAW_FREQ_DENOM 5
|
#define DRAW_FREQ_DENOM 5
|
||||||
#else
|
#else
|
||||||
#define DRAW_FREQ_DENOM 10 // MWOSD @ 115200 baud
|
#define DRAW_FREQ_DENOM 10 // MWOSD @ 115200 baud (
|
||||||
#endif
|
#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) {
|
if (counter++ % DRAW_FREQ_DENOM == 0) {
|
||||||
osdRefresh(currentTimeUs);
|
osdRefresh(currentTimeUs);
|
||||||
} else { // rest of time redraw screen 10 chars per idle so it doesn't lock the main idle
|
} else { // rest of time redraw screen 10 chars per idle so it doesn't lock the main idle
|
||||||
|
|
|
@ -73,7 +73,7 @@ typedef struct osdConfig_s {
|
||||||
osd_unit_e units;
|
osd_unit_e units;
|
||||||
} osdConfig_t;
|
} osdConfig_t;
|
||||||
|
|
||||||
extern uint16_t refreshTimeout;
|
extern uint32_t resumeRefreshAt;
|
||||||
|
|
||||||
PG_DECLARE(osdConfig_t, osdConfig);
|
PG_DECLARE(osdConfig_t, osdConfig);
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,10 @@
|
||||||
#define CURRENT_METER_ADC_PIN PA5
|
#define CURRENT_METER_ADC_PIN PA5
|
||||||
#define RSSI_ADC_PIN PB2
|
#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 USE_ESC_SENSOR
|
||||||
#define REMAP_TIM17_DMA
|
#define REMAP_TIM17_DMA
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue