mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +03:00
Add OSD element for Aux channel value
This commit is contained in:
parent
7c89b857ad
commit
0652767f1c
5 changed files with 29 additions and 0 deletions
|
@ -1413,6 +1413,7 @@ const clivalue_t valueTable[] = {
|
|||
{ "osd_camera_frame_pos", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, OSD_POSCFG_MAX }, PG_OSD_ELEMENT_CONFIG, offsetof(osdElementConfig_t, item_pos[OSD_CAMERA_FRAME]) },
|
||||
{ "osd_efficiency_pos", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, OSD_POSCFG_MAX }, PG_OSD_ELEMENT_CONFIG, offsetof(osdElementConfig_t, item_pos[OSD_EFFICIENCY]) },
|
||||
{ "osd_total_flights_pos", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, OSD_POSCFG_MAX }, PG_OSD_ELEMENT_CONFIG, offsetof(osdElementConfig_t, item_pos[OSD_TOTAL_FLIGHTS]) },
|
||||
{ "osd_aux_pos", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, OSD_POSCFG_MAX }, PG_OSD_ELEMENT_CONFIG, offsetof(osdElementConfig_t, item_pos[OSD_AUX_VALUE]) },
|
||||
|
||||
// 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
|
||||
|
@ -1462,6 +1463,9 @@ const clivalue_t valueTable[] = {
|
|||
{ "osd_stat_avg_cell_value", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, stat_show_cell_value) },
|
||||
{ "osd_task_frequency", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { OSD_TASK_FREQUENCY_MIN, OSD_TASK_FREQUENCY_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, task_frequency) },
|
||||
{ "osd_menu_background", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_CMS_BACKGROUND }, PG_OSD_CONFIG, offsetof(osdConfig_t, cms_background_type) },
|
||||
{ "osd_aux_channel", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 1, MAX_SUPPORTED_RC_CHANNEL_COUNT }, PG_OSD_CONFIG, offsetof(osdConfig_t, aux_channel) },
|
||||
{ "osd_aux_scale", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 1, 1000 }, PG_OSD_CONFIG, offsetof(osdConfig_t, aux_scale) },
|
||||
{ "osd_aux_symbol", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 255 }, PG_OSD_CONFIG, offsetof(osdConfig_t, aux_symbol) },
|
||||
#endif // end of #ifdef USE_OSD
|
||||
|
||||
// PG_SYSTEM_CONFIG
|
||||
|
|
|
@ -165,6 +165,7 @@ const OSD_Entry menuOsdActiveElemsEntries[] =
|
|||
{"RC CHANNELS", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_RC_CHANNELS], DYNAMIC},
|
||||
{"CAMERA FRAME", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_CAMERA_FRAME], DYNAMIC},
|
||||
{"TOTAL FLIGHTS", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_TOTAL_FLIGHTS], DYNAMIC},
|
||||
{"AUX VALUE", OME_VISIBLE, NULL, &osdConfig_item_pos[OSD_AUX_VALUE], DYNAMIC},
|
||||
{"BACK", OME_Back, NULL, NULL, 0},
|
||||
{NULL, OME_END, NULL, NULL, 0}
|
||||
};
|
||||
|
|
|
@ -119,6 +119,7 @@ timeUs_t osdFlyTime = 0;
|
|||
#if defined(USE_ACC)
|
||||
float osdGForce = 0;
|
||||
#endif
|
||||
uint16_t osdAuxValue = 0;
|
||||
|
||||
static bool showVisualBeeper = false;
|
||||
|
||||
|
@ -382,6 +383,10 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
|||
osdConfig->stat_show_cell_value = false;
|
||||
osdConfig->task_frequency = OSD_TASK_FREQUENCY_DEFAULT;
|
||||
osdConfig->cms_background_type = DISPLAY_BACKGROUND_TRANSPARENT;
|
||||
|
||||
osdConfig->aux_channel = 0;
|
||||
osdConfig->aux_scale = 200;
|
||||
osdConfig->aux_symbol = 'A';
|
||||
}
|
||||
|
||||
void pgResetFn_osdElementConfig(osdElementConfig_t *osdElementConfig)
|
||||
|
@ -940,6 +945,7 @@ STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
|
|||
static bool osdStatsEnabled = false;
|
||||
static bool osdStatsVisible = false;
|
||||
static timeUs_t osdStatsRefreshTimeUs;
|
||||
static timeUs_t osdAuxRefreshTimeUs = 0;
|
||||
|
||||
// detect arm/disarm
|
||||
if (armState != ARMING_FLAG(ARMED)) {
|
||||
|
@ -1026,6 +1032,12 @@ STATIC_UNIT_TESTED void osdRefresh(timeUs_t currentTimeUs)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (VISIBLE(osdElementConfig()->item_pos[OSD_AUX_VALUE])) {
|
||||
if (currentTimeUs > osdAuxRefreshTimeUs) {
|
||||
osdAuxValue = (constrain(rcData[osdConfig()->aux_channel - 1], PWM_RANGE_MIN, PWM_RANGE_MAX) - PWM_RANGE_MIN) * osdConfig()->aux_scale / (PWM_RANGE_MAX - PWM_RANGE_MIN);
|
||||
osdAuxRefreshTimeUs = currentTimeUs + REFRESH_1S;
|
||||
}
|
||||
}
|
||||
#ifdef USE_CMS
|
||||
if (!displayIsGrabbed(osdDisplayPort))
|
||||
#endif
|
||||
|
|
|
@ -161,6 +161,7 @@ typedef enum {
|
|||
OSD_TOTAL_FLIGHTS,
|
||||
OSD_UP_DOWN_REFERENCE,
|
||||
OSD_TX_UPLINK_POWER,
|
||||
OSD_AUX_VALUE,
|
||||
OSD_ITEM_COUNT // MUST BE LAST
|
||||
} osd_items_e;
|
||||
|
||||
|
@ -303,6 +304,9 @@ typedef struct osdConfig_s {
|
|||
uint16_t task_frequency;
|
||||
uint8_t cms_background_type; // For supporting devices, determines whether the CMS background is transparent or opaque
|
||||
uint8_t stat_show_cell_value;
|
||||
uint8_t aux_channel;
|
||||
uint16_t aux_scale;
|
||||
uint8_t aux_symbol;
|
||||
} osdConfig_t;
|
||||
|
||||
PG_DECLARE(osdConfig_t, osdConfig);
|
||||
|
@ -337,6 +341,7 @@ extern float osdGForce;
|
|||
#ifdef USE_ESC_SENSOR
|
||||
extern escSensorData_t *osdEscDataCombined;
|
||||
#endif
|
||||
extern uint16_t osdAuxValue;
|
||||
|
||||
void osdInit(displayPort_t *osdDisplayPort, osdDisplayPortDevice_e displayPortDevice);
|
||||
void osdUpdate(timeUs_t currentTimeUs);
|
||||
|
|
|
@ -1463,6 +1463,11 @@ static void osdElementVtxChannel(osdElementParms_t *element)
|
|||
}
|
||||
#endif // USE_VTX_COMMON
|
||||
|
||||
static void osdElementAuxValue(osdElementParms_t *element)
|
||||
{
|
||||
tfp_sprintf(element->buff, "%c%d", osdConfig()->aux_symbol, osdAuxValue);
|
||||
}
|
||||
|
||||
static void osdElementWarnings(osdElementParms_t *element)
|
||||
{
|
||||
bool elementBlinking = false;
|
||||
|
@ -1556,6 +1561,7 @@ static const uint8_t osdElementDisplayOrder[] = {
|
|||
#ifdef USE_PERSISTENT_STATS
|
||||
OSD_TOTAL_FLIGHTS,
|
||||
#endif
|
||||
OSD_AUX_VALUE,
|
||||
};
|
||||
|
||||
// Define the mapping between the OSD element id and the function to draw it
|
||||
|
@ -1673,6 +1679,7 @@ const osdElementDrawFn osdElementDrawFunction[OSD_ITEM_COUNT] = {
|
|||
#ifdef USE_PERSISTENT_STATS
|
||||
[OSD_TOTAL_FLIGHTS] = osdElementTotalFlights,
|
||||
#endif
|
||||
[OSD_AUX_VALUE] = osdElementAuxValue,
|
||||
};
|
||||
|
||||
// Define the mapping between the OSD element id and the function to draw its background (static part)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue