Skip to content

Commit

Permalink
Add support for displaying the debug[] array in the OSD
Browse files Browse the repository at this point in the history
Element intentionally not added to the configurator nor CMS. Must
be set via CLI or MSP.
  • Loading branch information
fiam committed May 11, 2018
1 parent 7120d65 commit 2889160
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/cms/cms_menu_osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,10 @@ static const OSD_Entry menuOsdElemsEntries[] =
};

#if defined(VTX_COMMON) && defined(USE_GPS) && defined(USE_BARO) && defined(USE_PITOT)
// All CMS OSD elements should be enabled in this case
_Static_assert(ARRAYLEN(menuOsdElemsEntries) - 3 == OSD_ITEM_COUNT, "missing OSD elements in CMS");
// All CMS OSD elements should be enabled in this case. The menu has 3 extra
// elements (label, back and end), but there's an OSD element that we intentionally
// don't show here (OSD_DEBUG).
_Static_assert(ARRAYLEN(menuOsdElemsEntries) - 3 + 1 == OSD_ITEM_COUNT, "missing OSD elements in CMS");
#endif

const CMS_Menu menuOsdElements = {
Expand Down
10 changes: 10 additions & 0 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,16 @@ static bool osdDrawSingleElement(uint8_t item)
break;
}

case OSD_DEBUG:
{
// Longest representable string is -32768, hence 6 characters
tfp_sprintf(buff, "[0]=%6d [1]=%6d", debug[0], debug[1]);
displayWrite(osdDisplayPort, elemPosX, elemPosY, buff);
elemPosY++;
tfp_sprintf(buff, "[2]=%6d [3]=%6d", debug[2], debug[3]);
break;
}

default:
return false;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/io/osd.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ typedef enum {
OSD_MAP_NORTH,
OSD_MAP_TAKEOFF,
OSD_RADAR,
OSD_DEBUG, // Number 46. Intentionally absent from configurator and CMS. Set it from CLI.
OSD_ITEM_COUNT // MUST BE LAST
} osd_items_e;

Expand Down

0 comments on commit 2889160

Please sign in to comment.