mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-24 16:55:22 +03:00
Merge pull request #391 from shellixyz/simplify_and_improve_channel_mapping
Make channel mapping more user friendly
This commit is contained in:
commit
a1774e5bac
3 changed files with 41 additions and 27 deletions
25
js/fc.js
25
js/fc.js
|
@ -994,7 +994,30 @@ var FC = {
|
|||
}
|
||||
},
|
||||
getRcMapLetters: function () {
|
||||
return ['A', 'E', 'R', 'T', '5', '6', '7', '8'];
|
||||
if (semver.gte(CONFIG.flightControllerVersion, '1.9.1'))
|
||||
return ['A', 'E', 'R', 'T'];
|
||||
else
|
||||
return ['A', 'E', 'R', 'T', '5', '6', '7', '8'];
|
||||
},
|
||||
isRcMapValid: function (val) {
|
||||
var strBuffer = val.split(''),
|
||||
duplicityBuffer = [];
|
||||
|
||||
if (val.length != FC.getRcMapLetters().length)
|
||||
return false;
|
||||
|
||||
// check if characters inside are all valid, also check for duplicity
|
||||
for (var i = 0; i < val.length; i++) {
|
||||
if (FC.getRcMapLetters().indexOf(strBuffer[i]) < 0)
|
||||
return false;
|
||||
|
||||
if (duplicityBuffer.indexOf(strBuffer[i]) < 0)
|
||||
duplicityBuffer.push(strBuffer[i]);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
getServoMixInputNames: function () {
|
||||
return [
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
<input type="text" name="rcmap" spellcheck="false" />
|
||||
<select class="hybrid_helper"
|
||||
name="rcmap_helper">
|
||||
<option value="AETR5678">Default</option>
|
||||
<option value="AETR5678">Futaba / Hitec</option>
|
||||
<option value="TAER5678">JR / Spektrum / Graupner</option>
|
||||
<option value="AETR">Default</option>
|
||||
<option value="AETR">Futaba / Hitec</option>
|
||||
<option value="TAER">JR / Spektrum / Graupner</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -77,6 +77,14 @@ TABS.receiver.initialize = function (callback) {
|
|||
// translate to user-selected language
|
||||
localize();
|
||||
|
||||
if (semver.lt(CONFIG.flightControllerVersion, '1.9.1')) {
|
||||
rcmap_options = $('select[name="rcmap_helper"] option');
|
||||
for (i = 0; i < rcmap_options.length; ++i) {
|
||||
option = rcmap_options[i];
|
||||
option.setAttribute("value", option.getAttribute("value") + "5678");
|
||||
}
|
||||
}
|
||||
|
||||
// fill in data from RC_tuning
|
||||
$('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2));
|
||||
$('.tunings .throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2));
|
||||
|
@ -152,9 +160,9 @@ TABS.receiver.initialize = function (callback) {
|
|||
$(window).on('resize', self.resize).resize(); // trigger so labels get correctly aligned on creation
|
||||
|
||||
// handle rcmap & rssi aux channel
|
||||
var strBuffer = [];
|
||||
var strBuffer = [], rcMapLetters = FC.getRcMapLetters();
|
||||
for (var i = 0; i < RC_MAP.length; i++) {
|
||||
strBuffer[RC_MAP[i]] = FC.getRcMapLetters()[i];
|
||||
strBuffer[RC_MAP[i]] = rcMapLetters[i];
|
||||
}
|
||||
|
||||
// reconstruct
|
||||
|
@ -183,29 +191,12 @@ TABS.receiver.initialize = function (callback) {
|
|||
});
|
||||
|
||||
$rcMap.focusout(function () {
|
||||
var val = $(this).val(),
|
||||
strBuffer = val.split(''),
|
||||
duplicityBuffer = [];
|
||||
|
||||
if (val.length != 8) {
|
||||
if (!FC.isRcMapValid($(this).val()))
|
||||
$(this).val(last_valid);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// check if characters inside are all valid, also check for duplicity
|
||||
for (var i = 0; i < val.length; i++) {
|
||||
if (FC.getRcMapLetters().indexOf(strBuffer[i]) < 0) {
|
||||
$(this).val(last_valid);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (duplicityBuffer.indexOf(strBuffer[i]) < 0) {
|
||||
duplicityBuffer.push(strBuffer[i]);
|
||||
} else {
|
||||
$(this).val(last_valid);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$rcMap.on('input change', function() {
|
||||
$(this).css("color", FC.isRcMapValid($(this).val()) ? "" : "#FF0000");
|
||||
});
|
||||
|
||||
// handle helper
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue