1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 17:25:20 +03:00

Add OSD Profile feature - issue 4155

This commit is contained in:
Pieter Kruger 2018-11-30 07:37:29 +10:00
parent 8a4ea0785e
commit 8d981df1a9
12 changed files with 227 additions and 66 deletions

View file

@ -149,7 +149,9 @@ timeUs_t resumeRefreshAt = 0;
static uint8_t armState;
static bool lastArmState;
#ifdef USE_OSD_PROFILES
static uint8_t osdProfile = 1;
#endif
static displayPort_t *osdDisplayPort;
static bool suppressStatsDisplay = false;
@ -470,12 +472,47 @@ bool osdWarnGetState(uint8_t warningIndex)
return osdConfig()->enabledWarnings & (1 << warningIndex);
}
#ifdef USE_OSD_PROFILES
void setOsdProfile(uint8_t value)
{
// 1 ->> 001
// 2 ->> 010
// 3 ->> 100
if (value <= OSD_PROFILE_COUNT) {
if (value == 0) {
osdProfile = 1;
} else {
osdProfile = 1 << (value - 1);
}
}
}
uint8_t getCurrentOsdProfileIndex(void)
{
return osdConfig()->osdProfileIndex;
}
void changeOsdProfileIndex(uint8_t profileIndex)
{
if (profileIndex <= OSD_PROFILE_COUNT) {
osdConfigMutable()->osdProfileIndex = profileIndex;
setOsdProfile(profileIndex);
}
}
#endif
static bool osdDrawSingleElement(uint8_t item)
{
#ifdef USE_OSD_PROFILES
if ((OSD_ELEMENT_PROFILE(osdConfig()->item_pos[item]) & osdProfile) == 0) {
return false;
}
#else
if (!VISIBLE(osdConfig()->item_pos[item]) || BLINK(item)) {
return false;
}
#endif
uint8_t elemPosX = OSD_X(osdConfig()->item_pos[item]);
uint8_t elemPosY = OSD_Y(osdConfig()->item_pos[item]);
char buff[OSD_ELEMENT_BUFFER_LENGTH] = "";
@ -1208,7 +1245,7 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
}
// Always enable warnings elements by default
osdConfig->item_pos[OSD_WARNINGS] = OSD_POS(9, 10) | VISIBLE_FLAG;
osdConfig->item_pos[OSD_WARNINGS] = OSD_POS(9, 10) | OSD_PROFILE_1_FLAG;
// Default to old fixed positions for these elements
osdConfig->item_pos[OSD_CROSSHAIRS] = OSD_POS(13, 6);
@ -1246,6 +1283,8 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
osdConfig->ahMaxPitch = 20; // 20 degrees
osdConfig->ahMaxRoll = 40; // 40 degrees
osdConfig->osdProfileIndex = 1;
osdConfig->ahInvert = false;
}
@ -1301,6 +1340,9 @@ void osdInit(displayPort_t *osdDisplayPortToUse)
displayResync(osdDisplayPort);
resumeRefreshAt = micros() + (4 * REFRESH_1S);
#ifdef USE_OSD_PROFILES
changeOsdProfileIndex(osdConfig()->osdProfileIndex);
#endif
}
bool osdInitialized(void)