mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 04:45:24 +03:00
Add RC channel values to OSD
This commit is contained in:
parent
37b059532f
commit
d4b4e37f6f
4 changed files with 34 additions and 1 deletions
|
@ -1294,6 +1294,8 @@ const clivalue_t valueTable[] = {
|
|||
{ "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_rcchannels_pos", VAR_UINT16 | MASTER_VALUE, .config.minmaxUnsigned = { 0, OSD_POSCFG_MAX }, PG_OSD_CONFIG, offsetof(osdConfig_t, item_pos[OSD_RC_CHANNELS]) },
|
||||
|
||||
// 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
|
||||
{ "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)},
|
||||
|
@ -1336,6 +1338,8 @@ const clivalue_t valueTable[] = {
|
|||
{ "osd_gps_sats_show_hdop", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_OSD_CONFIG, offsetof(osdConfig_t, gps_sats_show_hdop) },
|
||||
#endif
|
||||
|
||||
{ "osd_rcchannels", VAR_INT8 | MASTER_VALUE | MODE_ARRAY, .config.array.length = OSD_RCCHANNELS_COUNT, PG_OSD_CONFIG, offsetof(osdConfig_t, rcChannels) },
|
||||
|
||||
// PG_SYSTEM_CONFIG
|
||||
#if defined(STM32F4)
|
||||
{ "system_hse_mhz", VAR_UINT8 | HARDWARE_VALUE, .config.minmaxUnsigned = { 0, 30 }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, hseMhz) },
|
||||
|
|
|
@ -303,6 +303,10 @@ void pgResetFn_osdConfig(osdConfig_t *osdConfig)
|
|||
}
|
||||
osdConfig->rssi_dbm_alarm = 60;
|
||||
osdConfig->gps_sats_show_hdop = false;
|
||||
|
||||
for (int i = 0; i < OSD_RCCHANNELS_COUNT; i++) {
|
||||
osdConfig->rcChannels[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void osdDrawLogo(int x, int y)
|
||||
|
|
|
@ -39,6 +39,8 @@ extern const char * const osdTimerSourceNames[OSD_NUM_TIMER_TYPES];
|
|||
#define OSD_PROFILE_COUNT 1
|
||||
#endif
|
||||
|
||||
#define OSD_RCCHANNELS_COUNT 4
|
||||
|
||||
#define OSD_PROFILE_BITS_POS 11
|
||||
#define OSD_PROFILE_MASK (((1 << OSD_PROFILE_COUNT) - 1) << OSD_PROFILE_BITS_POS)
|
||||
#define OSD_POS_MAX 0x3FF
|
||||
|
@ -132,6 +134,7 @@ typedef enum {
|
|||
OSD_PID_PROFILE_NAME,
|
||||
OSD_PROFILE_NAME,
|
||||
OSD_RSSI_DBM_VALUE,
|
||||
OSD_RC_CHANNELS,
|
||||
OSD_ITEM_COUNT // MUST BE LAST
|
||||
} osd_items_e;
|
||||
|
||||
|
@ -258,6 +261,7 @@ typedef struct osdConfig_s {
|
|||
uint16_t link_quality_alarm;
|
||||
uint8_t rssi_dbm_alarm;
|
||||
uint8_t gps_sats_show_hdop;
|
||||
int8_t rcChannels[OSD_RCCHANNELS_COUNT]; // RC channel values to display, -1 if none
|
||||
} osdConfig_t;
|
||||
|
||||
PG_DECLARE(osdConfig_t, osdConfig);
|
||||
|
|
|
@ -1017,6 +1017,26 @@ static void osdElementPower(osdElementParms_t *element)
|
|||
tfp_sprintf(element->buff, "%4dW", getAmperage() * getBatteryVoltage() / 10000);
|
||||
}
|
||||
|
||||
static void osdElementRcChannels(osdElementParms_t *element)
|
||||
{
|
||||
const uint8_t xpos = element->elemPosX;
|
||||
const uint8_t ypos = element->elemPosY;
|
||||
|
||||
for (int i = 0; i < OSD_RCCHANNELS_COUNT; i++) {
|
||||
if (osdConfig()->rcChannels[i] >= 0) {
|
||||
// Translate (1000, 2000) to (-1000, 1000)
|
||||
int data = scaleRange(rcData[osdConfig()->rcChannels[i]], PWM_RANGE_MIN, PWM_RANGE_MAX, -1000, 1000);
|
||||
// Opt for the simplest formatting for now.
|
||||
// Decimal notation can be added when tfp_sprintf supports float among fancy options.
|
||||
char fmtbuf[6];
|
||||
tfp_sprintf(fmtbuf, "%5d", data);
|
||||
displayWrite(element->osdDisplayPort, xpos, ypos + i, fmtbuf);
|
||||
}
|
||||
}
|
||||
|
||||
element->drawElement = false; // element already drawn
|
||||
}
|
||||
|
||||
static void osdElementRemainingTimeEstimate(osdElementParms_t *element)
|
||||
{
|
||||
const int mAhDrawn = getMAhDrawn();
|
||||
|
@ -1457,7 +1477,7 @@ static const uint8_t osdElementDisplayOrder[] = {
|
|||
#ifdef USE_OSD_PROFILES
|
||||
OSD_PROFILE_NAME,
|
||||
#endif
|
||||
|
||||
OSD_RC_CHANNELS,
|
||||
};
|
||||
|
||||
// Define the mapping between the OSD element id and the function to draw it
|
||||
|
@ -1563,6 +1583,7 @@ const osdElementDrawFn osdElementDrawFunction[OSD_ITEM_COUNT] = {
|
|||
#ifdef USE_RX_RSSI_DBM
|
||||
[OSD_RSSI_DBM_VALUE] = osdElementRssiDbm,
|
||||
#endif
|
||||
[OSD_RC_CHANNELS] = osdElementRcChannels,
|
||||
};
|
||||
|
||||
static void osdAddActiveElement(osd_items_e element)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue