diff --git a/js/backup_restore.js b/js/backup_restore.js index 39dbdb7c..7b5ba146 100644 --- a/js/backup_restore.js +++ b/js/backup_restore.js @@ -3,8 +3,7 @@ // code below is highly experimental, although it runs fine on latest firmware // the data inside nested objects needs to be verified if deep copy works properly function configuration_backup(callback) { - var activeProfile = null, - profilesN = 3; + var activeProfile = null; var configuration = { 'generatedBy': chrome.runtime.getManifest().version, @@ -53,7 +52,7 @@ function configuration_backup(callback) { codeKey = 0; function fetch_specific_data_item() { - if (fetchingProfile < profilesN) { + if (fetchingProfile < CONFIG.numProfiles) { MSP.send_message(profileSpecificData[codeKey], false, false, function () { codeKey++; @@ -635,8 +634,11 @@ function configuration_restore(callback) { function configuration_upload(configuration, callback) { function upload() { - var activeProfile = null, - profilesN = 3; + var activeProfile = null; + var numProfiles = CONFIG.numProfiles; + if (configuration.profiles.length < numProfiles) { + numProfiles = configuration.profiles.length; + } var profileSpecificData = [ MSP_codes.MSP_SET_PID_CONTROLLER, @@ -688,7 +690,7 @@ function configuration_restore(callback) { codeKey = 0; savingProfile++; - if (savingProfile < profilesN) { + if (savingProfile < numProfiles) { load_objects(savingProfile); MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, function () { diff --git a/js/fc.js b/js/fc.js index 55edca59..3ea785f5 100644 --- a/js/fc.js +++ b/js/fc.js @@ -61,7 +61,8 @@ var FC = { profile: 0, uid: [0, 0, 0], accelerometerTrims: [0, 0], - name: '' + name: '', + numProfiles: 3 }; BF_CONFIG = { diff --git a/js/msp.js b/js/msp.js index 08b30a5d..12c6cf5f 100755 --- a/js/msp.js +++ b/js/msp.js @@ -296,7 +296,11 @@ var MSP = { CONFIG.mode = data.getUint32(6, 1); CONFIG.profile = data.getUint8(10); CONFIG.cpuload = data.getUint16(11, 1); + CONFIG.numProfiles = data.getUint8(13); $('select[name="profilechange"]').val(CONFIG.profile); + if (CONFIG.numProfiles === 2) { + $('select[name="profilechange"] .profile3').hide(); + } sensor_status(CONFIG.activeSensors); $('span.i2c-error').text(CONFIG.i2cError); diff --git a/js/serial_backend.js b/js/serial_backend.js index c3aa190f..ee63fa9b 100755 --- a/js/serial_backend.js +++ b/js/serial_backend.js @@ -252,10 +252,18 @@ function onConnect() { $('#tabs ul.mode-disconnected').hide(); $('#tabs ul.mode-connected').show(); - if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) + if (semver.gte(CONFIG.flightControllerVersion, "3.0.0")) { MSP.send_message(MSP_codes.MSP_STATUS_EX, false, false); - else + } else { MSP.send_message(MSP_codes.MSP_STATUS, false, false); + + if (semver.gte(CONFIG.flightControllerVersion, "2.4.0")) { + CONFIG.numProfiles = 2; + $('select[name="profilechange"] .profile3').hide(); + } else { + CONFIG.numProfiles = 3; + } + } MSP.send_message(MSP_codes.MSP_DATAFLASH_SUMMARY, false, false); @@ -269,7 +277,6 @@ function onConnect() { dataflash.show(); startLiveDataRefreshTimer(); - } function onClosed(result) { diff --git a/main.html b/main.html index 0fdcb7fd..144df8e1 100755 --- a/main.html +++ b/main.html @@ -148,8 +148,9 @@