diff --git a/src/main/cms/cms_menu_osd.c b/src/main/cms/cms_menu_osd.c index e99e0cc52f2..0e85d0e656d 100644 --- a/src/main/cms/cms_menu_osd.c +++ b/src/main/cms/cms_menu_osd.c @@ -147,10 +147,10 @@ static const OSD_Entry menuCrsfRxEntries[]= OSD_SETTING_ENTRY("LQ ALARM LEVEL", SETTING_OSD_LINK_QUALITY_ALARM), OSD_SETTING_ENTRY("SNR ALARM LEVEL", SETTING_OSD_SNR_ALARM), OSD_SETTING_ENTRY("RX SENSITIVITY", SETTING_OSD_RSSI_DBM_MIN), - OSD_ELEMENT_ENTRY("RX RSSI DBM", OSD_CRSF_RSSI_DBM), - OSD_ELEMENT_ENTRY("RX LQ", OSD_CRSF_LQ), - OSD_ELEMENT_ENTRY("RX SNR ALARM", OSD_CRSF_SNR_DB), - OSD_ELEMENT_ENTRY("TX POWER", OSD_CRSF_TX_POWER), + OSD_ELEMENT_ENTRY("RX RSSI DBM", OSD_RSSI_DBM), + OSD_ELEMENT_ENTRY("RX LQ", OSD_LQ_UPLINK), + OSD_ELEMENT_ENTRY("RX SNR ALARM", OSD_SNR_DB), + OSD_ELEMENT_ENTRY("TX POWER", OSD_TX_POWER_UPLINK), OSD_BACK_AND_END_ENTRY, }; diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index f7ba8eb7bbd..1960e5dac67 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -3371,35 +3371,35 @@ groups: min: -550 max: 1250 - name: osd_snr_alarm - condition: USE_SERIALRX_CRSF + condition: USE_SERIALRX_CRSF || USE_RX_MSP description: "Value below which Crossfire SNR Alarm pops-up. (dB)" default_value: 4 field: snr_alarm min: -20 max: 99 - name: osd_link_quality_alarm - condition: USE_SERIALRX_CRSF + condition: USE_SERIALRX_CRSF || USE_RX_MSP description: "LQ % indicator blinks below this value. For Crossfire use 70%, for Tracer use 50%" default_value: 70 field: link_quality_alarm min: 0 max: 100 - name: osd_rssi_dbm_alarm - condition: USE_SERIALRX_CRSF + condition: USE_SERIALRX_CRSF || USE_RX_MSP description: "RSSI dBm indicator blinks below this value [dBm]. 0 disables this alarm" default_value: 0 field: rssi_dbm_alarm min: -130 max: 0 - name: osd_rssi_dbm_max - condition: USE_SERIALRX_CRSF + condition: USE_SERIALRX_CRSF || USE_RX_MSP description: "RSSI dBm upper end of curve. Perfect rssi (max) = 100%" default_value: -30 field: rssi_dbm_max min: -50 max: 0 - name: osd_rssi_dbm_min - condition: USE_SERIALRX_CRSF + condition: USE_SERIALRX_CRSF || USE_RX_MSP description: "RSSI dBm lower end of curve or RX sensitivity level. Worst rssi (min) = 0%" default_value: -120 field: rssi_dbm_min diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 2b8b634f001..71081843c78 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -225,7 +225,7 @@ static bool osdDisplayHasCanvas; #define AH_MAX_PITCH_DEFAULT 20 // Specify default maximum AHI pitch value displayed (degrees) PG_REGISTER_WITH_RESET_TEMPLATE(osdConfig_t, osdConfig, PG_OSD_CONFIG, 14); -PG_REGISTER_WITH_RESET_FN(osdLayoutsConfig_t, osdLayoutsConfig, PG_OSD_LAYOUTS_CONFIG, 2); +PG_REGISTER_WITH_RESET_FN(osdLayoutsConfig_t, osdLayoutsConfig, PG_OSD_LAYOUTS_CONFIG, 3); void osdStartedSaveProcess(void) { savingSettings = true; @@ -2463,8 +2463,8 @@ static bool osdDrawSingleElement(uint8_t item) return true; } -#if defined(USE_SERIALRX_CRSF) - case OSD_CRSF_RSSI_DBM: +#if defined(USE_SERIALRX_CRSF) || defined(USE_RX_MSP) + case OSD_RSSI_DBM: { int16_t rssi = rxLinkStatistics.uplinkRSSI; buff[0] = (rxLinkStatistics.activeAntenna == 0) ? SYM_RSSI : SYM_2RSS; // Separate symbols for each antenna @@ -2480,19 +2480,15 @@ static bool osdDrawSingleElement(uint8_t item) } break; } - case OSD_CRSF_LQ: + case OSD_LQ_UPLINK: { buff[0] = SYM_LQ; - int16_t statsLQ = rxLinkStatistics.uplinkLQ; - int16_t scaledLQ = scaleRange(constrain(statsLQ, 0, 100), 0, 100, 170, 300); - switch (osdConfig()->crsf_lq_format) { - case OSD_CRSF_LQ_TYPE1: - if (!failsafeIsReceivingRxData()) { - tfp_sprintf(buff+1, "%3d", 0); - } else { - tfp_sprintf(buff+1, "%3d", rxLinkStatistics.uplinkLQ); - } - break; + uint8_t lqFormat = osdConfig()->crsf_lq_format; + + if (rxConfig()->receiverType == RX_TYPE_MSP) + lqFormat = OSD_CRSF_LQ_TYPE1; + + switch (lqFormat) { case OSD_CRSF_LQ_TYPE2: if (!failsafeIsReceivingRxData()) { tfp_sprintf(buff+1, "%s:%3d", " ", 0); @@ -2504,9 +2500,18 @@ static bool osdDrawSingleElement(uint8_t item) if (!failsafeIsReceivingRxData()) { tfp_sprintf(buff+1, "%3d", 0); } else { + int16_t scaledLQ = scaleRange(constrain(rxLinkStatistics.uplinkLQ, 0, 100), 0, 100, 170, 300); tfp_sprintf(buff+1, "%3d", rxLinkStatistics.rfMode >= 2 ? scaledLQ : rxLinkStatistics.uplinkLQ); } break; + case OSD_CRSF_LQ_TYPE1: + default: + if (!failsafeIsReceivingRxData()) { + tfp_sprintf(buff+1, "%3d", 0); + } else { + tfp_sprintf(buff+1, "%3d", rxLinkStatistics.uplinkLQ); + } + break; } if (!failsafeIsReceivingRxData()) { TEXT_ATTRIBUTES_ADD_BLINK(elemAttr); @@ -2516,7 +2521,24 @@ static bool osdDrawSingleElement(uint8_t item) break; } - case OSD_CRSF_SNR_DB: + case OSD_LQ_DOWNLINK: + { + buff[0] = SYM_LQ; + if (!failsafeIsReceivingRxData()) { + tfp_sprintf(buff+1, "%3d%c", 0, SYM_AH_DECORATION_DOWN); + } else { + tfp_sprintf(buff+1, "%3d%c", rxLinkStatistics.downlinkLQ, SYM_AH_DECORATION_DOWN); + } + + if (!failsafeIsReceivingRxData()) { + TEXT_ATTRIBUTES_ADD_BLINK(elemAttr); + } else if (rxLinkStatistics.downlinkLQ < osdConfig()->link_quality_alarm) { + TEXT_ATTRIBUTES_ADD_BLINK(elemAttr); + } + break; + } + + case OSD_SNR_DB: { static pt1Filter_t snrFilterState; static timeMs_t snrUpdated = 0; @@ -2544,7 +2566,7 @@ static bool osdDrawSingleElement(uint8_t item) break; } - case OSD_CRSF_TX_POWER: + case OSD_TX_POWER_UPLINK: { if (!failsafeIsReceivingRxData()) tfp_sprintf(buff, "%s%c", " ", SYM_BLANK); @@ -2552,6 +2574,15 @@ static bool osdDrawSingleElement(uint8_t item) tfp_sprintf(buff, "%4d%c", rxLinkStatistics.uplinkTXPower, SYM_MW); break; } + + case OSD_RX_POWER_DOWNLINK: + { + if (!failsafeIsReceivingRxData()) + tfp_sprintf(buff, "%s%c%c", " ", SYM_BLANK, SYM_BLANK); + else + tfp_sprintf(buff, "%4d%c%c", rxLinkStatistics.downlinkTXPower, SYM_MW, SYM_AH_DECORATION_DOWN); + break; + } #endif case OSD_FORMATION_FLIGHT: @@ -3992,7 +4023,7 @@ PG_RESET_TEMPLATE(osdConfig_t, osdConfig, .adsb_distance_alert = SETTING_OSD_ADSB_DISTANCE_ALERT_DEFAULT, .adsb_ignore_plane_above_me_limit = SETTING_OSD_ADSB_IGNORE_PLANE_ABOVE_ME_LIMIT_DEFAULT, #endif -#ifdef USE_SERIALRX_CRSF +#if defined(USE_SERIALRX_CRSF) || defined(USE_RX_MSP) .snr_alarm = SETTING_OSD_SNR_ALARM_DEFAULT, .crsf_lq_format = SETTING_OSD_CRSF_LQ_FORMAT_DEFAULT, .link_quality_alarm = SETTING_OSD_LINK_QUALITY_ALARM_DEFAULT, @@ -4143,11 +4174,13 @@ void pgResetFn_osdLayoutsConfig(osdLayoutsConfig_t *osdLayoutsConfig) osdLayoutsConfig->item_pos[0][OSD_PILOT_LOGO] = OSD_POS(20, 3); osdLayoutsConfig->item_pos[0][OSD_VTX_CHANNEL] = OSD_POS(8, 6); -#ifdef USE_SERIALRX_CRSF - osdLayoutsConfig->item_pos[0][OSD_CRSF_RSSI_DBM] = OSD_POS(23, 12); - osdLayoutsConfig->item_pos[0][OSD_CRSF_LQ] = OSD_POS(23, 11); - osdLayoutsConfig->item_pos[0][OSD_CRSF_SNR_DB] = OSD_POS(24, 9); - osdLayoutsConfig->item_pos[0][OSD_CRSF_TX_POWER] = OSD_POS(24, 10); +#if defined(USE_SERIALRX_CRSF) || defined(USE_RX_MSP) + osdLayoutsConfig->item_pos[0][OSD_RSSI_DBM] = OSD_POS(23, 12); + osdLayoutsConfig->item_pos[0][OSD_LQ_UPLINK] = OSD_POS(23, 10); + osdLayoutsConfig->item_pos[0][OSD_LQ_DOWNLINK] = OSD_POS(23, 11); + osdLayoutsConfig->item_pos[0][OSD_SNR_DB] = OSD_POS(24, 9); + osdLayoutsConfig->item_pos[0][OSD_TX_POWER_UPLINK] = OSD_POS(24, 10); + osdLayoutsConfig->item_pos[0][OSD_RX_POWER_DOWNLINK] = OSD_POS(24, 11); #endif osdLayoutsConfig->item_pos[0][OSD_ONTIME] = OSD_POS(23, 8); diff --git a/src/main/io/osd.h b/src/main/io/osd.h index b0423d40eff..da2c9bb015c 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -242,10 +242,10 @@ typedef enum { OSD_ESC_RPM, OSD_ESC_TEMPERATURE, OSD_AZIMUTH, - OSD_CRSF_RSSI_DBM, - OSD_CRSF_LQ, - OSD_CRSF_SNR_DB, - OSD_CRSF_TX_POWER, + OSD_RSSI_DBM, + OSD_LQ_UPLINK, + OSD_SNR_DB, + OSD_TX_POWER_UPLINK, OSD_GVAR_0, OSD_GVAR_1, OSD_GVAR_2, @@ -291,7 +291,9 @@ typedef enum { OSD_CUSTOM_ELEMENT_5, OSD_CUSTOM_ELEMENT_6, OSD_CUSTOM_ELEMENT_7, - OSD_CUSTOM_ELEMENT_8, // 158 + OSD_CUSTOM_ELEMENT_8, + OSD_LQ_DOWNLINK, + OSD_RX_POWER_DOWNLINK, // 160 OSD_ITEM_COUNT // MUST BE LAST } osd_items_e; @@ -369,7 +371,7 @@ typedef struct osdConfig_s { float gforce_alarm; float gforce_axis_alarm_min; float gforce_axis_alarm_max; -#ifdef USE_SERIALRX_CRSF +#if defined(USE_SERIALRX_CRSF) || defined(USE_RX_MSP) int8_t snr_alarm; //CRSF SNR alarm in dB int8_t link_quality_alarm; int16_t rssi_dbm_alarm; // in dBm diff --git a/src/main/programming/logic_condition.c b/src/main/programming/logic_condition.c index 594db21417c..facc595c3f4 100644 --- a/src/main/programming/logic_condition.c +++ b/src/main/programming/logic_condition.c @@ -796,20 +796,28 @@ static int logicConditionGetFlightOperandValue(int operand) { return constrain(calc_length_pythagorean_2D(GPS_distanceToHome, getEstimatedActualPosition(Z) / 100.0f), 0, INT32_MAX); break; - case LOGIC_CONDITION_OPERAND_FLIGHT_CRSF_LQ: - #ifdef USE_SERIALRX_CRSF + case LOGIC_CONDITION_OPERAND_FLIGHT_LQ_UPLINK: +#if defined(USE_SERIALRX_CRSF) || defined(USE_RX_MSP) return rxLinkStatistics.uplinkLQ; - #else +#else return 0; - #endif +#endif break; - case LOGIC_CONDITION_OPERAND_FLIGHT_CRSF_SNR: - #ifdef USE_SERIALRX_CRSF +case LOGIC_CONDITION_OPERAND_FLIGHT_LQ_DOWNLINK: +#if defined(USE_SERIALRX_CRSF) || defined(USE_RX_MSP) + return rxLinkStatistics.downlinkLQ; +#else + return 0; +#endif + break; + + case LOGIC_CONDITION_OPERAND_FLIGHT_SNR: +#if defined(USE_SERIALRX_CRSF) || defined(USE_RX_MSP) return rxLinkStatistics.uplinkSNR; - #else +#else return 0; - #endif +#endif break; case LOGIC_CONDITION_OPERAND_FLIGHT_ACTIVE_PROFILE: // int diff --git a/src/main/programming/logic_condition.h b/src/main/programming/logic_condition.h index 74a7765be40..aaa80d51d53 100644 --- a/src/main/programming/logic_condition.h +++ b/src/main/programming/logic_condition.h @@ -129,8 +129,8 @@ typedef enum { LOGIC_CONDITION_OPERAND_FLIGHT_STABILIZED_PITCH, // 26 LOGIC_CONDITION_OPERAND_FLIGHT_STABILIZED_YAW, // 27 LOGIC_CONDITION_OPERAND_FLIGHT_3D_HOME_DISTANCE, // 28 - LOGIC_CONDITION_OPERAND_FLIGHT_CRSF_LQ, // 29 - LOGIC_CONDITION_OPERAND_FLIGHT_CRSF_SNR, // 39 + LOGIC_CONDITION_OPERAND_FLIGHT_LQ_UPLINK, // 29 + LOGIC_CONDITION_OPERAND_FLIGHT_SNR, // 39 LOGIC_CONDITION_OPERAND_FLIGHT_GPS_VALID, // 0/1 // 31 LOGIC_CONDITION_OPERAND_FLIGHT_LOITER_RADIUS, // 32 LOGIC_CONDITION_OPERAND_FLIGHT_ACTIVE_PROFILE, //int // 33 @@ -144,6 +144,7 @@ typedef enum { LOGIC_CONDITION_OPERAND_FLIGHT_FW_LAND_STATE, // 41 LOGIC_CONDITION_OPERAND_FLIGHT_BATT_PROFILE, // int // 42 LOGIC_CONDITION_OPERAND_FLIGHT_FLOWN_LOITER_RADIUS, // 43 + LOGIC_CONDITION_OPERAND_FLIGHT_LQ_DOWNLINK, // 44 } logicFlightOperands_e; typedef enum {