Skip to content

Commit

Permalink
Render spec screen over normal OSD (betaflight#13460)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveCEvans authored Mar 21, 2024
1 parent 9dfa09a commit dc00d34
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 30 deletions.
38 changes: 17 additions & 21 deletions src/main/osd/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1462,31 +1462,10 @@ void osdUpdate(timeUs_t currentTimeUs)
if (resumeRefreshAt) {
osdState = OSD_STATE_TRANSFER;
} else {
#ifdef USE_SPEC_PREARM_SCREEN
osdState = OSD_STATE_REFRESH_PREARM;
#else
osdState = OSD_STATE_UPDATE_CANVAS;
#endif
}
break;

case OSD_STATE_REFRESH_PREARM:
{
#ifdef USE_SPEC_PREARM_SCREEN
if (!ARMING_FLAG(ARMED) && osdConfig()->osd_show_spec_prearm) {
if (osdDrawSpec(osdDisplayPort)) {
// Rendering is complete
osdState = OSD_STATE_COMMIT;
}
} else
#endif // USE_SPEC_PREARM_SCREEN
{
osdState = OSD_STATE_UPDATE_CANVAS;
}
}

break;

case OSD_STATE_UPDATE_CANVAS:
// Hide OSD when OSDSW mode is active
if (IS_RC_MODE_ACTIVE(BOXOSD)) {
Expand Down Expand Up @@ -1555,9 +1534,26 @@ void osdUpdate(timeUs_t currentTimeUs)
break;
}

#ifdef USE_SPEC_PREARM_SCREEN
if (!ARMING_FLAG(ARMED) && osdConfig()->osd_show_spec_prearm) {
osdState = OSD_STATE_REFRESH_PREARM;
} else
#endif // USE_SPEC_PREARM_SCREEN
{
osdState = OSD_STATE_COMMIT;
}
}
break;

#ifdef USE_SPEC_PREARM_SCREEN
case OSD_STATE_REFRESH_PREARM:
if (osdDrawSpec(osdDisplayPort)) {
// Rendering is complete
osdState = OSD_STATE_COMMIT;
}

break;
#endif // USE_SPEC_PREARM_SCREEN

case OSD_STATE_COMMIT:
displayCommitTransaction(osdDisplayPort);
Expand Down
12 changes: 3 additions & 9 deletions src/main/osd/osd_elements.c
Original file line number Diff line number Diff line change
Expand Up @@ -2199,7 +2199,7 @@ bool osdDrawNextActiveElement(displayPort_t *osdDisplayPort, timeUs_t currentTim
#ifdef USE_SPEC_PREARM_SCREEN
bool osdDrawSpec(displayPort_t *osdDisplayPort)
{
static enum {CLR, RPM, POLES, MIXER, THR, MOTOR, BAT, VER} specState = CLR;
static enum {RPM, POLES, MIXER, THR, MOTOR, BAT, VER} specState = RPM;
static int currentRow;

const uint8_t midRow = osdDisplayPort->rows / 2;
Expand All @@ -2211,14 +2211,8 @@ bool osdDrawSpec(displayPort_t *osdDisplayPort)

switch (specState) {
default:
case CLR:
displayClearScreen(osdDisplayPort, DISPLAY_CLEAR_NONE);
currentRow = midRow - 3;

specState = RPM;
break;

case RPM:
currentRow = midRow - 3;
#ifdef USE_RPM_LIMIT
{
const bool rpmLimitActive = mixerConfig()->rpm_limit > 0 && isMotorProtocolBidirDshot();
Expand Down Expand Up @@ -2283,7 +2277,7 @@ bool osdDrawSpec(displayPort_t *osdDisplayPort)
len = strlen(FC_VERSION_STRING);
displayWrite(osdDisplayPort, midCol - (len / 2), currentRow++, DISPLAYPORT_SEVERITY_NORMAL, FC_VERSION_STRING);

specState = CLR;
specState = RPM;

return true;
}
Expand Down

0 comments on commit dc00d34

Please sign in to comment.