Skip to content

Commit 3b4c4f0

Browse files
authored
Merge pull request #456 from iNavFlight/dzikuvx-show-only-configured-servos
show only configured servos
2 parents 8e27683 + 993f8b5 commit 3b4c4f0

File tree

5 files changed

+40
-6
lines changed

5 files changed

+40
-6
lines changed

_locales/en/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,5 +2548,8 @@
25482548
},
25492549
"confirm_reset_settings": {
25502550
"message": "Do you really want to reset all settings?\nATTENTION: All settings are lost! You have to setup the whole aircraft after this operation!"
2551+
},
2552+
"servoTableInfo": {
2553+
"message": "This table shows only servos configured using servo mixer"
25512554
}
25522555
}

js/servoMixerRuleCollection.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,19 @@ var ServoMixerRuleCollection = function () {
5858
return data.length < self.getServoRulesCount();
5959
};
6060

61+
self.isServoConfigured = function(servoId) {
62+
63+
for (let ruleIndex in data) {
64+
if (data.hasOwnProperty(ruleIndex)) {
65+
let rule = data[ruleIndex];
66+
67+
if (rule.getTarget() == servoId && rule.isUsed()) {
68+
return true;
69+
}
70+
}
71+
}
72+
return false;
73+
}
74+
6175
return self;
6276
};

main.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,11 @@ dialog {
10531053
font-family: 'open_sansregular', Arial, serif;
10541054
}
10551055

1056+
.note--big {
1057+
font-size: 1.15em;
1058+
padding: 0.6em;
1059+
}
1060+
10561061
.note_spacer {
10571062
padding: 5px 7px 5px 7px;
10581063
}

tabs/servos.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<a id="button-documentation" href="" target="_blank"></a>
66
</div>
77
<div>
8+
<p data-i18n="servoTableInfo" class="requires-v2_0 note note--big"></p>
89
<!-- <div class="title" data-i18n="servosChangeDirection"></div> -->
910
<table id="servo-config-table" class="fields">
1011
<tr class="main">

tabs/servos.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*global fc*/
1+
/*global fc,mspHelper,TABS*/
22
'use strict';
33

44
TABS.servos = {};
@@ -12,6 +12,7 @@ TABS.servos.initialize = function (callback) {
1212
let loadChainer = new MSPChainerClass();
1313

1414
loadChainer.setChain([
15+
mspHelper.loadServoMixRules,
1516
mspHelper.loadServoConfiguration,
1617
mspHelper.loadRcData,
1718
mspHelper.loadBfConfig,
@@ -52,6 +53,9 @@ TABS.servos.initialize = function (callback) {
5253
servoHeader = '';
5354

5455
if (semver.lt(CONFIG.flightControllerVersion, "2.0.0")) {
56+
57+
$('.requires-v2_0').hide();
58+
5559
for (i = 0; i < RC.active_channels - 4; i++) {
5660
servoHeader = servoHeader + '<th class="short">CH' + (i + 5) + '</th>';
5761
}
@@ -88,29 +92,36 @@ TABS.servos.initialize = function (callback) {
8892
</tr> \
8993
');
9094

95+
let $currentRow = $servoConfigTable.find('tr:last');
96+
9197
//This routine is pre 2.0 only
9298
if (SERVO_CONFIG[obj].indexOfChannelToForward >= 0) {
93-
$servoConfigTable.find('tr:last td.channel input').eq(SERVO_CONFIG[obj].indexOfChannelToForward).prop('checked', true);
99+
$currentRow.find('td.channel input').eq(SERVO_CONFIG[obj].indexOfChannelToForward).prop('checked', true);
94100
}
95101

96102
// adding select box and generating options
97-
$servoConfigTable.find('tr:last td.rate').append(
103+
$currentRow.find('td.rate').append(
98104
'<input class="rate-input" type="number" min="' + FC.MIN_SERVO_RATE + '" max="' + FC.MAX_SERVO_RATE + '" value="' + Math.abs(SERVO_CONFIG[obj].rate) + '" />'
99105
);
100106

101-
$servoConfigTable.find('tr:last td.reverse').append(
107+
$currentRow.find('td.reverse').append(
102108
'<input type="checkbox" class="reverse-input togglemedium" ' + (SERVO_CONFIG[obj].rate < 0 ? ' checked ' : '') + '/>'
103109
);
104110

105-
$servoConfigTable.find('tr:last').data('info', { 'obj': obj });
111+
$currentRow.data('info', { 'obj': obj });
106112

107113
if (semver.lt(CONFIG.flightControllerVersion, "2.0.0")) {
108114
// only one checkbox for indicating a channel to forward can be selected at a time, perhaps a radio group would be best here.
109-
$servoConfigTable.find('tr:last td.channel input').click(function () {
115+
$currentRow.find('td.channel input').click(function () {
110116
if ($(this).is(':checked')) {
111117
$(this).parent().parent().find('.channel input').not($(this)).prop('checked', false);
112118
}
113119
});
120+
} else {
121+
//For 2.0 and above hide a row when servo is not configured
122+
if (!SERVO_RULES.isServoConfigured(obj)) {
123+
$servoConfigTable.find('tr:last').hide();
124+
}
114125
}
115126
}
116127

0 commit comments

Comments
 (0)