diff --git a/js/fc.js b/js/fc.js index a216cce1..4d25ba1d 100644 --- a/js/fc.js +++ b/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 [ diff --git a/tabs/receiver.html b/tabs/receiver.html index 958a10ea..f2af3660 100644 --- a/tabs/receiver.html +++ b/tabs/receiver.html @@ -25,9 +25,9 @@ diff --git a/tabs/receiver.js b/tabs/receiver.js index 7ea25775..b95c45d2 100644 --- a/tabs/receiver.js +++ b/tabs/receiver.js @@ -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