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:
commit
500ddba518
5 changed files with 27 additions and 12 deletions
|
@ -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 () {
|
||||
|
|
3
js/fc.js
3
js/fc.js
|
@ -61,7 +61,8 @@ var FC = {
|
|||
profile: 0,
|
||||
uid: [0, 0, 0],
|
||||
accelerometerTrims: [0, 0],
|
||||
name: ''
|
||||
name: '',
|
||||
numProfiles: 3
|
||||
};
|
||||
|
||||
BF_CONFIG = {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -252,11 +252,19 @@ 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);
|
||||
|
||||
var sensor_state = $('#sensor-status');
|
||||
|
@ -269,7 +277,6 @@ function onConnect() {
|
|||
dataflash.show();
|
||||
|
||||
startLiveDataRefreshTimer();
|
||||
|
||||
}
|
||||
|
||||
function onClosed(result) {
|
||||
|
|
|
@ -148,8 +148,9 @@
|
|||
<div class="dropdown dropdown-dark">
|
||||
<form name="profile-change" id="profile-change">
|
||||
<select class="dropdown-select" name="profilechange">
|
||||
<option value="0">Profile 1</option>
|
||||
<option value="1">Profile 2</option>
|
||||
<option value="0" class="profile1">Profile 1</option>
|
||||
<option value="1" class="profile2">Profile 2</option>
|
||||
<option value="2" class="profile3">Profile 3</option>
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue