mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-15 20:35:19 +03:00
Output mapping in mixer tab
This commit is contained in:
parent
83bd7ac67f
commit
b099f68281
5 changed files with 140 additions and 1 deletions
|
@ -2566,5 +2566,14 @@
|
||||||
},
|
},
|
||||||
"confirm_reset_settings": {
|
"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!"
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,23 @@ let OutputMappingCollection = function () {
|
||||||
data.push(element);
|
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() {
|
function getFirstOutputOffset() {
|
||||||
for (let i = 0; i < data.length; i++) {
|
for (let i = 0; i < data.length; i++) {
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -40,4 +40,38 @@
|
||||||
|
|
||||||
.mixer-table tr:nth-child(even) td {
|
.mixer-table tr:nth-child(even) td {
|
||||||
background-color: #ebe7e7;
|
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;
|
||||||
}
|
}
|
|
@ -52,6 +52,23 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clear-both"></div>
|
<div class="clear-both"></div>
|
||||||
|
|
||||||
|
<div class="gui_box grey">
|
||||||
|
<div class="gui_box_titlebar">
|
||||||
|
<div class="spacer_box_title" data-i18n="mappingTableTitle"></div>
|
||||||
|
</div>
|
||||||
|
<table class="output-table">
|
||||||
|
<tr id="output-row">
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr id="function-row">
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- middle roew -->
|
||||||
|
<div class="clear-both"></div>
|
||||||
<!-- bottom row -->
|
<!-- bottom row -->
|
||||||
<div>
|
<div>
|
||||||
<div class="leftWrapper">
|
<div class="leftWrapper">
|
||||||
|
|
|
@ -23,7 +23,8 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
||||||
mspHelper.loadMixerConfig,
|
mspHelper.loadMixerConfig,
|
||||||
mspHelper.loadMotors,
|
mspHelper.loadMotors,
|
||||||
mspHelper.loadServoMixRules,
|
mspHelper.loadServoMixRules,
|
||||||
mspHelper.loadMotorMixRules
|
mspHelper.loadMotorMixRules,
|
||||||
|
mspHelper.loadOutputMapping
|
||||||
]);
|
]);
|
||||||
loadChainer.setExitPoint(loadHtml);
|
loadChainer.setExitPoint(loadHtml);
|
||||||
loadChainer.execute();
|
loadChainer.execute();
|
||||||
|
@ -55,6 +56,58 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
||||||
$('#content').load("./tabs/mixer.html", processHtml);
|
$('#content').load("./tabs/mixer.html", processHtml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderOutputTable() {
|
||||||
|
let outputCount = OUTPUT_MAPPING.getOutputCount(),
|
||||||
|
$outputRow = $('#output-row'),
|
||||||
|
$functionRow = $('#function-row');
|
||||||
|
|
||||||
|
$outputRow.append('<th data-i18n="mappingTableOutput"></th>');
|
||||||
|
$functionRow.append('<th data-i18n="mappingTableFunction"></th>');
|
||||||
|
|
||||||
|
for (let i = 1; i <= outputCount; i++) {
|
||||||
|
$outputRow.append('<td>S' + i + '</td>');
|
||||||
|
$functionRow.append('<td id="function-' + i +'">-</td>');
|
||||||
|
}
|
||||||
|
|
||||||
|
$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() {
|
function renderServoMixRules() {
|
||||||
/*
|
/*
|
||||||
* Process servo mix table UI
|
* Process servo mix table UI
|
||||||
|
@ -258,6 +311,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
||||||
helper.mixer.loadMotorRules(currentMixerPreset);
|
helper.mixer.loadMotorRules(currentMixerPreset);
|
||||||
renderServoMixRules();
|
renderServoMixRules();
|
||||||
renderMotorMixRules();
|
renderMotorMixRules();
|
||||||
|
renderOutputMapping();
|
||||||
modal.close();
|
modal.close();
|
||||||
saveAndReboot();
|
saveAndReboot();
|
||||||
});
|
});
|
||||||
|
@ -267,22 +321,26 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
||||||
helper.mixer.loadMotorRules(currentMixerPreset);
|
helper.mixer.loadMotorRules(currentMixerPreset);
|
||||||
renderServoMixRules();
|
renderServoMixRules();
|
||||||
renderMotorMixRules();
|
renderMotorMixRules();
|
||||||
|
renderOutputMapping();
|
||||||
});
|
});
|
||||||
|
|
||||||
$servoMixTableBody.on('click', "[data-role='role-servo-delete']", function (event) {
|
$servoMixTableBody.on('click', "[data-role='role-servo-delete']", function (event) {
|
||||||
SERVO_RULES.drop($(event.currentTarget).attr("data-index"));
|
SERVO_RULES.drop($(event.currentTarget).attr("data-index"));
|
||||||
renderServoMixRules();
|
renderServoMixRules();
|
||||||
|
renderOutputMapping();
|
||||||
});
|
});
|
||||||
|
|
||||||
$motorMixTableBody.on('click', "[data-role='role-motor-delete']", function (event) {
|
$motorMixTableBody.on('click', "[data-role='role-motor-delete']", function (event) {
|
||||||
MOTOR_RULES.drop($(event.currentTarget).attr("data-index"));
|
MOTOR_RULES.drop($(event.currentTarget).attr("data-index"));
|
||||||
renderMotorMixRules();
|
renderMotorMixRules();
|
||||||
|
renderOutputMapping();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("[data-role='role-servo-add']").click(function () {
|
$("[data-role='role-servo-add']").click(function () {
|
||||||
if (SERVO_RULES.hasFreeSlots()) {
|
if (SERVO_RULES.hasFreeSlots()) {
|
||||||
SERVO_RULES.put(new ServoMixRule(0, 0, 100, 0));
|
SERVO_RULES.put(new ServoMixRule(0, 0, 100, 0));
|
||||||
renderServoMixRules();
|
renderServoMixRules();
|
||||||
|
renderOutputMapping();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -290,6 +348,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
||||||
if (MOTOR_RULES.hasFreeSlots()) {
|
if (MOTOR_RULES.hasFreeSlots()) {
|
||||||
MOTOR_RULES.put(new MotorMixRule(1, 0, 0, 0));
|
MOTOR_RULES.put(new MotorMixRule(1, 0, 0, 0));
|
||||||
renderMotorMixRules();
|
renderMotorMixRules();
|
||||||
|
renderOutputMapping();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -298,6 +357,9 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
|
||||||
renderServoMixRules();
|
renderServoMixRules();
|
||||||
renderMotorMixRules();
|
renderMotorMixRules();
|
||||||
|
|
||||||
|
renderOutputTable();
|
||||||
|
renderOutputMapping();
|
||||||
|
|
||||||
localize();
|
localize();
|
||||||
GUI.content_ready(callback);
|
GUI.content_ready(callback);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue