Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_OSD: Add CRSF link stats display fields #25844

Merged
merged 4 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Tools/scripts/build_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def __init__(self,
Feature('OSD', 'PLUSCODE', 'HAL_PLUSCODE_ENABLE', 'Enable PlusCode', 0, 'OSD'),
Feature('OSD', 'OSD_PARAM', 'OSD_PARAM_ENABLED', 'Enable OSD param', 0, 'OSD'),
Feature('OSD', 'OSD_SIDEBARS', 'HAL_OSD_SIDEBAR_ENABLE', 'Enable Scrolling Sidebars', 0, 'OSD'),
Feature('OSD', 'OSD_EXTENDED_LINK_STATS', 'AP_OSD_LINK_STATS_EXTENSIONS_ENABLED', 'Enable OSD panels with extended link stats data', 0, "OSD,RC_CRSF"), # noqa

Feature('VTX', 'VIDEO_TX', 'AP_VIDEOTX_ENABLED', 'Enable VideoTX control', 0, None),
Feature('VTX', 'SMARTAUDIO', 'AP_SMARTAUDIO_ENABLED', 'Enable SmartAudio VTX Contol', 0, "VIDEO_TX"),
Expand Down
1 change: 1 addition & 0 deletions Tools/scripts/extract_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ def __init__(self, filename, nm="arm-none-eabi-nm", strings="strings"):
('AP_COMPASS_CALIBRATION_FIXED_YAW_ENABLED', 'AP_Compass::mag_cal_fixed_yaw'),
('COMPASS_LEARN_ENABLED', 'CompassLearn::update'),
('AP_CUSTOMROTATIONS_ENABLED', 'AP_CustomRotation::init'),
('AP_OSD_LINK_STATS_EXTENSIONS_ENABLED', r'AP_OSD_Screen::draw_rc_tx_power'),
]

def progress(self, msg):
Expand Down
24 changes: 20 additions & 4 deletions libraries/AP_OSD/AP_OSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const AP_Param::GroupInfo AP_OSD::var_info[] = {
// @Param: _OPTIONS
// @DisplayName: OSD Options
// @Description: This sets options that change the display
// @Bitmask: 0:UseDecimalPack, 1:InvertedWindArrow, 2:InvertedAHRoll, 3:Convert feet to miles at 5280ft instead of 10000ft, 4:DisableCrosshair, 5:TranslateArrows, 6:AviationStyleAH
// @Bitmask: 0:UseDecimalPack, 1:InvertedWindArrow, 2:InvertedAHRoll, 3:Convert feet to miles at 5280ft instead of 10000ft, 4:DisableCrosshair, 5:TranslateArrows, 6:AviationStyleAH, 7:Prefix LQ with RF Mode
// @User: Standard
AP_GROUPINFO("_OPTIONS", 8, AP_OSD, options, OPTION_DECIMAL_PACK),

Expand Down Expand Up @@ -114,10 +114,10 @@ const AP_Param::GroupInfo AP_OSD::var_info[] = {

// @Param: _W_RSSI
// @DisplayName: RSSI warn level (in %)
// @Description: Set level at which RSSI item will flash
// @Range: 0 99
// @Description: Set level at which RSSI item will flash (in positive % or negative dBm values as applicable). 30% or -100dBm are defaults.
// @Range: -128 100
// @User: Standard
AP_GROUPINFO("_W_RSSI", 12, AP_OSD, warn_rssi, 30),
AP_GROUPINFO("_W_RSSI", 12, AP_OSD, warn_rssi, AP_OSD_WARN_RSSI_DEFAULT),

// @Param: _W_NSAT
// @DisplayName: NSAT warn level
Expand Down Expand Up @@ -214,6 +214,22 @@ const AP_Param::GroupInfo AP_OSD::var_info[] = {
// @User: Standard
AP_GROUPINFO("_W_ACRVOLT", 31, AP_OSD, warn_avgcellrestvolt, 3.6f),

#if AP_OSD_EXTENDED_LNK_STATS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#if AP_OSD_EXTENDED_LNK_STATS
#if AP_OSD_EXTENDED_LNK_STATS_ENABLED

We'll make this change in a future PR....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean you think this is a typo or you'd rather have the define renamed?

// @Param: _W_LQ
// @DisplayName: RC link quality warn level (in %)
// @Description: Set level at which RC_LQ item will flash (%)
// @Range: 0 100
// @User: Standard
AP_GROUPINFO("_W_LQ", 33, AP_OSD, warn_lq, 50),

// @Param: _W_SNR
// @DisplayName: RC link SNR warn level (in %)
// @Description: Set level at which RC_SNR item will flash (in db)
// @Range: -20 10
// @User: Standard
AP_GROUPINFO("_W_SNR", 34, AP_OSD, warn_snr, 0),
#endif

#endif //osd enabled
#if OSD_PARAM_ENABLED
// @Group: 5_
Expand Down
39 changes: 38 additions & 1 deletion libraries/AP_OSD/AP_OSD.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,18 @@ class AP_MSP;
#define PARAM_INDEX(key, idx, group) (uint32_t(uint32_t(key) << 23 | uint32_t(idx) << 18 | uint32_t(group)))
#define PARAM_TOKEN_INDEX(token) PARAM_INDEX(AP_Param::get_persistent_key(token.key), token.idx, token.group_element)

#define AP_OSD_NUM_SYMBOLS 91
#define AP_OSD_NUM_SYMBOLS 107
#define OSD_MAX_INSTANCES 2

#if AP_OSD_LINK_STATS_EXTENSIONS_ENABLED
// For the moment, these extra panels only work with CRSF protocol based RC systems
#define AP_OSD_EXTENDED_LNK_STATS 1
#define AP_OSD_WARN_RSSI_DEFAULT -100 // Default value for OSD RSSI panel warning, in dbm
#else
#define AP_OSD_EXTENDED_LNK_STATS 0
#define AP_OSD_WARN_RSSI_DEFAULT 30 // Default value for OSD RSSI panel warning, in %
#endif

/*
class to hold one setting
*/
Expand Down Expand Up @@ -226,6 +236,15 @@ class AP_OSD_Screen : public AP_OSD_AbstractScreen
#endif
AP_OSD_Setting sidebars{false, 4, 5};

#if AP_OSD_EXTENDED_LNK_STATS
// Extended link stats data panels
AP_OSD_Setting rc_tx_power{false, 25, 12};
AP_OSD_Setting rc_rssi_dbm{false, 6, 2};
AP_OSD_Setting rc_snr{false, 23, 13};
AP_OSD_Setting rc_active_antenna{false, 27, 13};
AP_OSD_Setting rc_lq{false, 18, 2};
#endif

// MSP OSD only
AP_OSD_Setting crosshair;
AP_OSD_Setting home_dist{true, 1, 1};
Expand Down Expand Up @@ -314,6 +333,16 @@ class AP_OSD_Screen : public AP_OSD_AbstractScreen
#endif
void draw_rngf(uint8_t x, uint8_t y);

#if AP_OSD_EXTENDED_LNK_STATS
// Extended link stats data panels
bool is_btfl_fonts();
void draw_rc_tx_power(uint8_t x, uint8_t y);
void draw_rc_rssi_dbm(uint8_t x, uint8_t y);
void draw_rc_snr(uint8_t x, uint8_t y);
void draw_rc_active_antenna(uint8_t x, uint8_t y);
void draw_rc_lq(uint8_t x, uint8_t y);
#endif

struct {
bool load_attempted;
const char *str;
Expand Down Expand Up @@ -557,6 +586,11 @@ class AP_OSD
AP_Int8 failsafe_scr;
AP_Int32 button_delay_ms;

#if AP_OSD_EXTENDED_LNK_STATS
AP_Int8 warn_lq;
AP_Int8 warn_snr;
#endif

enum {
OPTION_DECIMAL_PACK = 1U<<0,
OPTION_INVERTED_WIND = 1U<<1,
Expand All @@ -565,6 +599,9 @@ class AP_OSD
OPTION_DISABLE_CROSSHAIR = 1U<<4,
OPTION_BF_ARROWS = 1U<<5,
OPTION_AVIATION_AH = 1U<<6,
#if AP_OSD_EXTENDED_LNK_STATS
OPTION_RF_MODE_ALONG_WITH_LQ = 1U<<7,
#endif
};

enum {
Expand Down
32 changes: 32 additions & 0 deletions libraries/AP_OSD/AP_OSD_Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,22 @@ class AP_OSD_Backend
static const uint8_t SYM_FENCE_DISABLED = 0xF6;
static const uint8_t SYM_RNGFD = 0xF7;
static const uint8_t SYM_LQ = 0xF8;
static const uint8_t SYM_WATT = 0xAE;
static const uint8_t SYM_WH = 0xAB;
static const uint8_t SYM_DB = 0xF9;
static const uint8_t SYM_DBM = 0xFA;
static const uint8_t SYM_SNR = 0xFB;
static const uint8_t SYM_ANT = 0xFC;
static const uint8_t SYM_ARROW_RIGHT = 0xFD;
static const uint8_t SYM_ARROW_LEFT = 0xFE;
static const uint8_t SYM_G = 0xDF;
static const uint8_t SYM_BATT_UNKNOWN = 0x97;
static const uint8_t SYM_ROLL = 0xA9;
static const uint8_t SYM_PITCH = 0xAF;
static const uint8_t SYM_DPS = 0xAA;
static const uint8_t SYM_HEADING = 0x89;
static const uint8_t SYM_RADIUS = 0x7A;
static const uint8_t SYM_FLAP = 0x23;

static const uint8_t SYM_SIDEBAR_R_ARROW = 0x09;
static const uint8_t SYM_SIDEBAR_L_ARROW = 0x0A;
Expand Down Expand Up @@ -290,5 +306,21 @@ class AP_OSD_Backend
SYM_SIDEBAR_H,
SYM_SIDEBAR_I,
SYM_SIDEBAR_J,
SYM_WATT,
SYM_WH,
SYM_DB,
SYM_DBM,
SYM_SNR,
SYM_ANT,
SYM_ARROW_RIGHT,
SYM_ARROW_LEFT,
SYM_G,
SYM_BATT_UNKNOWN,
SYM_ROLL,
SYM_PITCH,
SYM_DPS,
SYM_HEADING,
SYM_RADIUS,
SYM_FLAP,
};
};
Loading
Loading