From c98bf6e0137d6bddc0056d0c231091e0dd7200eb Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sat, 11 May 2024 23:47:19 +0200 Subject: [PATCH 1/9] Allow reassignment of led pin to servos or motors --- js/bitHelper.js | 2 +- js/msp/MSPCodes.js | 1 + js/msp/MSPHelper.js | 11 +++++++---- js/outputMapping.js | 13 +++++++++++-- tabs/mixer.js | 1 + 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/js/bitHelper.js b/js/bitHelper.js index 13df5b92c..bee166d4a 100644 --- a/js/bitHelper.js +++ b/js/bitHelper.js @@ -17,7 +17,7 @@ var BitHelper = function() { } self.bit_check = function (num, bit) { - return ((num >> bit) % 2 != 0); + return ((1 << bit) & num) != 0; } self.bit_set = function (num, bit) { diff --git a/js/msp/MSPCodes.js b/js/msp/MSPCodes.js index 66d3fd6e8..de0de07df 100644 --- a/js/msp/MSPCodes.js +++ b/js/msp/MSPCodes.js @@ -166,6 +166,7 @@ var MSPCodes = { MSP2_INAV_MC_BRAKING: 0x200B, MSP2_INAV_SET_MC_BRAKING: 0x200C, MSPV2_INAV_OUTPUT_MAPPING_EXT: 0x200D, + MSPV2_INAV_OUTPUT_MAPPING_EXT2: 0x210D, MSP2_INAV_TIMER_OUTPUT_MODE: 0x200E, MSP2_INAV_SET_TIMER_OUTPUT_MODE: 0x200F, diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 4e45369b2..74328a293 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -1423,6 +1423,7 @@ var mspHelper = (function () { case MSPCodes.MSP2_INAV_SET_CUSTOM_OSD_ELEMENTS: console.log('OSD custom elements preferences saved'); break; +/* case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING: FC.OUTPUT_MAPPING.flush(); for (let i = 0; i < data.byteLength; ++i) @@ -1430,11 +1431,12 @@ var mspHelper = (function () { 'timerId': i, 'usageFlags': data.getUint8(i)}); break; - case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING_EXT: + */ + case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING_EXT2: FC.OUTPUT_MAPPING.flush(); - for (let i = 0; i < data.byteLength; i += 2) { + for (let i = 0; i < data.byteLength; i += 5) { let timerId = data.getUint8(i); - let usageFlags = data.getUint8(i + 1); + let usageFlags = data.getUint32(i + 1, true); FC.OUTPUT_MAPPING.put( { 'timerId': timerId, @@ -2784,11 +2786,12 @@ var mspHelper = (function () { }; self.loadOutputMapping = function (callback) { + alert('Obsolete MSPHelper.loadOutputMapping call'); MSP.send_message(MSPCodes.MSPV2_INAV_OUTPUT_MAPPING, false, false, callback); }; self.loadOutputMappingExt = function (callback) { - MSP.send_message(MSPCodes.MSPV2_INAV_OUTPUT_MAPPING_EXT, false, false, callback); + MSP.send_message(MSPCodes.MSPV2_INAV_OUTPUT_MAPPING_EXT2, false, false, callback); }; self.loadTimerOutputModes = function(callback) { diff --git a/js/outputMapping.js b/js/outputMapping.js index 28be64498..eecd63878 100644 --- a/js/outputMapping.js +++ b/js/outputMapping.js @@ -30,6 +30,7 @@ var OutputMappingCollection = function () { const OUTPUT_TYPE_MOTOR = 0; const OUTPUT_TYPE_SERVO = 1; + const OUTPUT_TYPE_LED = 2; self.TIMER_OUTPUT_MODE_AUTO = 0; self.TIMER_OUTPUT_MODE_MOTORS = 1; @@ -98,6 +99,7 @@ var OutputMappingCollection = function () { outputMap = [], offset = getFirstOutputOffset(); + for (let i = 0; i < self.getOutputCount(); i++) { let assignment = timerMap[i + offset]; @@ -110,6 +112,8 @@ var OutputMappingCollection = function () { } else if (assignment == OUTPUT_TYPE_SERVO) { outputMap[i] = "Servo " + servos[currentServoIndex]; currentServoIndex++; + } else if (assignment == OUTPUT_TYPE_LED) { + outputMap[i] = "Led"; } } @@ -126,12 +130,17 @@ var OutputMappingCollection = function () { self.getOutputCount = function () { let retVal = 0; + let testFlag = 1 << TIM_USE_LED; + testFlag = testFlag + 1; for (let i = 0; i < data.length; i++) { + let flags = data[i]['usageFlags']; if ( - BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_MOTOR) || - BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO) + BitHelper.bit_check(flags, TIM_USE_MOTOR) || + BitHelper.bit_check(flags, TIM_USE_SERVO) || + BitHelper.bit_check(flags, TIM_USE_LED) ) { + //alert("Found motor, servo or led"); retVal++; }; } diff --git a/tabs/mixer.js b/tabs/mixer.js index 7e5e9d550..e3470c69c 100644 --- a/tabs/mixer.js +++ b/tabs/mixer.js @@ -129,6 +129,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) { 'AUTO'+ 'MOTORS'+ 'SERVOS'+ + 'LED'+ '' + '' + ' Timer ' + (parseInt(t) + 1) + '' + From b7b81b41c4d0a413e43e30c95f18fd5037641bbf Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sun, 12 May 2024 10:55:37 +0200 Subject: [PATCH 2/9] Fix output display when a remmaped led output overlaps motors/servos --- js/outputMapping.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/js/outputMapping.js b/js/outputMapping.js index eecd63878..40dc3f907 100644 --- a/js/outputMapping.js +++ b/js/outputMapping.js @@ -35,6 +35,7 @@ var OutputMappingCollection = function () { self.TIMER_OUTPUT_MODE_AUTO = 0; self.TIMER_OUTPUT_MODE_MOTORS = 1; self.TIMER_OUTPUT_MODE_SERVOS = 2; + self.TIMER_OUTPUT_MODE_LED = 3; self.flushTimerOverrides = function() { timerOverrides = {}; @@ -80,10 +81,15 @@ var OutputMappingCollection = function () { for (let i = 0; i < data.length; i++) { timerMap[i] = null; - if (servosToGo > 0 && BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO)) { + if (servosToGo > 0 && BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_LED)) { + console.log(i + ": LED"); + timerMap[i] = OUTPUT_TYPE_LED; + } else if (servosToGo > 0 && BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO)) { + console.log(i + ": SERVO"); servosToGo--; timerMap[i] = OUTPUT_TYPE_SERVO; } else if (motorsToGo > 0 && BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_MOTOR)) { + console.log(i + ": MOTOR"); motorsToGo--; timerMap[i] = OUTPUT_TYPE_MOTOR; } @@ -99,7 +105,7 @@ var OutputMappingCollection = function () { outputMap = [], offset = getFirstOutputOffset(); - + console.log("Offset: " + offset) for (let i = 0; i < self.getOutputCount(); i++) { let assignment = timerMap[i + offset]; @@ -130,8 +136,6 @@ var OutputMappingCollection = function () { self.getOutputCount = function () { let retVal = 0; - let testFlag = 1 << TIM_USE_LED; - testFlag = testFlag + 1; for (let i = 0; i < data.length; i++) { let flags = data[i]['usageFlags']; @@ -140,7 +144,6 @@ var OutputMappingCollection = function () { BitHelper.bit_check(flags, TIM_USE_SERVO) || BitHelper.bit_check(flags, TIM_USE_LED) ) { - //alert("Found motor, servo or led"); retVal++; }; } @@ -152,7 +155,8 @@ var OutputMappingCollection = function () { for (let i = 0; i < data.length; i++) { if ( BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_MOTOR) || - BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO) + BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_SERVO) || + BitHelper.bit_check(data[i]['usageFlags'], TIM_USE_LED) ) { return i; } From 3b7504ce5df20344a8f3e73d77c0fea546d5ba5e Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Sun, 19 May 2024 17:38:47 +0200 Subject: [PATCH 3/9] quick fix --- tabs/outputs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/outputs.js b/tabs/outputs.js index 5a8ff5beb..d936d18af 100644 --- a/tabs/outputs.js +++ b/tabs/outputs.js @@ -46,7 +46,7 @@ TABS.outputs.initialize = function (callback) { mspHelper.loadServoMixRules, mspHelper.loadMixerConfig, mspHelper.loadServoConfiguration, - mspHelper.loadOutputMapping, + mspHelper.loadOutputMappingExt, mspHelper.loadRcData, mspHelper.loadAdvancedConfig, function(callback) { From efb04926e0b754d4021f819bc06b89fa95f32851 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Tue, 28 May 2024 23:09:43 +0200 Subject: [PATCH 4/9] Fix for mixer tab not loading --- tabs/mixer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tabs/mixer.js b/tabs/mixer.js index 1adfb02e9..6c257e62f 100644 --- a/tabs/mixer.js +++ b/tabs/mixer.js @@ -654,7 +654,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) { const updateMotorDirection = function () { let motorDirectionCheckbox = $('input[name=motor_direction_inverted]:checked'); - const isReversed = motorDirectionCheckbox.val() == 1 && (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER); + const isReversed = motorDirectionCheckbox.val() == 1 && (FC.MIXER_CONFIG.platformType == PLATFORM.MULTIROTOR || FC.MIXER_CONFIG.platformType == PLATFORM.TRICOPTER); const path = './resources/motor_order/' + currentMixerPreset.image + (isReversed ? "_reverse" : "") + '.svg'; From 16b212e244b119c126d03898fec7d3a5c19f427d Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Fri, 31 May 2024 17:30:44 +0200 Subject: [PATCH 5/9] Use new special label info from msp to tag led pin. --- js/msp/MSPHelper.js | 6 ++++-- js/outputMapping.js | 6 ++++++ tabs/mixer.js | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 1f19b2a9e..613fb7445 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -1420,13 +1420,15 @@ var mspHelper = (function () { */ case MSPCodes.MSPV2_INAV_OUTPUT_MAPPING_EXT2: FC.OUTPUT_MAPPING.flush(); - for (let i = 0; i < data.byteLength; i += 5) { + for (let i = 0; i < data.byteLength; i += 6) { let timerId = data.getUint8(i); let usageFlags = data.getUint32(i + 1, true); + let specialLabels = data.getUint8(i + 5); FC.OUTPUT_MAPPING.put( { 'timerId': timerId, - 'usageFlags': usageFlags + 'usageFlags': usageFlags, + 'specialLabels': specialLabels }); } break; diff --git a/js/outputMapping.js b/js/outputMapping.js index 40dc3f907..7a92f7c13 100644 --- a/js/outputMapping.js +++ b/js/outputMapping.js @@ -32,6 +32,8 @@ var OutputMappingCollection = function () { const OUTPUT_TYPE_SERVO = 1; const OUTPUT_TYPE_LED = 2; + const SPECIAL_LABEL_LED = 1; + self.TIMER_OUTPUT_MODE_AUTO = 0; self.TIMER_OUTPUT_MODE_MOTORS = 1; self.TIMER_OUTPUT_MODE_SERVOS = 2; @@ -55,6 +57,10 @@ var OutputMappingCollection = function () { return colorTable[timerIndex % colorTable.length]; } + self.isLedPin = function(timer) { + return data[timer].specialLabels == SPECIAL_LABEL_LED; + } + self.getOutputTimerColor = function (output) { let timerId = self.getTimerId(output); diff --git a/tabs/mixer.js b/tabs/mixer.js index 0604190d4..bdd41a419 100644 --- a/tabs/mixer.js +++ b/tabs/mixer.js @@ -94,8 +94,9 @@ TABS.mixer.initialize = function (callback, scrollPosition) { let timerId = FC.OUTPUT_MAPPING.getTimerId(i - 1); let color = FC.OUTPUT_MAPPING.getOutputTimerColor(i - 1); + let isLed = FC.OUTPUT_MAPPING.isLedPin(i - 1); - $outputRow.append('S' + i + ' (Timer ' + (timerId + 1) + ')'); + $outputRow.append('S' + i + (isLed ? '/LED' : '') + ' (Timer ' + (timerId + 1) + ')'); $functionRow.append('-'); } From fb12da14dbd1e0619e0ed33219f27bb9ffbc31b6 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sun, 2 Jun 2024 16:17:52 +0100 Subject: [PATCH 6/9] Add Battery Profile to programming framework --- js/logicConditionOperantTypes.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/logicConditionOperantTypes.js b/js/logicConditionOperantTypes.js index 98ba42ff3..024f40a40 100644 --- a/js/logicConditionOperantTypes.js +++ b/js/logicConditionOperantTypes.js @@ -53,15 +53,16 @@ const OPERAND_TYPES = { 30: "CRSF SNR", 31: "GPS Valid Fix", 32: "Loiter Radius [cm]", - 33: "Active PIDProfile", + 33: "Active PID Profile", 34: "Battery cells", 35: "AGL status [0/1]", 36: "AGL [cm]", 37: "Rangefinder [cm]", - 38: "Active MixerProfile", + 38: "Active Mixer Profile", 39: "MixerTransition Active", 40: "Yaw [deg]", - 41: "FW Land State" + 41: "FW Land State", + 42: "Active Battery Profile", } }, 3: { From 164f9c7c20237cdcee411953b72102cb67aff855 Mon Sep 17 00:00:00 2001 From: Darren Lines Date: Sun, 2 Jun 2024 18:54:28 +0100 Subject: [PATCH 7/9] Consolidate the old `PIDProfile` and `Profile` in to `Control Profile` - Consolidate the old `PIDProfile` and `Profile` in to `Control Profile` - Improve consistency by maintaining the order of `Control Profile`, `Mixer Profile`, and `Battery Profile`. - Added missing `Set Heading Target` operator to the programming UI --- index.html | 20 ++++++++++---------- js/logicConditionOperantTypes.js | 4 ++-- js/logicConditionOperators.js | 9 ++++++++- js/msp/MSPHelper.js | 2 +- locale/en/messages.json | 10 +++++----- src/css/main.css | 4 ++-- 6 files changed, 28 insertions(+), 21 deletions(-) diff --git a/index.html b/index.html index e41c0f288..651930611 100644 --- a/index.html +++ b/index.html @@ -95,16 +95,6 @@ - - - - - - - - - - @@ -117,6 +107,16 @@ + + + + + + + + + + diff --git a/js/logicConditionOperantTypes.js b/js/logicConditionOperantTypes.js index 98ba42ff3..99599ca69 100644 --- a/js/logicConditionOperantTypes.js +++ b/js/logicConditionOperantTypes.js @@ -53,13 +53,13 @@ const OPERAND_TYPES = { 30: "CRSF SNR", 31: "GPS Valid Fix", 32: "Loiter Radius [cm]", - 33: "Active PIDProfile", + 33: "Active Control Profile", 34: "Battery cells", 35: "AGL status [0/1]", 36: "AGL [cm]", 37: "Rangefinder [cm]", 38: "Active MixerProfile", - 39: "MixerTransition Active", + 39: "Mixer Transition Active", 40: "Yaw [deg]", 41: "FW Land State" } diff --git a/js/logicConditionOperators.js b/js/logicConditionOperators.js index 76e515ddd..115affbd2 100644 --- a/js/logicConditionOperators.js +++ b/js/logicConditionOperators.js @@ -242,6 +242,13 @@ const LOGIC_OPERATORS = { output: "boolean" }, + 39: { + name: "Set Heading Target", + operandType: "Set Flight Parameter", + hasOperand: [true, false], + output: "raw" + }, + 41: { name: "Override Loiter Radius", operandType: "Set Flight Parameter", @@ -249,7 +256,7 @@ const LOGIC_OPERATORS = { output: "boolean" }, 42: { - name: "Set Profile", + name: "Set Control Profile", operandType: "Set Flight Parameter", hasOperand: [true, false], output: "boolean" diff --git a/js/msp/MSPHelper.js b/js/msp/MSPHelper.js index 613fb7445..383b99bbd 100644 --- a/js/msp/MSPHelper.js +++ b/js/msp/MSPHelper.js @@ -1319,7 +1319,7 @@ var mspHelper = (function () { console.log('Looptime saved'); break; case MSPCodes.MSP_SET_RESET_CURR_PID: - console.log('Current PID profile reset'); + console.log('Current Control profile reset'); break; case MSPCodes.MSP_SET_3D: console.log('3D settings saved'); diff --git a/locale/en/messages.json b/locale/en/messages.json index c5e53172e..031f2be01 100644 --- a/locale/en/messages.json +++ b/locale/en/messages.json @@ -5132,10 +5132,10 @@ "message": "Enable if the motor direction is reversed and the props are mounted in the opposite direction." }, "mixer_pid_profile_linking": { - "message": "PID Profile will use same index as Mixer Profile index" + "message": "Control Profile will use same index as Mixer Profile index" }, "mixer_pid_profile_linking_hint": { - "message": "mixer_pid_profile_linking: Enable on both Mixer Profile if you want PID Profile switching handled by Mixer Profile switching(Recommend in vtol/mixed plaform type setup)" + "message": "mixer_pid_profile_linking: Enable on both Mixer Profile if you want Control Profile switching handled by Mixer Profile switching(Recommend in vtol/mixed plaform type setup)" }, "blackboxFields": { "message": "Blackbox fields" @@ -5459,13 +5459,13 @@ "message": "Mixer Profile 2" }, "sensorProfile1": { - "message": "PID Profile 1" + "message": "Control Profile 1" }, "sensorProfile2": { - "message": "PID Profile 2" + "message": "Control Profile 2" }, "sensorProfile3": { - "message": "PID Profile 3" + "message": "Control Profile 3" }, "sensorBatteryProfile1": { "message": "Battery Profile 1" diff --git a/src/css/main.css b/src/css/main.css index 9baa8f7b1..06cc62f70 100644 --- a/src/css/main.css +++ b/src/css/main.css @@ -1700,7 +1700,7 @@ dialog { } -#mixer_profile_change { +#profile_change { color: white; margin-top: 16px; width: 130px; @@ -1709,7 +1709,7 @@ dialog { line-height: 12px; } -#profile_change { +#mixer_profile_change { color: white; margin-top: 16px; width: 130px; From cd9b08a21b46bf2a8765ea69a8ff0381032c4b4b Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:10:47 +0200 Subject: [PATCH 8/9] Add head tracking source to mixer --- js/fc.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/fc.js b/js/fc.js index aad9a460a..38842fa00 100644 --- a/js/fc.js +++ b/js/fc.js @@ -941,6 +941,9 @@ var FC = { 'GVAR 6', // 36 'GVAR 7', // 37 'Mixer Transition', // 38 + 'Head Tracker Pan', // 39 + 'Head Tracker Tilt', // 40 + 'Head Tracker Roll', // 41 ]; }, getServoMixInputName: function (input) { @@ -1116,4 +1119,4 @@ var FC = { } }; -module.exports = FC; \ No newline at end of file +module.exports = FC; From 1887fe142d9148a4ce7c77af236a2e2067cacce2 Mon Sep 17 00:00:00 2001 From: Marcelo Bezerra <23555060+mmosca@users.noreply.github.com> Date: Mon, 10 Jun 2024 16:17:52 +0200 Subject: [PATCH 9/9] Revert "Add head tracking source to mixer" This reverts commit cd9b08a21b46bf2a8765ea69a8ff0381032c4b4b. --- js/fc.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/js/fc.js b/js/fc.js index 38842fa00..aad9a460a 100644 --- a/js/fc.js +++ b/js/fc.js @@ -941,9 +941,6 @@ var FC = { 'GVAR 6', // 36 'GVAR 7', // 37 'Mixer Transition', // 38 - 'Head Tracker Pan', // 39 - 'Head Tracker Tilt', // 40 - 'Head Tracker Roll', // 41 ]; }, getServoMixInputName: function (input) { @@ -1119,4 +1116,4 @@ var FC = { } }; -module.exports = FC; +module.exports = FC; \ No newline at end of file