1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-17 05:15:21 +03:00

Merge pull request #124 from mikeller/add_num_profiles_to_msp

Made configurator aware of number of profiles supported by firmware. Made backup / restore more robust.
This commit is contained in:
borisbstyle 2016-07-18 12:18:37 +02:00 committed by GitHub
commit 500ddba518
5 changed files with 27 additions and 12 deletions

View file

@ -3,8 +3,7 @@
// code below is highly experimental, although it runs fine on latest firmware // 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 // the data inside nested objects needs to be verified if deep copy works properly
function configuration_backup(callback) { function configuration_backup(callback) {
var activeProfile = null, var activeProfile = null;
profilesN = 3;
var configuration = { var configuration = {
'generatedBy': chrome.runtime.getManifest().version, 'generatedBy': chrome.runtime.getManifest().version,
@ -53,7 +52,7 @@ function configuration_backup(callback) {
codeKey = 0; codeKey = 0;
function fetch_specific_data_item() { function fetch_specific_data_item() {
if (fetchingProfile < profilesN) { if (fetchingProfile < CONFIG.numProfiles) {
MSP.send_message(profileSpecificData[codeKey], false, false, function () { MSP.send_message(profileSpecificData[codeKey], false, false, function () {
codeKey++; codeKey++;
@ -635,8 +634,11 @@ function configuration_restore(callback) {
function configuration_upload(configuration, callback) { function configuration_upload(configuration, callback) {
function upload() { function upload() {
var activeProfile = null, var activeProfile = null;
profilesN = 3; var numProfiles = CONFIG.numProfiles;
if (configuration.profiles.length < numProfiles) {
numProfiles = configuration.profiles.length;
}
var profileSpecificData = [ var profileSpecificData = [
MSP_codes.MSP_SET_PID_CONTROLLER, MSP_codes.MSP_SET_PID_CONTROLLER,
@ -688,7 +690,7 @@ function configuration_restore(callback) {
codeKey = 0; codeKey = 0;
savingProfile++; savingProfile++;
if (savingProfile < profilesN) { if (savingProfile < numProfiles) {
load_objects(savingProfile); load_objects(savingProfile);
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, function () { MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, function () {

View file

@ -61,7 +61,8 @@ var FC = {
profile: 0, profile: 0,
uid: [0, 0, 0], uid: [0, 0, 0],
accelerometerTrims: [0, 0], accelerometerTrims: [0, 0],
name: '' name: '',
numProfiles: 3
}; };
BF_CONFIG = { BF_CONFIG = {

View file

@ -296,7 +296,11 @@ var MSP = {
CONFIG.mode = data.getUint32(6, 1); CONFIG.mode = data.getUint32(6, 1);
CONFIG.profile = data.getUint8(10); CONFIG.profile = data.getUint8(10);
CONFIG.cpuload = data.getUint16(11, 1); CONFIG.cpuload = data.getUint16(11, 1);
CONFIG.numProfiles = data.getUint8(13);
$('select[name="profilechange"]').val(CONFIG.profile); $('select[name="profilechange"]').val(CONFIG.profile);
if (CONFIG.numProfiles === 2) {
$('select[name="profilechange"] .profile3').hide();
}
sensor_status(CONFIG.activeSensors); sensor_status(CONFIG.activeSensors);
$('span.i2c-error').text(CONFIG.i2cError); $('span.i2c-error').text(CONFIG.i2cError);

View file

@ -252,10 +252,18 @@ function onConnect() {
$('#tabs ul.mode-disconnected').hide(); $('#tabs ul.mode-disconnected').hide();
$('#tabs ul.mode-connected').show(); $('#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); MSP.send_message(MSP_codes.MSP_STATUS_EX, false, false);
else } else {
MSP.send_message(MSP_codes.MSP_STATUS, false, false); 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); MSP.send_message(MSP_codes.MSP_DATAFLASH_SUMMARY, false, false);
@ -269,7 +277,6 @@ function onConnect() {
dataflash.show(); dataflash.show();
startLiveDataRefreshTimer(); startLiveDataRefreshTimer();
} }
function onClosed(result) { function onClosed(result) {

View file

@ -148,8 +148,9 @@
<div class="dropdown dropdown-dark"> <div class="dropdown dropdown-dark">
<form name="profile-change" id="profile-change"> <form name="profile-change" id="profile-change">
<select class="dropdown-select" name="profilechange"> <select class="dropdown-select" name="profilechange">
<option value="0">Profile 1</option> <option value="0" class="profile1">Profile 1</option>
<option value="1">Profile 2</option> <option value="1" class="profile2">Profile 2</option>
<option value="2" class="profile3">Profile 3</option>
</select> </select>
</form> </form>
</div> </div>