From 27a4849ddfd1a3cb540e72de8400d7c0efc2179e Mon Sep 17 00:00:00 2001 From: visdauas <69413047+visdauas@users.noreply.github.com> Date: Thu, 19 Nov 2020 22:41:36 +0100 Subject: [PATCH] Moved getSerialRxTypes to not interfere with backup/restore --- src/js/fc.js | 104 +++++++++++++++++------------------ src/js/tabs/configuration.js | 2 +- src/js/tabs/osd.js | 2 +- 3 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/js/fc.js b/src/js/fc.js index cbfef912..e9ef6eca 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -543,58 +543,6 @@ const FC = { rcSmoothingDerivativeType: 0, rcSmoothingAutoSmoothness: 0, usbCdcHidType: 0, - serialRxTypes: [ - 'SPEKTRUM1024', - 'SPEKTRUM2048', - 'SBUS', - 'SUMD', - 'SUMH', - 'XBUS_MODE_B', - 'XBUS_MODE_B_RJ01', - ], - - getSerialRxTypes: () => { - const apiVersion = this.CONFIG.apiVersion; - const flightControllerIdentifier = this.CONFIG.flightControllerIdentifier; - const flightControllerVersion = this.CONFIG.flightControllerVersion; - // js way of cloning an array - const result = [...this.RX_CONFIG.serialRxTypes]; - - if (semver.gte(apiVersion, "1.15.0")) { - result.push('IBUS'); - } - - if ((flightControllerIdentifier === 'BTFL' && semver.gte(flightControllerVersion, "2.6.0")) || - (flightControllerIdentifier === 'CLFL' && semver.gte(apiVersion, API_VERSION_1_31))) { - result.push('JETIEXBUS'); - } - - if (semver.gte(apiVersion, API_VERSION_1_31)) { - result.push('CRSF'); - } - - if (semver.gte(apiVersion, "1.24.0")) { - result.push('SPEKTRUM2048/SRXL'); - } - - if (semver.gte(apiVersion, API_VERSION_1_35)) { - result.push('TARGET_CUSTOM'); - } - - if (semver.gte(apiVersion, API_VERSION_1_37)) { - result.push('FrSky FPort'); - } - - if (semver.gte(apiVersion, API_VERSION_1_42)) { - result.push('SPEKTRUM SRXL2'); - } - - if (semver.gte(apiVersion, API_VERSION_1_44)) { - result.push('IRC GHOST'); - } - - return result; - }, }; this.FAILSAFE_CONFIG = { @@ -696,6 +644,58 @@ const FC = { ]; }, + getSerialRxTypes: () => { + const apiVersion = FC.CONFIG.apiVersion; + const flightControllerIdentifier = FC.CONFIG.flightControllerIdentifier; + const flightControllerVersion = FC.CONFIG.flightControllerVersion; + + // defaults + const serialRxTypes = [ + 'SPEKTRUM1024', + 'SPEKTRUM2048', + 'SBUS', + 'SUMD', + 'SUMH', + 'XBUS_MODE_B', + 'XBUS_MODE_B_RJ01', + ]; + + if (semver.gte(apiVersion, "1.15.0")) { + serialRxTypes.push('IBUS'); + } + + if ((flightControllerIdentifier === 'BTFL' && semver.gte(flightControllerVersion, "2.6.0")) || + (flightControllerIdentifier === 'CLFL' && semver.gte(apiVersion, API_VERSION_1_31))) { + serialRxTypes.push('JETIEXBUS'); + } + + if (semver.gte(apiVersion, API_VERSION_1_31)) { + serialRxTypes.push('CRSF'); + } + + if (semver.gte(apiVersion, "1.24.0")) { + serialRxTypes.push('SPEKTRUM2048/SRXL'); + } + + if (semver.gte(apiVersion, API_VERSION_1_35)) { + serialRxTypes.push('TARGET_CUSTOM'); + } + + if (semver.gte(apiVersion, API_VERSION_1_37)) { + serialRxTypes.push('FrSky FPort'); + } + + if (semver.gte(apiVersion, API_VERSION_1_42)) { + serialRxTypes.push('SPEKTRUM SRXL2'); + } + + if (semver.gte(apiVersion, API_VERSION_1_44)) { + serialRxTypes.push('IRC GHOST'); + } + + return serialRxTypes; + }, + getHardwareName() { let name; if (this.CONFIG.targetName) { diff --git a/src/js/tabs/configuration.js b/src/js/tabs/configuration.js index d2009cdd..e6133e9f 100644 --- a/src/js/tabs/configuration.js +++ b/src/js/tabs/configuration.js @@ -844,7 +844,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) { } const serialRXSelectEl = $('select.serialRX'); - FC.RX_CONFIG.getSerialRxTypes().forEach((serialRxType, index) => { + FC.getSerialRxTypes().forEach((serialRxType, index) => { serialRXSelectEl.append(``); }); diff --git a/src/js/tabs/osd.js b/src/js/tabs/osd.js index 160beea9..d834e7f3 100644 --- a/src/js/tabs/osd.js +++ b/src/js/tabs/osd.js @@ -345,7 +345,7 @@ OSD.generateTemperaturePreview = function(osdData, temperature) { }; OSD.generateLQPreview = function() { - const crsfIndex = FC.RX_CONFIG.getSerialRxTypes().findIndex(name => name === 'CRSF'); + const crsfIndex = FC.getSerialRxTypes().findIndex(name => name === 'CRSF'); const isXF = crsfIndex === FC.RX_CONFIG.serialrx_provider; return FONT.symbol(SYM.LINK_QUALITY) + (isXF ? '2:100' : '8'); };