mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Merge pull request #10789 from alexeystn/osd_aux_channel
Add AUX channel value to OSD (e.g. for Pilot's Heart Rate)
This commit is contained in:
commit
ec32baa955
5 changed files with 33 additions and 2 deletions
|
@ -1424,6 +1424,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
|
||||
|
@ -1444,6 +1445,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_framerate_hz", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { OSD_FRAMERATE_MIN_HZ, OSD_FRAMERATE_MAX_HZ }, PG_OSD_CONFIG, offsetof(osdConfig_t, framerate_hz) },
|
||||
{ "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
|
||||
|
||||
#ifdef USE_CRAFTNAME_MSGS
|
||||
|
|
|
@ -165,6 +165,7 @@ const OSD_Entry menuOsdActiveElemsEntries[] =
|
|||
{"RC CHANNELS", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_RC_CHANNELS]},
|
||||
{"CAMERA FRAME", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_CAMERA_FRAME]},
|
||||
{"TOTAL FLIGHTS", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_TOTAL_FLIGHTS]},
|
||||
{"AUX VALUE", OME_VISIBLE | DYNAMIC, NULL, &osdConfig_item_pos[OSD_AUX_VALUE]},
|
||||
{"BACK", OME_Back, NULL, NULL},
|
||||
{NULL, OME_END, NULL, NULL}
|
||||
};
|
||||
|
|
|
@ -123,6 +123,7 @@ timeUs_t osdFlyTime = 0;
|
|||
#if defined(USE_ACC)
|
||||
float osdGForce = 0;
|
||||
#endif
|
||||
uint16_t osdAuxValue = 0;
|
||||
|
||||
static bool showVisualBeeper = false;
|
||||
|
||||
|
@ -148,9 +149,9 @@ escSensorData_t *osdEscDataCombined;
|
|||
|
||||
STATIC_ASSERT(OSD_POS_MAX == OSD_POS(31,31), OSD_POS_MAX_incorrect);
|
||||
|
||||
PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 9);
|
||||
PG_REGISTER_WITH_RESET_FN(osdConfig_t, osdConfig, PG_OSD_CONFIG, 10);
|
||||
|
||||
PG_REGISTER_WITH_RESET_FN(osdElementConfig_t, osdElementConfig, PG_OSD_ELEMENT_CONFIG, 0);
|
||||
PG_REGISTER_WITH_RESET_FN(osdElementConfig_t, osdElementConfig, PG_OSD_ELEMENT_CONFIG, 1);
|
||||
|
||||
// Controls the display order of the OSD post-flight statistics.
|
||||
// Adjust the ordering here to control how the post-flight stats are presented.
|
||||
|
@ -390,6 +391,10 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
|||
#ifdef USE_CRAFTNAME_MSGS
|
||||
osdConfig->osd_craftname_msgs = false; // Insert LQ/RSSI-dBm and warnings into CraftName
|
||||
#endif //USE_CRAFTNAME_MSGS
|
||||
|
||||
osdConfig->aux_channel = 0;
|
||||
osdConfig->aux_scale = 200;
|
||||
osdConfig->aux_symbol = 'A';
|
||||
}
|
||||
|
||||
void pgResetFn_osdElementConfig(osdElementConfig_t *osdElementConfig)
|
||||
|
@ -1058,6 +1063,7 @@ STATIC_UNIT_TESTED bool osdProcessStats1(timeUs_t currentTimeUs)
|
|||
{
|
||||
static timeUs_t lastTimeUs = 0;
|
||||
static timeUs_t osdStatsRefreshTimeUs;
|
||||
static timeUs_t osdAuxRefreshTimeUs = 0;
|
||||
|
||||
bool refreshStatsRequired = false;
|
||||
|
||||
|
@ -1108,6 +1114,14 @@ STATIC_UNIT_TESTED bool osdProcessStats1(timeUs_t currentTimeUs)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
lastTimeUs = currentTimeUs;
|
||||
|
||||
return refreshStatsRequired;
|
||||
|
|
|
@ -162,6 +162,7 @@ typedef enum {
|
|||
OSD_UP_DOWN_REFERENCE,
|
||||
OSD_TX_UPLINK_POWER,
|
||||
OSD_WATT_HOURS_DRAWN,
|
||||
OSD_AUX_VALUE,
|
||||
OSD_ITEM_COUNT // MUST BE LAST
|
||||
} osd_items_e;
|
||||
|
||||
|
@ -308,6 +309,9 @@ typedef struct osdConfig_s {
|
|||
#ifdef USE_CRAFTNAME_MSGS
|
||||
uint8_t osd_craftname_msgs; // Insert LQ/RSSI-dBm and warnings into CraftName
|
||||
#endif //USE_CRAFTNAME_MSGS
|
||||
uint8_t aux_channel;
|
||||
uint16_t aux_scale;
|
||||
uint8_t aux_symbol;
|
||||
} osdConfig_t;
|
||||
|
||||
PG_DECLARE(osdConfig_t, osdConfig);
|
||||
|
@ -343,6 +347,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);
|
||||
bool osdUpdateCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTimeUs);
|
||||
|
|
|
@ -1478,6 +1478,11 @@ switch (element->type) {
|
|||
}
|
||||
#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;
|
||||
|
@ -1601,6 +1606,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
|
||||
|
@ -1717,6 +1723,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