diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 2f4dff21..7cb52170 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -2566,5 +2566,14 @@ }, "confirm_reset_settings": { "message": "Do you really want to reset all settings?\nATTENTION: All settings are lost! You have to setup the whole aircraft after this operation!" + }, + "mappingTableOutput": { + "message": "Output" + }, + "mappingTableFunction": { + "message": "Function" + }, + "mappingTableTitle": { + "message": "Output Mapping" } } diff --git a/js/outputMapping.js b/js/outputMapping.js index 19860919..227077ac 100644 --- a/js/outputMapping.js +++ b/js/outputMapping.js @@ -24,6 +24,23 @@ let OutputMappingCollection = function () { data.push(element); }; + self.getOutputCount = function () { + let retVal = 0; + + for (let i = 0; i < data.length; i++) { + if ( + bit_check(data[i], TIM_USE_MC_MOTOR) || + bit_check(data[i], TIM_USE_MC_SERVO) || + bit_check(data[i], TIM_USE_FW_MOTOR) || + bit_check(data[i], TIM_USE_FW_SERVO) + ) { + retVal++; + }; + } + + return retVal; + } + function getFirstOutputOffset() { for (let i = 0; i < data.length; i++) { if ( diff --git a/src/css/tabs/mixer.css b/src/css/tabs/mixer.css index 96522ad7..eb5218ef 100644 --- a/src/css/tabs/mixer.css +++ b/src/css/tabs/mixer.css @@ -40,4 +40,38 @@ .mixer-table tr:nth-child(even) td { background-color: #ebe7e7; +} + +.tab-mixer .rightWrapper { + margin-bottom: 0 !important; +} + +.output-table { + width: 100%; + border-spacing: 1px; + border-collapse: separate; +} + +.output-table th { + background-color: #828885; + color: #fff; + text-align: left; + padding-left: 1em; +} + +.output-table td { + text-align: center; + padding: 2px; +} + +.output-table td, .output-table th { + height: 2.2em; +} + +.output-table #output-row td { + font-weight: bold; +} + +.output-table #function-row td { + background-color: #ebe7e7; } \ No newline at end of file diff --git a/tabs/mixer.html b/tabs/mixer.html index 7b44fe47..45245841 100644 --- a/tabs/mixer.html +++ b/tabs/mixer.html @@ -52,6 +52,23 @@
+ +
+
+
+
+ + + + + + + +
+
+ + +
diff --git a/tabs/mixer.js b/tabs/mixer.js index 1a9f6f5f..b09a3a56 100644 --- a/tabs/mixer.js +++ b/tabs/mixer.js @@ -23,7 +23,8 @@ TABS.mixer.initialize = function (callback, scrollPosition) { mspHelper.loadMixerConfig, mspHelper.loadMotors, mspHelper.loadServoMixRules, - mspHelper.loadMotorMixRules + mspHelper.loadMotorMixRules, + mspHelper.loadOutputMapping ]); loadChainer.setExitPoint(loadHtml); loadChainer.execute(); @@ -55,6 +56,58 @@ TABS.mixer.initialize = function (callback, scrollPosition) { $('#content').load("./tabs/mixer.html", processHtml); } + function renderOutputTable() { + let outputCount = OUTPUT_MAPPING.getOutputCount(), + $outputRow = $('#output-row'), + $functionRow = $('#function-row'); + + $outputRow.append(''); + $functionRow.append(''); + + for (let i = 1; i <= outputCount; i++) { + $outputRow.append('S' + i + ''); + $functionRow.append('-'); + } + + $outputRow.find('td').css('width', 100 / (outputCount + 1) + '%'); + + } + + function renderOutputMapping() { + let motorRules = MOTOR_RULES.get(), + servoRules = SERVO_RULES.get(), + output; + + for (let index in motorRules) { + if (motorRules.hasOwnProperty(index) && motorRules[index].isUsed()) { + if (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER) { + output = OUTPUT_MAPPING.getMrMotorOutput(index); + } else { + output = OUTPUT_MAPPING.getFwMotorOutput(index); + } + if (output !== null) { + $('#function-' + output).html("Motor " + index); + } + } + } + + let usedServoIndex = 0; + for (let i = 0; i < MIXER_CONFIG.numberOfServos; i++) { + if (SERVO_RULES.isServoConfigured(i)) { + console.log(i, usedServoIndex); + if (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER) { + output = OUTPUT_MAPPING.getMrServoOutput(usedServoIndex); + } else { + output = OUTPUT_MAPPING.getFwServoOutput(usedServoIndex); + } + if (output !== null) { + $('#function-' + output).html("Servo " + i); + } + usedServoIndex++; + } + } + } + function renderServoMixRules() { /* * Process servo mix table UI @@ -258,6 +311,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) { helper.mixer.loadMotorRules(currentMixerPreset); renderServoMixRules(); renderMotorMixRules(); + renderOutputMapping(); modal.close(); saveAndReboot(); }); @@ -267,22 +321,26 @@ TABS.mixer.initialize = function (callback, scrollPosition) { helper.mixer.loadMotorRules(currentMixerPreset); renderServoMixRules(); renderMotorMixRules(); + renderOutputMapping(); }); $servoMixTableBody.on('click', "[data-role='role-servo-delete']", function (event) { SERVO_RULES.drop($(event.currentTarget).attr("data-index")); renderServoMixRules(); + renderOutputMapping(); }); $motorMixTableBody.on('click', "[data-role='role-motor-delete']", function (event) { MOTOR_RULES.drop($(event.currentTarget).attr("data-index")); renderMotorMixRules(); + renderOutputMapping(); }); $("[data-role='role-servo-add']").click(function () { if (SERVO_RULES.hasFreeSlots()) { SERVO_RULES.put(new ServoMixRule(0, 0, 100, 0)); renderServoMixRules(); + renderOutputMapping(); } }); @@ -290,6 +348,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) { if (MOTOR_RULES.hasFreeSlots()) { MOTOR_RULES.put(new MotorMixRule(1, 0, 0, 0)); renderMotorMixRules(); + renderOutputMapping(); } }); @@ -298,6 +357,9 @@ TABS.mixer.initialize = function (callback, scrollPosition) { renderServoMixRules(); renderMotorMixRules(); + renderOutputTable(); + renderOutputMapping(); + localize(); GUI.content_ready(callback); }