1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 04:45:24 +03:00

Add OSD profile names feature (#8272)

Add OSD profile names feature
This commit is contained in:
Michael Keller 2019-05-25 12:29:41 +12:00 committed by GitHub
commit ef79a36fd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 2 deletions

View file

@ -1253,6 +1253,10 @@ const clivalue_t valueTable[] = {
{ "osd_pid_profile_name_pos", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_PID_PROFILE_NAME]) }, { "osd_pid_profile_name_pos", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_PID_PROFILE_NAME]) },
#endif #endif
#ifdef USE_OSD_PROFILES
{ "osd_profile_name_pos", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_PROFILE_NAME]) },
#endif
// OSD stats enabled flags are stored as bitmapped values inside a 32bit parameter // OSD stats enabled flags are stored as bitmapped values inside a 32bit parameter
// It is recommended to keep the settings order the same as the enumeration. This way the settings are displayed in the cli in the same order making it easier on the users // It is recommended to keep the settings order the same as the enumeration. This way the settings are displayed in the cli in the same order making it easier on the users
{ "osd_stat_rtc_date_time", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_RTC_DATE_TIME, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)}, { "osd_stat_rtc_date_time", VAR_UINT32 | MASTER_VALUE | MODE_BITSET, .config.bitpos = OSD_STAT_RTC_DATE_TIME, PG_OSD_CONFIG, offsetof(osdConfig_t, enabled_stats)},
@ -1288,6 +1292,9 @@ const clivalue_t valueTable[] = {
#ifdef USE_OSD_PROFILES #ifdef USE_OSD_PROFILES
{ "osd_profile", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 1, OSD_PROFILE_COUNT }, PG_OSD_CONFIG, offsetof(osdConfig_t, osdProfileIndex) }, { "osd_profile", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 1, OSD_PROFILE_COUNT }, PG_OSD_CONFIG, offsetof(osdConfig_t, osdProfileIndex) },
{ "osd_profile_1_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, OSD_PROFILE_NAME_LENGTH, STRING_FLAGS_NONE }, PG_OSD_CONFIG, offsetof(osdConfig_t, profile[0]) },
{ "osd_profile_2_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, OSD_PROFILE_NAME_LENGTH, STRING_FLAGS_NONE }, PG_OSD_CONFIG, offsetof(osdConfig_t, profile[1]) },
{ "osd_profile_3_name", VAR_UINT8 | MASTER_VALUE | MODE_STRING, .config.string = { 1, OSD_PROFILE_NAME_LENGTH, STRING_FLAGS_NONE }, PG_OSD_CONFIG, offsetof(osdConfig_t, profile[2]) },
#endif #endif
#endif #endif

View file

@ -120,6 +120,9 @@ const OSD_Entry menuOsdActiveElemsEntries[] =
#ifdef USE_PROFILE_NAMES #ifdef USE_PROFILE_NAMES
{"PID PROFILE NAME", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_PID_PROFILE_NAME], DYNAMIC}, {"PID PROFILE NAME", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_PID_PROFILE_NAME], DYNAMIC},
{"RATE PROFILE NAME", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_RATE_PROFILE_NAME], DYNAMIC}, {"RATE PROFILE NAME", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_RATE_PROFILE_NAME], DYNAMIC},
#endif
#ifdef USE_OSD_PROFILES
{"OSD PROFILE NAME", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_PROFILE_NAME], DYNAMIC},
#endif #endif
{"DEBUG", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_DEBUG], DYNAMIC}, {"DEBUG", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_DEBUG], DYNAMIC},
{"WARNINGS", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_WARNINGS], DYNAMIC}, {"WARNINGS", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_WARNINGS], DYNAMIC},

View file

@ -128,7 +128,7 @@ static uint8_t osdStatsRowCount = 0;
escSensorData_t *osdEscDataCombined; escSensorData_t *osdEscDataCombined;
#endif #endif
PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 5); PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 6);
void osdStatSetState(uint8_t statIndex, bool enabled) void osdStatSetState(uint8_t statIndex, bool enabled)
{ {
@ -265,6 +265,9 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
osdConfig->osdProfileIndex = 1; osdConfig->osdProfileIndex = 1;
osdConfig->ahInvert = false; osdConfig->ahInvert = false;
for (int i=0; i < OSD_PROFILE_COUNT; i++) {
osdConfig->profile[i][0] = '\0';
}
osdConfig->rssi_dbm_alarm = 60; osdConfig->rssi_dbm_alarm = 60;
} }

View file

@ -31,6 +31,8 @@ extern const char * const osdTimerSourceNames[OSD_NUM_TIMER_TYPES];
#define OSD_ELEMENT_BUFFER_LENGTH 32 #define OSD_ELEMENT_BUFFER_LENGTH 32
#define OSD_PROFILE_NAME_LENGTH 16
#ifdef USE_OSD_PROFILES #ifdef USE_OSD_PROFILES
#define OSD_PROFILE_COUNT 3 #define OSD_PROFILE_COUNT 3
#else #else
@ -128,6 +130,7 @@ typedef enum {
OSD_ESC_RPM_FREQ, OSD_ESC_RPM_FREQ,
OSD_RATE_PROFILE_NAME, OSD_RATE_PROFILE_NAME,
OSD_PID_PROFILE_NAME, OSD_PID_PROFILE_NAME,
OSD_PROFILE_NAME,
OSD_RSSI_DBM_VALUE, OSD_RSSI_DBM_VALUE,
OSD_ITEM_COUNT // MUST BE LAST OSD_ITEM_COUNT // MUST BE LAST
} osd_items_e; } osd_items_e;
@ -252,6 +255,7 @@ typedef struct osdConfig_s {
uint8_t ahInvert; // invert the artificial horizon uint8_t ahInvert; // invert the artificial horizon
uint8_t osdProfileIndex; uint8_t osdProfileIndex;
uint8_t overlay_radio_mode; uint8_t overlay_radio_mode;
char profile[OSD_PROFILE_COUNT][OSD_PROFILE_NAME_LENGTH + 1];
uint16_t link_quality_alarm; uint16_t link_quality_alarm;
uint8_t rssi_dbm_alarm; uint8_t rssi_dbm_alarm;
} osdConfig_t; } osdConfig_t;

View file

@ -690,6 +690,27 @@ static void osdElementPidProfileName(osdElementParms_t *element)
} }
#endif #endif
#ifdef USE_OSD_PROFILES
static void osdElementOsdProfileName(osdElementParms_t *element)
{
uint8_t profileIndex = getCurrentOsdProfileIndex();
if (strlen(osdConfig()->profile[profileIndex - 1]) == 0) {
tfp_sprintf(element->buff, "OSD_%u", profileIndex);
} else {
unsigned i;
for (i = 0; i < OSD_PROFILE_NAME_LENGTH; i++) {
if (osdConfig()->profile[profileIndex - 1][i]) {
element->buff[i] = toupper((unsigned char)osdConfig()->profile[profileIndex - 1][i]);
} else {
break;
}
}
element->buff[i] = '\0';
}
}
#endif
#ifdef USE_ESC_SENSOR #ifdef USE_ESC_SENSOR
static void osdElementEscTemperature(osdElementParms_t *element) static void osdElementEscTemperature(osdElementParms_t *element)
{ {
@ -1401,6 +1422,10 @@ static const uint8_t osdElementDisplayOrder[] = {
OSD_RATE_PROFILE_NAME, OSD_RATE_PROFILE_NAME,
OSD_PID_PROFILE_NAME, OSD_PID_PROFILE_NAME,
#endif #endif
#ifdef USE_OSD_PROFILES
OSD_PROFILE_NAME,
#endif
}; };
// Define the mapping between the OSD element id and the function to draw it // Define the mapping between the OSD element id and the function to draw it
@ -1500,10 +1525,12 @@ const osdElementDrawFn osdElementDrawFunction[OSD_ITEM_COUNT] = {
[OSD_RATE_PROFILE_NAME] = osdElementRateProfileName, [OSD_RATE_PROFILE_NAME] = osdElementRateProfileName,
[OSD_PID_PROFILE_NAME] = osdElementPidProfileName, [OSD_PID_PROFILE_NAME] = osdElementPidProfileName,
#endif #endif
#ifdef USE_OSD_PROFILES
[OSD_PROFILE_NAME] = osdElementOsdProfileName,
#endif
#ifdef USE_RX_RSSI_DBM #ifdef USE_RX_RSSI_DBM
[OSD_RSSI_DBM_VALUE] = osdElementRssiDbm, [OSD_RSSI_DBM_VALUE] = osdElementRssiDbm,
#endif #endif
}; };
static void osdAddActiveElement(osd_items_e element) static void osdAddActiveElement(osd_items_e element)