mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-25 17:25:14 +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 () {
|
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 () {
|
getServoMixInputNames: function () {
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
<input type="text" name="rcmap" spellcheck="false" />
|
<input type="text" name="rcmap" spellcheck="false" />
|
||||||
<select class="hybrid_helper"
|
<select class="hybrid_helper"
|
||||||
name="rcmap_helper">
|
name="rcmap_helper">
|
||||||
<option value="AETR5678">Default</option>
|
<option value="AETR">Default</option>
|
||||||
<option value="AETR5678">Futaba / Hitec</option>
|
<option value="AETR">Futaba / Hitec</option>
|
||||||
<option value="TAER5678">JR / Spektrum / Graupner</option>
|
<option value="TAER">JR / Spektrum / Graupner</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -77,6 +77,14 @@ TABS.receiver.initialize = function (callback) {
|
||||||
// translate to user-selected language
|
// translate to user-selected language
|
||||||
localize();
|
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
|
// fill in data from RC_tuning
|
||||||
$('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2));
|
$('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2));
|
||||||
$('.tunings .throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.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
|
$(window).on('resize', self.resize).resize(); // trigger so labels get correctly aligned on creation
|
||||||
|
|
||||||
// handle rcmap & rssi aux channel
|
// handle rcmap & rssi aux channel
|
||||||
var strBuffer = [];
|
var strBuffer = [], rcMapLetters = FC.getRcMapLetters();
|
||||||
for (var i = 0; i < RC_MAP.length; i++) {
|
for (var i = 0; i < RC_MAP.length; i++) {
|
||||||
strBuffer[RC_MAP[i]] = FC.getRcMapLetters()[i];
|
strBuffer[RC_MAP[i]] = rcMapLetters[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// reconstruct
|
// reconstruct
|
||||||
|
@ -183,29 +191,12 @@ TABS.receiver.initialize = function (callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
$rcMap.focusout(function () {
|
$rcMap.focusout(function () {
|
||||||
var val = $(this).val(),
|
if (!FC.isRcMapValid($(this).val()))
|
||||||
strBuffer = val.split(''),
|
|
||||||
duplicityBuffer = [];
|
|
||||||
|
|
||||||
if (val.length != 8) {
|
|
||||||
$(this).val(last_valid);
|
$(this).val(last_valid);
|
||||||
return false;
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// check if characters inside are all valid, also check for duplicity
|
$rcMap.on('input change', function() {
|
||||||
for (var i = 0; i < val.length; i++) {
|
$(this).css("color", FC.isRcMapValid($(this).val()) ? "" : "#FF0000");
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// handle helper
|
// handle helper
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue