From 030b52e51d1750377af8e8ebd15fb5b2c1899e97 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Mon, 5 Aug 2024 12:22:15 +0300 Subject: [PATCH 1/6] Removed Switch Indicators and increase custom to 8 Removed switch indicators and increased the number of osd custom elements to 8. The number of osd custom elements and custom element parts can now be automatically changed using the defined numbers. MSP change Requires Configurator --- src/main/fc/fc_msp.c | 42 +++++++------ src/main/fc/settings.yaml | 53 ----------------- src/main/io/osd.c | 91 +++++++++-------------------- src/main/io/osd.h | 24 +++----- src/main/io/osd/custom_elements.c | 1 - src/main/io/osd/custom_elements.h | 2 +- src/main/msp/msp_protocol_v2_inav.h | 3 +- 7 files changed, 60 insertions(+), 156 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index c8ae27f270d..e8cb5c39054 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -1706,28 +1706,19 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF #endif #ifdef USE_PROGRAMMING_FRAMEWORK case MSP2_INAV_CUSTOM_OSD_ELEMENTS: - sbufWriteU8(dst, MAX_CUSTOM_ELEMENTS); - sbufWriteU8(dst, OSD_CUSTOM_ELEMENT_TEXT_SIZE - 1); - - for (int i = 0; i < MAX_CUSTOM_ELEMENTS; i++) { - const osdCustomElement_t *customElement = osdCustomElements(i); - for (int ii = 0; ii < CUSTOM_ELEMENTS_PARTS; ii++) { - sbufWriteU8(dst, customElement->part[ii].type); - sbufWriteU16(dst, customElement->part[ii].value); - } - sbufWriteU8(dst, customElement->visibility.type); - sbufWriteU16(dst, customElement->visibility.value); - for (int ii = 0; ii < OSD_CUSTOM_ELEMENT_TEXT_SIZE - 1; ii++) { - sbufWriteU8(dst, customElement->osdCustomElementText[ii]); - } + { + sbufWriteU8(dst, MAX_CUSTOM_ELEMENTS); + sbufWriteU8(dst, OSD_CUSTOM_ELEMENT_TEXT_SIZE - 1); + sbufWriteU8(dst, CUSTOM_ELEMENTS_PARTS); } break; +#endif default: return false; } return true; } -#endif + #ifdef USE_SAFE_HOME static mspResult_e mspFcSafeHomeOutCommand(sbuf_t *dst, sbuf_t *src) @@ -3349,7 +3340,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) #ifdef USE_PROGRAMMING_FRAMEWORK case MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS: sbufReadU8Safe(&tmp_u8, src); - if ((dataSize == (OSD_CUSTOM_ELEMENT_TEXT_SIZE - 1) + (MAX_CUSTOM_ELEMENTS * 3) + 4) && (tmp_u8 < MAX_CUSTOM_ELEMENTS)) { + if ((dataSize == (OSD_CUSTOM_ELEMENT_TEXT_SIZE - 1) + (CUSTOM_ELEMENTS_PARTS * 3) + 4) && (tmp_u8 < MAX_CUSTOM_ELEMENTS)) { for (int i = 0; i < CUSTOM_ELEMENTS_PARTS; i++) { osdCustomElementsMutable(tmp_u8)->part[i].type = sbufReadU8(src); osdCustomElementsMutable(tmp_u8)->part[i].value = sbufReadU16(src); @@ -3365,7 +3356,7 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) } break; - +#endif case MSP2_BETAFLIGHT_BIND: if (rxConfig()->receiverType == RX_TYPE_SERIAL) { switch (rxConfig()->serialrx_provider) { @@ -3392,7 +3383,6 @@ static mspResult_e mspFcProcessInCommand(uint16_t cmdMSP, sbuf_t *src) } return MSP_RESULT_ACK; } -#endif static const setting_t *mspReadSetting(sbuf_t *src) { @@ -3849,6 +3839,22 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu case MSP2_INAV_LOGIC_CONDITIONS_SINGLE: *ret = mspFcLogicConditionCommand(dst, src); break; + case MSP2_INAV_CUSTOM_OSD_ELEMENT: + const uint8_t idx = sbufReadU8(src); + + if (idx < MAX_CUSTOM_ELEMENTS) { + const osdCustomElement_t *customElement = osdCustomElements(idx); + for (int ii = 0; ii < CUSTOM_ELEMENTS_PARTS; ii++) { + sbufWriteU8(dst, customElement->part[ii].type); + sbufWriteU16(dst, customElement->part[ii].value); + } + sbufWriteU8(dst, customElement->visibility.type); + sbufWriteU16(dst, customElement->visibility.value); + for (int ii = 0; ii < OSD_CUSTOM_ELEMENT_TEXT_SIZE - 1; ii++) { + sbufWriteU8(dst, customElement->osdCustomElementText[ii]); + } + } + break; #endif #ifdef USE_SAFE_HOME case MSP2_INAV_SAFEHOME: diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 6c16ce93b21..1bd1400d0a6 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -3706,59 +3706,6 @@ groups: min: 1000 max: 5000 default_value: 1500 - - name: osd_switch_indicator_zero_name - description: "Character to use for OSD switch incicator 0." - field: osd_switch_indicator0_name - type: string - max: 5 - default_value: "FLAP" - - name: osd_switch_indicator_one_name - description: "Character to use for OSD switch incicator 1." - field: osd_switch_indicator1_name - type: string - max: 5 - default_value: "GEAR" - - name: osd_switch_indicator_two_name - description: "Character to use for OSD switch incicator 2." - field: osd_switch_indicator2_name - type: string - max: 5 - default_value: "CAM" - - name: osd_switch_indicator_three_name - description: "Character to use for OSD switch incicator 3." - field: osd_switch_indicator3_name - type: string - max: 5 - default_value: "LIGT" - - name: osd_switch_indicator_zero_channel - description: "RC Channel to use for OSD switch indicator 0." - field: osd_switch_indicator0_channel - min: 5 - max: MAX_SUPPORTED_RC_CHANNEL_COUNT - default_value: 5 - - name: osd_switch_indicator_one_channel - description: "RC Channel to use for OSD switch indicator 1." - field: osd_switch_indicator1_channel - min: 5 - max: MAX_SUPPORTED_RC_CHANNEL_COUNT - default_value: 5 - - name: osd_switch_indicator_two_channel - description: "RC Channel to use for OSD switch indicator 2." - field: osd_switch_indicator2_channel - min: 5 - max: MAX_SUPPORTED_RC_CHANNEL_COUNT - default_value: 5 - - name: osd_switch_indicator_three_channel - description: "RC Channel to use for OSD switch indicator 3." - field: osd_switch_indicator3_channel - min: 5 - max: MAX_SUPPORTED_RC_CHANNEL_COUNT - default_value: 5 - - name: osd_switch_indicators_align_left - description: "Align text to left of switch indicators" - field: osd_switch_indicators_align_left - type: bool - default_value: ON - name: osd_system_msg_display_time description: System message display cycle time for multiple messages (milliseconds). field: system_msg_display_time diff --git a/src/main/io/osd.c b/src/main/io/osd.c index d682c0299ff..77762c6a003 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, 12); -PG_REGISTER_WITH_RESET_FN(osdLayoutsConfig_t, osdLayoutsConfig, PG_OSD_LAYOUTS_CONFIG, 1); +PG_REGISTER_WITH_RESET_FN(osdLayoutsConfig_t, osdLayoutsConfig, PG_OSD_LAYOUTS_CONFIG, 2); void osdStartedSaveProcess(void) { savingSettings = true; @@ -1610,40 +1610,6 @@ int8_t getGeoWaypointNumber(int8_t waypointIndex) return geoWaypointIndex - posControl.startWpIndex + 1; } -void osdDisplaySwitchIndicator(const char *swName, int rcValue, char *buff) { - int8_t ptr = 0; - - if (osdConfig()->osd_switch_indicators_align_left) { - for (ptr = 0; ptr < constrain(strlen(swName), 0, OSD_SWITCH_INDICATOR_NAME_LENGTH); ptr++) { - buff[ptr] = swName[ptr]; - } - - if ( rcValue < 1333) { - buff[ptr++] = SYM_SWITCH_INDICATOR_LOW; - } else if ( rcValue > 1666) { - buff[ptr++] = SYM_SWITCH_INDICATOR_HIGH; - } else { - buff[ptr++] = SYM_SWITCH_INDICATOR_MID; - } - } else { - if ( rcValue < 1333) { - buff[ptr++] = SYM_SWITCH_INDICATOR_LOW; - } else if ( rcValue > 1666) { - buff[ptr++] = SYM_SWITCH_INDICATOR_HIGH; - } else { - buff[ptr++] = SYM_SWITCH_INDICATOR_MID; - } - - for (ptr = 1; ptr < constrain(strlen(swName), 0, OSD_SWITCH_INDICATOR_NAME_LENGTH) + 1; ptr++) { - buff[ptr] = swName[ptr-1]; - } - - ptr++; - } - - buff[ptr] = '\0'; -} - static bool osdDrawSingleElement(uint8_t item) { uint16_t pos = osdLayoutsConfig()->item_pos[currentLayout][item]; @@ -1671,6 +1637,31 @@ static bool osdDrawSingleElement(uint8_t item) customElementDrawElement(buff, 2); break; } + case OSD_CUSTOM_ELEMENT_4: + { + customElementDrawElement(buff, 3); + break; + } + case OSD_CUSTOM_ELEMENT_5: + { + customElementDrawElement(buff, 4); + break; + } + case OSD_CUSTOM_ELEMENT_6: + { + customElementDrawElement(buff, 5); + break; + } + case OSD_CUSTOM_ELEMENT_7: + { + customElementDrawElement(buff, 6); + break; + } + case OSD_CUSTOM_ELEMENT_8: + { + customElementDrawElement(buff, 7); + break; + } case OSD_RSSI_VALUE: { uint16_t osdRssi = osdConvertRSSI(); @@ -2873,22 +2864,6 @@ static bool osdDrawSingleElement(uint8_t item) } #endif - case OSD_SWITCH_INDICATOR_0: - osdDisplaySwitchIndicator(osdConfig()->osd_switch_indicator0_name, rxGetChannelValue(osdConfig()->osd_switch_indicator0_channel - 1), buff); - break; - - case OSD_SWITCH_INDICATOR_1: - osdDisplaySwitchIndicator(osdConfig()->osd_switch_indicator1_name, rxGetChannelValue(osdConfig()->osd_switch_indicator1_channel - 1), buff); - break; - - case OSD_SWITCH_INDICATOR_2: - osdDisplaySwitchIndicator(osdConfig()->osd_switch_indicator2_name, rxGetChannelValue(osdConfig()->osd_switch_indicator2_channel - 1), buff); - break; - - case OSD_SWITCH_INDICATOR_3: - osdDisplaySwitchIndicator(osdConfig()->osd_switch_indicator3_name, rxGetChannelValue(osdConfig()->osd_switch_indicator3_channel - 1), buff); - break; - case OSD_PAN_SERVO_CENTRED: { int16_t panOffset = osdGetPanServoOffset(); @@ -4008,15 +3983,6 @@ PG_RESET_TEMPLATE(osdConfig_t, osdConfig, .pan_servo_indicator_show_degrees = SETTING_OSD_PAN_SERVO_INDICATOR_SHOW_DEGREES_DEFAULT, .esc_rpm_precision = SETTING_OSD_ESC_RPM_PRECISION_DEFAULT, .mAh_precision = SETTING_OSD_MAH_PRECISION_DEFAULT, - .osd_switch_indicator0_name = SETTING_OSD_SWITCH_INDICATOR_ZERO_NAME_DEFAULT, - .osd_switch_indicator0_channel = SETTING_OSD_SWITCH_INDICATOR_ZERO_CHANNEL_DEFAULT, - .osd_switch_indicator1_name = SETTING_OSD_SWITCH_INDICATOR_ONE_NAME_DEFAULT, - .osd_switch_indicator1_channel = SETTING_OSD_SWITCH_INDICATOR_ONE_CHANNEL_DEFAULT, - .osd_switch_indicator2_name = SETTING_OSD_SWITCH_INDICATOR_TWO_NAME_DEFAULT, - .osd_switch_indicator2_channel = SETTING_OSD_SWITCH_INDICATOR_TWO_CHANNEL_DEFAULT, - .osd_switch_indicator3_name = SETTING_OSD_SWITCH_INDICATOR_THREE_NAME_DEFAULT, - .osd_switch_indicator3_channel = SETTING_OSD_SWITCH_INDICATOR_THREE_CHANNEL_DEFAULT, - .osd_switch_indicators_align_left = SETTING_OSD_SWITCH_INDICATORS_ALIGN_LEFT_DEFAULT, .system_msg_display_time = SETTING_OSD_SYSTEM_MSG_DISPLAY_TIME_DEFAULT, .units = SETTING_OSD_UNITS_DEFAULT, .main_voltage_decimals = SETTING_OSD_MAIN_VOLTAGE_DECIMALS_DEFAULT, @@ -4191,11 +4157,6 @@ void pgResetFn_osdLayoutsConfig(osdLayoutsConfig_t *osdLayoutsConfig) osdLayoutsConfig->item_pos[0][OSD_MULTI_FUNCTION] = OSD_POS(1, 4); - osdLayoutsConfig->item_pos[0][OSD_SWITCH_INDICATOR_0] = OSD_POS(2, 7); - osdLayoutsConfig->item_pos[0][OSD_SWITCH_INDICATOR_1] = OSD_POS(2, 8); - osdLayoutsConfig->item_pos[0][OSD_SWITCH_INDICATOR_2] = OSD_POS(2, 9); - osdLayoutsConfig->item_pos[0][OSD_SWITCH_INDICATOR_3] = OSD_POS(2, 10); - osdLayoutsConfig->item_pos[0][OSD_ADSB_WARNING] = OSD_POS(2, 7); osdLayoutsConfig->item_pos[0][OSD_ADSB_INFO] = OSD_POS(2, 8); #if defined(USE_ESC_SENSOR) diff --git a/src/main/io/osd.h b/src/main/io/osd.h index a73db015793..2e5200a0483 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -263,10 +263,10 @@ typedef enum { OSD_AIR_MAX_SPEED, OSD_ACTIVE_PROFILE, OSD_MISSION, - OSD_SWITCH_INDICATOR_0, - OSD_SWITCH_INDICATOR_1, - OSD_SWITCH_INDICATOR_2, - OSD_SWITCH_INDICATOR_3, + OSD_CUSTOM_ELEMENT_4, + OSD_CUSTOM_ELEMENT_5, + OSD_CUSTOM_ELEMENT_6, + OSD_CUSTOM_ELEMENT_7, OSD_TPA_TIME_CONSTANT, OSD_FW_LEVEL_TRIM, OSD_GLIDE_TIME_REMAINING, @@ -286,7 +286,8 @@ typedef enum { OSD_ADSB_WARNING, //150 OSD_ADSB_INFO, OSD_BLACKBOX, - OSD_FORMATION_FLIGHT, //153 + OSD_FORMATION_FLIGHT, + OSD_CUSTOM_ELEMENT_8, // 154 OSD_ITEM_COUNT // MUST BE LAST } osd_items_e; @@ -347,8 +348,6 @@ typedef struct osdLayoutsConfig_s { PG_DECLARE(osdLayoutsConfig_t, osdLayoutsConfig); -#define OSD_SWITCH_INDICATOR_NAME_LENGTH 4 - typedef struct osdConfig_s { // Alarms uint8_t rssi_alarm; // rssi % @@ -444,17 +443,8 @@ typedef struct osdConfig_s { uint8_t telemetry; // use telemetry on displayed pixel line 0 uint8_t esc_rpm_precision; // Number of characters used for the RPM numbers. uint16_t system_msg_display_time; // system message display time for multiple messages (ms) - uint8_t mAh_precision; // Number of numbers used for mAh drawn. Plently of packs now are > 9999 mAh + uint8_t mAh_precision; // Number of numbers used for mAh drawn. Plently of packs now are > 9999 mAh uint8_t ahi_pitch_interval; // redraws AHI at set pitch interval (Not pixel OSD) - char osd_switch_indicator0_name[OSD_SWITCH_INDICATOR_NAME_LENGTH + 1]; // Name to use for switch indicator 0. - uint8_t osd_switch_indicator0_channel; // RC Channel to use for switch indicator 0. - char osd_switch_indicator1_name[OSD_SWITCH_INDICATOR_NAME_LENGTH + 1]; // Name to use for switch indicator 1. - uint8_t osd_switch_indicator1_channel; // RC Channel to use for switch indicator 1. - char osd_switch_indicator2_name[OSD_SWITCH_INDICATOR_NAME_LENGTH + 1]; // Name to use for switch indicator 2. - uint8_t osd_switch_indicator2_channel; // RC Channel to use for switch indicator 2. - char osd_switch_indicator3_name[OSD_SWITCH_INDICATOR_NAME_LENGTH + 1]; // Name to use for switch indicator 3. - uint8_t osd_switch_indicator3_channel; // RC Channel to use for switch indicator 3. - bool osd_switch_indicators_align_left; // Align switch indicator name to left of the switch. bool use_pilot_logo; // If enabled, the pilot logo (last 40 characters of page 2 font) will be used with the INAV logo. uint8_t inav_to_pilot_logo_spacing; // The space between the INAV and pilot logos, if pilot logo is used. This number may be adjusted so that it fits the odd/even col width. uint16_t arm_screen_display_time; // Length of time the arm screen is displayed diff --git a/src/main/io/osd/custom_elements.c b/src/main/io/osd/custom_elements.c index fbd05e2be61..132b6c820af 100644 --- a/src/main/io/osd/custom_elements.c +++ b/src/main/io/osd/custom_elements.c @@ -138,4 +138,3 @@ void customElementDrawElement(char *buff, uint8_t customElementIndex){ } prevLength[customElementIndex] = buffSeek; } - diff --git a/src/main/io/osd/custom_elements.h b/src/main/io/osd/custom_elements.h index a55b010f01a..715bae5ab2b 100644 --- a/src/main/io/osd/custom_elements.h +++ b/src/main/io/osd/custom_elements.h @@ -21,7 +21,7 @@ #define OSD_CUSTOM_ELEMENT_TEXT_SIZE 16 #define CUSTOM_ELEMENTS_PARTS 3 -#define MAX_CUSTOM_ELEMENTS 3 +#define MAX_CUSTOM_ELEMENTS 8 typedef enum { CUSTOM_ELEMENT_TYPE_NONE = 0, diff --git a/src/main/msp/msp_protocol_v2_inav.h b/src/main/msp/msp_protocol_v2_inav.h index 8b4a09e87af..02c8c979aae 100755 --- a/src/main/msp/msp_protocol_v2_inav.h +++ b/src/main/msp/msp_protocol_v2_inav.h @@ -109,7 +109,8 @@ #define MSP2_ADSB_VEHICLE_LIST 0x2090 #define MSP2_INAV_CUSTOM_OSD_ELEMENTS 0x2100 -#define MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS 0x2101 +#define MSP2_INAV_CUSTOM_OSD_ELEMENT 0x2101 +#define MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS 0x2102 #define MSP2_INAV_SERVO_CONFIG 0x2200 #define MSP2_INAV_SET_SERVO_CONFIG 0x2201 \ No newline at end of file From f3c43e8c0dd6db69bae0066ae52ed9dd049d13ff Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Tue, 6 Aug 2024 18:32:41 +0300 Subject: [PATCH 2/6] Updates - Added additional numeric options and LC options to custom element types - Changed method of displaying numbers. So that negative numbers will work. --- src/main/io/osd/custom_elements.c | 111 +++++++++++++++++++++++++++--- src/main/io/osd/custom_elements.h | 26 +++++-- 2 files changed, 124 insertions(+), 13 deletions(-) diff --git a/src/main/io/osd/custom_elements.c b/src/main/io/osd/custom_elements.c index 132b6c820af..07ca43db4fd 100644 --- a/src/main/io/osd/custom_elements.c +++ b/src/main/io/osd/custom_elements.c @@ -68,26 +68,119 @@ uint8_t customElementDrawPart(char *buff, uint8_t customElementIndex, uint8_t cu const int customPartValue = osdCustomElements(customElementIndex)->part[customElementItemIndex].value; switch (customPartType) { - case CUSTOM_ELEMENT_TYPE_GV: + case CUSTOM_ELEMENT_TYPE_GV_1: { - osdFormatCentiNumber(buff, (int32_t) gvGet(customPartValue) * (int32_t) 100, 1, 0, 0, 6, false); - return 6; + osdFormatCentiNumber(buff,(int32_t) (constrain(gvGet(customPartValue), -9, 9) * (int32_t) 100), 1, 0, 0, 2, false); + return 2; + } + case CUSTOM_ELEMENT_TYPE_GV_2: + { + osdFormatCentiNumber(buff, (int32_t) (constrain(gvGet(customPartValue), -99, 99) * (int32_t) 100), 1, 0, 0, 3, false); + return 3; + } + case CUSTOM_ELEMENT_TYPE_GV_3: + { + osdFormatCentiNumber(buff, (int32_t) (constrain(gvGet(customPartValue), -999, 999) * (int32_t) 100), 1, 0, 0, 4, false); + return 4; + } + case CUSTOM_ELEMENT_TYPE_GV_4: + { + osdFormatCentiNumber(buff, (int32_t) (constrain(gvGet(customPartValue), -9999, 9999) * (int32_t) 100), 1, 0, 0, 5, false); + return 5; } - case CUSTOM_ELEMENT_TYPE_GV_FLOAT: + case CUSTOM_ELEMENT_TYPE_GV_5: { - osdFormatCentiNumber(buff, (int32_t) gvGet(customPartValue), 1, 2, 0, 6, false); + osdFormatCentiNumber(buff, (int32_t) (constrain(gvGet(customPartValue), -99999, 99999) * (int32_t) 100), 1, 0, 0, 6, false); return 6; } - case CUSTOM_ELEMENT_TYPE_GV_SMALL: + case CUSTOM_ELEMENT_TYPE_GV_FLOAT_1_1: { - osdFormatCentiNumber(buff, (int32_t) ((gvGet(customPartValue) % 1000 ) * (int32_t) 100), 1, 0, 0, 3, false); + osdFormatCentiNumber(buff, (int32_t) (constrain(gvGet(customPartValue), -99, 99) * (int32_t) 10), 1, 1, 0, 3, false); return 3; } - case CUSTOM_ELEMENT_TYPE_GV_SMALL_FLOAT: + case CUSTOM_ELEMENT_TYPE_GV_FLOAT_2_1: + { + osdFormatCentiNumber(buff, (int32_t) (constrain(gvGet(customPartValue), -999, 999) * (int32_t) 10), 1, 1, 0, 4, false); + return 4; + } + case CUSTOM_ELEMENT_TYPE_GV_FLOAT_2_2: + { + osdFormatCentiNumber(buff, (int32_t) constrain(gvGet(customPartValue), -9999, 9999), 1, 2, 0, 5, false); + return 5; + } + case CUSTOM_ELEMENT_TYPE_GV_FLOAT_3_1: + { + osdFormatCentiNumber(buff, (int32_t) (constrain(gvGet(customPartValue), -9999, 9999) * (int32_t) 10), 1, 1, 0, 5, false); + return 5; + } + case CUSTOM_ELEMENT_TYPE_GV_FLOAT_3_2: + { + osdFormatCentiNumber(buff, (int32_t) constrain(gvGet(customPartValue), -99999, 99999), 1, 2, 0, 6, false); + return 6; + } + case CUSTOM_ELEMENT_TYPE_GV_FLOAT_4_1: { - osdFormatCentiNumber(buff, (int32_t) ((gvGet(customPartValue) % 100) * (int32_t) 10), 1, 1, 0, 2, false); + osdFormatCentiNumber(buff, (int32_t) (constrain(gvGet(customPartValue), -99999, 99999) * (int32_t) 10), 1, 1, 0, 6, false); + return 6; + } + + case CUSTOM_ELEMENT_TYPE_LC_1: + { + osdFormatCentiNumber(buff,(int32_t) (constrain(logicConditionGetValue(customPartValue), -9, 9) * (int32_t) 100), 1, 0, 0, 2, false); return 2; } + case CUSTOM_ELEMENT_TYPE_LC_2: + { + osdFormatCentiNumber(buff, (int32_t) (constrain(logicConditionGetValue(customPartValue), -99, 99) * (int32_t) 100), 1, 0, 0, 3, false); + return 3; + } + case CUSTOM_ELEMENT_TYPE_LC_3: + { + osdFormatCentiNumber(buff, (int32_t) (constrain(logicConditionGetValue(customPartValue), -999, 999) * (int32_t) 100), 1, 0, 0, 4, false); + return 4; + } + case CUSTOM_ELEMENT_TYPE_LC_4: + { + osdFormatCentiNumber(buff, (int32_t) (constrain(logicConditionGetValue(customPartValue), -9999, 9999) * (int32_t) 100), 1, 0, 0, 5, false); + return 5; + } + case CUSTOM_ELEMENT_TYPE_LC_5: + { + osdFormatCentiNumber(buff, (int32_t) (constrain(logicConditionGetValue(customPartValue), -99999, 99999) * (int32_t) 100), 1, 0, 0, 6, false); + return 6; + } + case CUSTOM_ELEMENT_TYPE_LC_FLOAT_1_1: + { + osdFormatCentiNumber(buff, (int32_t) (constrain(logicConditionGetValue(customPartValue), -99, 99) * (int32_t) 10), 1, 1, 0, 3, false); + return 3; + } + case CUSTOM_ELEMENT_TYPE_LC_FLOAT_2_1: + { + osdFormatCentiNumber(buff, (int32_t) (constrain(logicConditionGetValue(customPartValue), -999, 999) * (int32_t) 10), 1, 1, 0, 4, false); + return 4; + } + case CUSTOM_ELEMENT_TYPE_LC_FLOAT_2_2: + { + osdFormatCentiNumber(buff, (int32_t) constrain(logicConditionGetValue(customPartValue), -9999, 9999), 1, 2, 0, 5, false); + return 5; + } + case CUSTOM_ELEMENT_TYPE_LC_FLOAT_3_1: + { + osdFormatCentiNumber(buff, (int32_t) (constrain(logicConditionGetValue(customPartValue), -9999, 9999) * (int32_t) 10), 1, 1, 0, 5, false); + return 5; + } + case CUSTOM_ELEMENT_TYPE_LC_FLOAT_3_2: + { + osdFormatCentiNumber(buff, (int32_t) constrain(logicConditionGetValue(customPartValue), -99999, 99999), 1, 2, 0, 6, false); + return 6; + } + case CUSTOM_ELEMENT_TYPE_LC_FLOAT_4_1: + { + osdFormatCentiNumber(buff, (int32_t) (constrain(logicConditionGetValue(customPartValue), -99999, 99999) * (int32_t) 10), 1, 1, 0, 6, false); + return 6; + } + + case CUSTOM_ELEMENT_TYPE_ICON_GV: { *buff = (uint8_t)gvGet(customPartValue); diff --git a/src/main/io/osd/custom_elements.h b/src/main/io/osd/custom_elements.h index 715bae5ab2b..73425d59ad3 100644 --- a/src/main/io/osd/custom_elements.h +++ b/src/main/io/osd/custom_elements.h @@ -28,10 +28,28 @@ typedef enum { CUSTOM_ELEMENT_TYPE_TEXT = 1, CUSTOM_ELEMENT_TYPE_ICON_STATIC = 2, CUSTOM_ELEMENT_TYPE_ICON_GV = 3, - CUSTOM_ELEMENT_TYPE_GV = 4, - CUSTOM_ELEMENT_TYPE_GV_FLOAT = 5, - CUSTOM_ELEMENT_TYPE_GV_SMALL = 6, - CUSTOM_ELEMENT_TYPE_GV_SMALL_FLOAT = 7, + CUSTOM_ELEMENT_TYPE_GV_1 = 4, + CUSTOM_ELEMENT_TYPE_GV_2 = 5, + CUSTOM_ELEMENT_TYPE_GV_3 = 6, + CUSTOM_ELEMENT_TYPE_GV_4 = 7, + CUSTOM_ELEMENT_TYPE_GV_5 = 8, + CUSTOM_ELEMENT_TYPE_GV_FLOAT_1_1 = 9, + CUSTOM_ELEMENT_TYPE_GV_FLOAT_2_1 = 10, + CUSTOM_ELEMENT_TYPE_GV_FLOAT_2_2 = 11, + CUSTOM_ELEMENT_TYPE_GV_FLOAT_3_1 = 12, + CUSTOM_ELEMENT_TYPE_GV_FLOAT_3_2 = 13, + CUSTOM_ELEMENT_TYPE_GV_FLOAT_4_1 = 14, + CUSTOM_ELEMENT_TYPE_LC_1 = 15, + CUSTOM_ELEMENT_TYPE_LC_2 = 16, + CUSTOM_ELEMENT_TYPE_LC_3 = 17, + CUSTOM_ELEMENT_TYPE_LC_4 = 18, + CUSTOM_ELEMENT_TYPE_LC_5 = 19, + CUSTOM_ELEMENT_TYPE_LC_FLOAT_1_1 = 20, + CUSTOM_ELEMENT_TYPE_LC_FLOAT_2_1 = 21, + CUSTOM_ELEMENT_TYPE_LC_FLOAT_2_2 = 22, + CUSTOM_ELEMENT_TYPE_LC_FLOAT_3_1 = 23, + CUSTOM_ELEMENT_TYPE_LC_FLOAT_3_2 = 24, + CUSTOM_ELEMENT_TYPE_LC_FLOAT_4_1 = 25, } osdCustomElementType_e; typedef enum { From dad76ec9610fdbb7e53e7f9d36a068bb8f8848ce Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Tue, 6 Aug 2024 19:41:08 +0300 Subject: [PATCH 3/6] Updated docs --- docs/Settings.md | 90 ------------------------------------------------ 1 file changed, 90 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 6487b44b6d1..1e7bf47381c 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -5152,96 +5152,6 @@ Enabling this option will show metric efficiency statistics on the post flight s --- -### osd_switch_indicator_one_channel - -RC Channel to use for OSD switch indicator 1. - -| Default | Min | Max | -| --- | --- | --- | -| 5 | 5 | MAX_SUPPORTED_RC_CHANNEL_COUNT | - ---- - -### osd_switch_indicator_one_name - -Character to use for OSD switch incicator 1. - -| Default | Min | Max | -| --- | --- | --- | -| GEAR | | 5 | - ---- - -### osd_switch_indicator_three_channel - -RC Channel to use for OSD switch indicator 3. - -| Default | Min | Max | -| --- | --- | --- | -| 5 | 5 | MAX_SUPPORTED_RC_CHANNEL_COUNT | - ---- - -### osd_switch_indicator_three_name - -Character to use for OSD switch incicator 3. - -| Default | Min | Max | -| --- | --- | --- | -| LIGT | | 5 | - ---- - -### osd_switch_indicator_two_channel - -RC Channel to use for OSD switch indicator 2. - -| Default | Min | Max | -| --- | --- | --- | -| 5 | 5 | MAX_SUPPORTED_RC_CHANNEL_COUNT | - ---- - -### osd_switch_indicator_two_name - -Character to use for OSD switch incicator 2. - -| Default | Min | Max | -| --- | --- | --- | -| CAM | | 5 | - ---- - -### osd_switch_indicator_zero_channel - -RC Channel to use for OSD switch indicator 0. - -| Default | Min | Max | -| --- | --- | --- | -| 5 | 5 | MAX_SUPPORTED_RC_CHANNEL_COUNT | - ---- - -### osd_switch_indicator_zero_name - -Character to use for OSD switch incicator 0. - -| Default | Min | Max | -| --- | --- | --- | -| FLAP | | 5 | - ---- - -### osd_switch_indicators_align_left - -Align text to left of switch indicators - -| Default | Min | Max | -| --- | --- | --- | -| ON | OFF | ON | - ---- - ### osd_system_msg_display_time System message display cycle time for multiple messages (milliseconds). From fa166c61c6e468c70d24e4fb8ed41592748df0cc Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Tue, 6 Aug 2024 19:49:22 +0300 Subject: [PATCH 4/6] Mac issues --- src/main/fc/fc_msp.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index e8cb5c39054..2749f016761 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -3840,18 +3840,20 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu *ret = mspFcLogicConditionCommand(dst, src); break; case MSP2_INAV_CUSTOM_OSD_ELEMENT: - const uint8_t idx = sbufReadU8(src); + { + const uint8_t idx = sbufReadU8(src); - if (idx < MAX_CUSTOM_ELEMENTS) { - const osdCustomElement_t *customElement = osdCustomElements(idx); - for (int ii = 0; ii < CUSTOM_ELEMENTS_PARTS; ii++) { - sbufWriteU8(dst, customElement->part[ii].type); - sbufWriteU16(dst, customElement->part[ii].value); - } - sbufWriteU8(dst, customElement->visibility.type); - sbufWriteU16(dst, customElement->visibility.value); - for (int ii = 0; ii < OSD_CUSTOM_ELEMENT_TEXT_SIZE - 1; ii++) { - sbufWriteU8(dst, customElement->osdCustomElementText[ii]); + if (idx < MAX_CUSTOM_ELEMENTS) { + const osdCustomElement_t *customElement = osdCustomElements(idx); + for (int ii = 0; ii < CUSTOM_ELEMENTS_PARTS; ii++) { + sbufWriteU8(dst, customElement->part[ii].type); + sbufWriteU16(dst, customElement->part[ii].value); + } + sbufWriteU8(dst, customElement->visibility.type); + sbufWriteU16(dst, customElement->visibility.value); + for (int ii = 0; ii < OSD_CUSTOM_ELEMENT_TEXT_SIZE - 1; ii++) { + sbufWriteU8(dst, customElement->osdCustomElementText[ii]); + } } } break; From 70856d7baa1e89f8cb0be92ac11cb012afaa77ec Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Wed, 7 Aug 2024 23:10:33 +0300 Subject: [PATCH 5/6] Added icon from logic condition --- src/main/io/osd/custom_elements.c | 5 ++++ src/main/io/osd/custom_elements.h | 45 ++++++++++++++++--------------- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/src/main/io/osd/custom_elements.c b/src/main/io/osd/custom_elements.c index 07ca43db4fd..df84ddd76b0 100644 --- a/src/main/io/osd/custom_elements.c +++ b/src/main/io/osd/custom_elements.c @@ -186,6 +186,11 @@ uint8_t customElementDrawPart(char *buff, uint8_t customElementIndex, uint8_t cu *buff = (uint8_t)gvGet(customPartValue); return 1; } + case CUSTOM_ELEMENT_TYPE_ICON_LC: + { + *buff = (uint8_t)constrain(logicConditionGetValue(customPartValue), 1, 255); + return 1; + } case CUSTOM_ELEMENT_TYPE_ICON_STATIC: { *buff = (uint8_t)customPartValue; diff --git a/src/main/io/osd/custom_elements.h b/src/main/io/osd/custom_elements.h index 73425d59ad3..9c12ede6734 100644 --- a/src/main/io/osd/custom_elements.h +++ b/src/main/io/osd/custom_elements.h @@ -28,28 +28,29 @@ typedef enum { CUSTOM_ELEMENT_TYPE_TEXT = 1, CUSTOM_ELEMENT_TYPE_ICON_STATIC = 2, CUSTOM_ELEMENT_TYPE_ICON_GV = 3, - CUSTOM_ELEMENT_TYPE_GV_1 = 4, - CUSTOM_ELEMENT_TYPE_GV_2 = 5, - CUSTOM_ELEMENT_TYPE_GV_3 = 6, - CUSTOM_ELEMENT_TYPE_GV_4 = 7, - CUSTOM_ELEMENT_TYPE_GV_5 = 8, - CUSTOM_ELEMENT_TYPE_GV_FLOAT_1_1 = 9, - CUSTOM_ELEMENT_TYPE_GV_FLOAT_2_1 = 10, - CUSTOM_ELEMENT_TYPE_GV_FLOAT_2_2 = 11, - CUSTOM_ELEMENT_TYPE_GV_FLOAT_3_1 = 12, - CUSTOM_ELEMENT_TYPE_GV_FLOAT_3_2 = 13, - CUSTOM_ELEMENT_TYPE_GV_FLOAT_4_1 = 14, - CUSTOM_ELEMENT_TYPE_LC_1 = 15, - CUSTOM_ELEMENT_TYPE_LC_2 = 16, - CUSTOM_ELEMENT_TYPE_LC_3 = 17, - CUSTOM_ELEMENT_TYPE_LC_4 = 18, - CUSTOM_ELEMENT_TYPE_LC_5 = 19, - CUSTOM_ELEMENT_TYPE_LC_FLOAT_1_1 = 20, - CUSTOM_ELEMENT_TYPE_LC_FLOAT_2_1 = 21, - CUSTOM_ELEMENT_TYPE_LC_FLOAT_2_2 = 22, - CUSTOM_ELEMENT_TYPE_LC_FLOAT_3_1 = 23, - CUSTOM_ELEMENT_TYPE_LC_FLOAT_3_2 = 24, - CUSTOM_ELEMENT_TYPE_LC_FLOAT_4_1 = 25, + CUSTOM_ELEMENT_TYPE_ICON_LC = 4, + CUSTOM_ELEMENT_TYPE_GV_1 = 5, + CUSTOM_ELEMENT_TYPE_GV_2 = 6, + CUSTOM_ELEMENT_TYPE_GV_3 = 7, + CUSTOM_ELEMENT_TYPE_GV_4 = 8, + CUSTOM_ELEMENT_TYPE_GV_5 = 9, + CUSTOM_ELEMENT_TYPE_GV_FLOAT_1_1 = 10, + CUSTOM_ELEMENT_TYPE_GV_FLOAT_2_1 = 11, + CUSTOM_ELEMENT_TYPE_GV_FLOAT_2_2 = 12, + CUSTOM_ELEMENT_TYPE_GV_FLOAT_3_1 = 13, + CUSTOM_ELEMENT_TYPE_GV_FLOAT_3_2 = 14, + CUSTOM_ELEMENT_TYPE_GV_FLOAT_4_1 = 15, + CUSTOM_ELEMENT_TYPE_LC_1 = 16, + CUSTOM_ELEMENT_TYPE_LC_2 = 17, + CUSTOM_ELEMENT_TYPE_LC_3 = 18, + CUSTOM_ELEMENT_TYPE_LC_4 = 19, + CUSTOM_ELEMENT_TYPE_LC_5 = 20, + CUSTOM_ELEMENT_TYPE_LC_FLOAT_1_1 = 21, + CUSTOM_ELEMENT_TYPE_LC_FLOAT_2_1 = 22, + CUSTOM_ELEMENT_TYPE_LC_FLOAT_2_2 = 23, + CUSTOM_ELEMENT_TYPE_LC_FLOAT_3_1 = 24, + CUSTOM_ELEMENT_TYPE_LC_FLOAT_3_2 = 25, + CUSTOM_ELEMENT_TYPE_LC_FLOAT_4_1 = 26, } osdCustomElementType_e; typedef enum { From 387d51e1dfbb6dfb0f8252d78f384face876ff80 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Wed, 11 Sep 2024 20:50:58 +0100 Subject: [PATCH 6/6] Added switch indicators back in - Added switch indicators back in - Updated OSD document --- docs/OSD.md | 13 +++++- docs/Settings.md | 90 +++++++++++++++++++++++++++++++++++++++ src/main/fc/settings.yaml | 53 +++++++++++++++++++++++ src/main/io/osd.c | 63 +++++++++++++++++++++++++++ src/main/io/osd.h | 25 ++++++++--- 5 files changed, 238 insertions(+), 6 deletions(-) diff --git a/docs/OSD.md b/docs/OSD.md index 5787496687a..b492e537cef 100644 --- a/docs/OSD.md +++ b/docs/OSD.md @@ -177,7 +177,18 @@ Here are the OSD Elements provided by INAV. | 144 | OSD_MULTI_FUNCTION | 7.0.0 | | | 145 | OSD_ODOMETER | 7.0.0 | For this to work correctly, stats must be enabled (`set stats=ON`). Otherwise, this will show the total flight distance. | | 146 | OSD_PILOT_LOGO | 7.0.0 | | -| 147 | OSD_BLACKBOX | 8.0.0 | The element will be hidden unless blackbox recording is attempted. | +| 147 | OSD_CUSTOM_ELEMENT_1 | 7.0.0 | | +| 148 | OSD_CUSTOM_ELEMENT_2 | 7.0.0 | | +| 149 | OSD_CUSTOM_ELEMENT_3 | 7.0.0 | | +| 150 | OSD_ADSB_WARNING | 7.0.0 | | +| 151 | OSD_ADSB_INFO | 7.0.0 | | +| 152 | OSD_BLACKBOX | 8.0.0 | The element will be hidden unless blackbox recording is attempted. | +| 153 | OSD_FORMATION_FLIGHT | 8.0.0 | | +| 154 | OSD_CUSTOM_ELEMENT_4 | 8.0.0 | | +| 155 | OSD_CUSTOM_ELEMENT_5 | 8.0.0 | | +| 156 | OSD_CUSTOM_ELEMENT_6 | 8.0.0 | | +| 157 | OSD_CUSTOM_ELEMENT_7 | 8.0.0 | | +| 158 | OSD_CUSTOM_ELEMENT_8 | 8.0.0 | | # Pilot Logos diff --git a/docs/Settings.md b/docs/Settings.md index 1e7bf47381c..6487b44b6d1 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -5152,6 +5152,96 @@ Enabling this option will show metric efficiency statistics on the post flight s --- +### osd_switch_indicator_one_channel + +RC Channel to use for OSD switch indicator 1. + +| Default | Min | Max | +| --- | --- | --- | +| 5 | 5 | MAX_SUPPORTED_RC_CHANNEL_COUNT | + +--- + +### osd_switch_indicator_one_name + +Character to use for OSD switch incicator 1. + +| Default | Min | Max | +| --- | --- | --- | +| GEAR | | 5 | + +--- + +### osd_switch_indicator_three_channel + +RC Channel to use for OSD switch indicator 3. + +| Default | Min | Max | +| --- | --- | --- | +| 5 | 5 | MAX_SUPPORTED_RC_CHANNEL_COUNT | + +--- + +### osd_switch_indicator_three_name + +Character to use for OSD switch incicator 3. + +| Default | Min | Max | +| --- | --- | --- | +| LIGT | | 5 | + +--- + +### osd_switch_indicator_two_channel + +RC Channel to use for OSD switch indicator 2. + +| Default | Min | Max | +| --- | --- | --- | +| 5 | 5 | MAX_SUPPORTED_RC_CHANNEL_COUNT | + +--- + +### osd_switch_indicator_two_name + +Character to use for OSD switch incicator 2. + +| Default | Min | Max | +| --- | --- | --- | +| CAM | | 5 | + +--- + +### osd_switch_indicator_zero_channel + +RC Channel to use for OSD switch indicator 0. + +| Default | Min | Max | +| --- | --- | --- | +| 5 | 5 | MAX_SUPPORTED_RC_CHANNEL_COUNT | + +--- + +### osd_switch_indicator_zero_name + +Character to use for OSD switch incicator 0. + +| Default | Min | Max | +| --- | --- | --- | +| FLAP | | 5 | + +--- + +### osd_switch_indicators_align_left + +Align text to left of switch indicators + +| Default | Min | Max | +| --- | --- | --- | +| ON | OFF | ON | + +--- + ### osd_system_msg_display_time System message display cycle time for multiple messages (milliseconds). diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 1bd1400d0a6..00119727f34 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -3717,6 +3717,59 @@ groups: field: highlight_djis_missing_characters default_value: ON type: bool + - name: osd_switch_indicator_zero_name + description: "Character to use for OSD switch incicator 0." + field: osd_switch_indicator0_name + type: string + max: 5 + default_value: "FLAP" + - name: osd_switch_indicator_one_name + description: "Character to use for OSD switch incicator 1." + field: osd_switch_indicator1_name + type: string + max: 5 + default_value: "GEAR" + - name: osd_switch_indicator_two_name + description: "Character to use for OSD switch incicator 2." + field: osd_switch_indicator2_name + type: string + max: 5 + default_value: "CAM" + - name: osd_switch_indicator_three_name + description: "Character to use for OSD switch incicator 3." + field: osd_switch_indicator3_name + type: string + max: 5 + default_value: "LIGT" + - name: osd_switch_indicator_zero_channel + description: "RC Channel to use for OSD switch indicator 0." + field: osd_switch_indicator0_channel + min: 5 + max: MAX_SUPPORTED_RC_CHANNEL_COUNT + default_value: 5 + - name: osd_switch_indicator_one_channel + description: "RC Channel to use for OSD switch indicator 1." + field: osd_switch_indicator1_channel + min: 5 + max: MAX_SUPPORTED_RC_CHANNEL_COUNT + default_value: 5 + - name: osd_switch_indicator_two_channel + description: "RC Channel to use for OSD switch indicator 2." + field: osd_switch_indicator2_channel + min: 5 + max: MAX_SUPPORTED_RC_CHANNEL_COUNT + default_value: 5 + - name: osd_switch_indicator_three_channel + description: "RC Channel to use for OSD switch indicator 3." + field: osd_switch_indicator3_channel + min: 5 + max: MAX_SUPPORTED_RC_CHANNEL_COUNT + default_value: 5 + - name: osd_switch_indicators_align_left + description: "Align text to left of switch indicators" + field: osd_switch_indicators_align_left + type: bool + default_value: ON - name: PG_OSD_COMMON_CONFIG type: osdCommonConfig_t headers: ["io/osd_common.h"] diff --git a/src/main/io/osd.c b/src/main/io/osd.c index 77762c6a003..249359d4b6d 100644 --- a/src/main/io/osd.c +++ b/src/main/io/osd.c @@ -1610,6 +1610,40 @@ int8_t getGeoWaypointNumber(int8_t waypointIndex) return geoWaypointIndex - posControl.startWpIndex + 1; } +void osdDisplaySwitchIndicator(const char *swName, int rcValue, char *buff) { + int8_t ptr = 0; + + if (osdConfig()->osd_switch_indicators_align_left) { + for (ptr = 0; ptr < constrain(strlen(swName), 0, OSD_SWITCH_INDICATOR_NAME_LENGTH); ptr++) { + buff[ptr] = swName[ptr]; + } + + if ( rcValue < 1333) { + buff[ptr++] = SYM_SWITCH_INDICATOR_LOW; + } else if ( rcValue > 1666) { + buff[ptr++] = SYM_SWITCH_INDICATOR_HIGH; + } else { + buff[ptr++] = SYM_SWITCH_INDICATOR_MID; + } + } else { + if ( rcValue < 1333) { + buff[ptr++] = SYM_SWITCH_INDICATOR_LOW; + } else if ( rcValue > 1666) { + buff[ptr++] = SYM_SWITCH_INDICATOR_HIGH; + } else { + buff[ptr++] = SYM_SWITCH_INDICATOR_MID; + } + + for (ptr = 1; ptr < constrain(strlen(swName), 0, OSD_SWITCH_INDICATOR_NAME_LENGTH) + 1; ptr++) { + buff[ptr] = swName[ptr-1]; + } + + ptr++; + } + + buff[ptr] = '\0'; +} + static bool osdDrawSingleElement(uint8_t item) { uint16_t pos = osdLayoutsConfig()->item_pos[currentLayout][item]; @@ -2863,6 +2897,21 @@ static bool osdDrawSingleElement(uint8_t item) break; } #endif + case OSD_SWITCH_INDICATOR_0: + osdDisplaySwitchIndicator(osdConfig()->osd_switch_indicator0_name, rxGetChannelValue(osdConfig()->osd_switch_indicator0_channel - 1), buff); + break; + + case OSD_SWITCH_INDICATOR_1: + osdDisplaySwitchIndicator(osdConfig()->osd_switch_indicator1_name, rxGetChannelValue(osdConfig()->osd_switch_indicator1_channel - 1), buff); + break; + + case OSD_SWITCH_INDICATOR_2: + osdDisplaySwitchIndicator(osdConfig()->osd_switch_indicator2_name, rxGetChannelValue(osdConfig()->osd_switch_indicator2_channel - 1), buff); + break; + + case OSD_SWITCH_INDICATOR_3: + osdDisplaySwitchIndicator(osdConfig()->osd_switch_indicator3_name, rxGetChannelValue(osdConfig()->osd_switch_indicator3_channel - 1), buff); + break; case OSD_PAN_SERVO_CENTRED: { @@ -3983,6 +4032,15 @@ PG_RESET_TEMPLATE(osdConfig_t, osdConfig, .pan_servo_indicator_show_degrees = SETTING_OSD_PAN_SERVO_INDICATOR_SHOW_DEGREES_DEFAULT, .esc_rpm_precision = SETTING_OSD_ESC_RPM_PRECISION_DEFAULT, .mAh_precision = SETTING_OSD_MAH_PRECISION_DEFAULT, + .osd_switch_indicator0_name = SETTING_OSD_SWITCH_INDICATOR_ZERO_NAME_DEFAULT, + .osd_switch_indicator0_channel = SETTING_OSD_SWITCH_INDICATOR_ZERO_CHANNEL_DEFAULT, + .osd_switch_indicator1_name = SETTING_OSD_SWITCH_INDICATOR_ONE_NAME_DEFAULT, + .osd_switch_indicator1_channel = SETTING_OSD_SWITCH_INDICATOR_ONE_CHANNEL_DEFAULT, + .osd_switch_indicator2_name = SETTING_OSD_SWITCH_INDICATOR_TWO_NAME_DEFAULT, + .osd_switch_indicator2_channel = SETTING_OSD_SWITCH_INDICATOR_TWO_CHANNEL_DEFAULT, + .osd_switch_indicator3_name = SETTING_OSD_SWITCH_INDICATOR_THREE_NAME_DEFAULT, + .osd_switch_indicator3_channel = SETTING_OSD_SWITCH_INDICATOR_THREE_CHANNEL_DEFAULT, + .osd_switch_indicators_align_left = SETTING_OSD_SWITCH_INDICATORS_ALIGN_LEFT_DEFAULT, .system_msg_display_time = SETTING_OSD_SYSTEM_MSG_DISPLAY_TIME_DEFAULT, .units = SETTING_OSD_UNITS_DEFAULT, .main_voltage_decimals = SETTING_OSD_MAIN_VOLTAGE_DECIMALS_DEFAULT, @@ -4157,6 +4215,11 @@ void pgResetFn_osdLayoutsConfig(osdLayoutsConfig_t *osdLayoutsConfig) osdLayoutsConfig->item_pos[0][OSD_MULTI_FUNCTION] = OSD_POS(1, 4); + osdLayoutsConfig->item_pos[0][OSD_SWITCH_INDICATOR_0] = OSD_POS(2, 7); + osdLayoutsConfig->item_pos[0][OSD_SWITCH_INDICATOR_1] = OSD_POS(2, 8); + osdLayoutsConfig->item_pos[0][OSD_SWITCH_INDICATOR_2] = OSD_POS(2, 9); + osdLayoutsConfig->item_pos[0][OSD_SWITCH_INDICATOR_3] = OSD_POS(2, 10); + osdLayoutsConfig->item_pos[0][OSD_ADSB_WARNING] = OSD_POS(2, 7); osdLayoutsConfig->item_pos[0][OSD_ADSB_INFO] = OSD_POS(2, 8); #if defined(USE_ESC_SENSOR) diff --git a/src/main/io/osd.h b/src/main/io/osd.h index 2e5200a0483..0cf93b69162 100644 --- a/src/main/io/osd.h +++ b/src/main/io/osd.h @@ -263,10 +263,10 @@ typedef enum { OSD_AIR_MAX_SPEED, OSD_ACTIVE_PROFILE, OSD_MISSION, - OSD_CUSTOM_ELEMENT_4, - OSD_CUSTOM_ELEMENT_5, - OSD_CUSTOM_ELEMENT_6, - OSD_CUSTOM_ELEMENT_7, + OSD_SWITCH_INDICATOR_0, + OSD_SWITCH_INDICATOR_1, + OSD_SWITCH_INDICATOR_2, + OSD_SWITCH_INDICATOR_3, OSD_TPA_TIME_CONSTANT, OSD_FW_LEVEL_TRIM, OSD_GLIDE_TIME_REMAINING, @@ -287,7 +287,11 @@ typedef enum { OSD_ADSB_INFO, OSD_BLACKBOX, OSD_FORMATION_FLIGHT, - OSD_CUSTOM_ELEMENT_8, // 154 + OSD_CUSTOM_ELEMENT_4, + OSD_CUSTOM_ELEMENT_5, + OSD_CUSTOM_ELEMENT_6, + OSD_CUSTOM_ELEMENT_7, + OSD_CUSTOM_ELEMENT_8, // 158 OSD_ITEM_COUNT // MUST BE LAST } osd_items_e; @@ -348,6 +352,8 @@ typedef struct osdLayoutsConfig_s { PG_DECLARE(osdLayoutsConfig_t, osdLayoutsConfig); +#define OSD_SWITCH_INDICATOR_NAME_LENGTH 4 + typedef struct osdConfig_s { // Alarms uint8_t rssi_alarm; // rssi % @@ -445,6 +451,15 @@ typedef struct osdConfig_s { uint16_t system_msg_display_time; // system message display time for multiple messages (ms) uint8_t mAh_precision; // Number of numbers used for mAh drawn. Plently of packs now are > 9999 mAh uint8_t ahi_pitch_interval; // redraws AHI at set pitch interval (Not pixel OSD) + char osd_switch_indicator0_name[OSD_SWITCH_INDICATOR_NAME_LENGTH + 1]; // Name to use for switch indicator 0. + uint8_t osd_switch_indicator0_channel; // RC Channel to use for switch indicator 0. + char osd_switch_indicator1_name[OSD_SWITCH_INDICATOR_NAME_LENGTH + 1]; // Name to use for switch indicator 1. + uint8_t osd_switch_indicator1_channel; // RC Channel to use for switch indicator 1. + char osd_switch_indicator2_name[OSD_SWITCH_INDICATOR_NAME_LENGTH + 1]; // Name to use for switch indicator 2. + uint8_t osd_switch_indicator2_channel; // RC Channel to use for switch indicator 2. + char osd_switch_indicator3_name[OSD_SWITCH_INDICATOR_NAME_LENGTH + 1]; // Name to use for switch indicator 3. + uint8_t osd_switch_indicator3_channel; // RC Channel to use for switch indicator 3. + bool osd_switch_indicators_align_left; // Align switch indicator name to left of the switch. bool use_pilot_logo; // If enabled, the pilot logo (last 40 characters of page 2 font) will be used with the INAV logo. uint8_t inav_to_pilot_logo_spacing; // The space between the INAV and pilot logos, if pilot logo is used. This number may be adjusted so that it fits the odd/even col width. uint16_t arm_screen_display_time; // Length of time the arm screen is displayed