1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-25 17:25:14 +03:00

show only configured servos

This commit is contained in:
Pawel Spychalski (DzikuVx) 2018-05-24 14:32:21 +02:00
parent 8e2768377c
commit 6d40d8e020
4 changed files with 33 additions and 5 deletions

View file

@ -2548,5 +2548,8 @@
},
"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!"
},
"servoTableInfo": {
"message": "This table shows only servos configured using servo mixer"
}
}

View file

@ -58,5 +58,19 @@ var ServoMixerRuleCollection = function () {
return data.length < self.getServoRulesCount();
};
self.isServoConfigured = function(servoId) {
for (let ruleIndex in data) {
if (data.hasOwnProperty(ruleIndex)) {
let rule = data[ruleIndex];
if (rule.getTarget() == servoId && rule.isUsed()) {
return true;
}
}
}
return false;
}
return self;
};

View file

@ -5,6 +5,7 @@
<a id="button-documentation" href="" target="_blank"></a>
</div>
<div>
<p data-i18n="servoTableInfo" class="requires-v2_0"></p>
<!-- <div class="title" data-i18n="servosChangeDirection"></div> -->
<table id="servo-config-table" class="fields">
<tr class="main">

View file

@ -52,6 +52,9 @@ TABS.servos.initialize = function (callback) {
servoHeader = '';
if (semver.lt(CONFIG.flightControllerVersion, "2.0.0")) {
$('.requires-v2_0').hide();
for (i = 0; i < RC.active_channels - 4; i++) {
servoHeader = servoHeader + '<th class="short">CH' + (i + 5) + '</th>';
}
@ -88,29 +91,36 @@ TABS.servos.initialize = function (callback) {
</tr> \
');
let $currentRow = $servoConfigTable.find('tr:last');
//This routine is pre 2.0 only
if (SERVO_CONFIG[obj].indexOfChannelToForward >= 0) {
$servoConfigTable.find('tr:last td.channel input').eq(SERVO_CONFIG[obj].indexOfChannelToForward).prop('checked', true);
$currentRow.find('td.channel input').eq(SERVO_CONFIG[obj].indexOfChannelToForward).prop('checked', true);
}
// adding select box and generating options
$servoConfigTable.find('tr:last td.rate').append(
$currentRow.find('td.rate').append(
'<input class="rate-input" type="number" min="' + FC.MIN_SERVO_RATE + '" max="' + FC.MAX_SERVO_RATE + '" value="' + Math.abs(SERVO_CONFIG[obj].rate) + '" />'
);
$servoConfigTable.find('tr:last td.reverse').append(
$currentRow.find('td.reverse').append(
'<input type="checkbox" class="reverse-input togglemedium" ' + (SERVO_CONFIG[obj].rate < 0 ? ' checked ' : '') + '/>'
);
$servoConfigTable.find('tr:last').data('info', { 'obj': obj });
$currentRow.data('info', { 'obj': obj });
if (semver.lt(CONFIG.flightControllerVersion, "2.0.0")) {
// only one checkbox for indicating a channel to forward can be selected at a time, perhaps a radio group would be best here.
$servoConfigTable.find('tr:last td.channel input').click(function () {
$currentRow.find('td.channel input').click(function () {
if ($(this).is(':checked')) {
$(this).parent().parent().find('.channel input').not($(this)).prop('checked', false);
}
});
} else {
//For 2.0 and above hide a row when servo is not configured
if (!SERVO_RULES.isServoConfigured(obj)) {
$servoConfigTable.find('tr:last').hide();
}
}
}