1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-15 12:25:13 +03:00

Provide a migration path from pre-1.8.0 firmware backups.

This commit is contained in:
Dominic Clifton 2015-03-11 23:34:24 +00:00
parent 4b2704e784
commit b2be2853b4
8 changed files with 148 additions and 46 deletions

View file

@ -518,6 +518,9 @@
"portsHelp": { "portsHelp": {
"message": "Configure serial ports. <strong>Note:</strong> not all combinations are valid. When the flight controller firmware detects this the serial port configuration will be reset." "message": "Configure serial ports. <strong>Note:</strong> not all combinations are valid. When the flight controller firmware detects this the serial port configuration will be reset."
}, },
"portsFirmwareUpgradeRequired": {
"message": "Firmware upgrade <span style=\"color: red\">required</span>. Serial port configurations of firmware &lt; 1.8.0 is not supported."
},
"portsButtonSave": { "portsButtonSave": {
"message": "Save and Reboot" "message": "Save and Reboot"
}, },
@ -899,6 +902,9 @@
"dataflashNotSupportedNote": { "dataflashNotSupportedNote": {
"message": "Your flight controller does not have a compatible dataflash chip available." "message": "Your flight controller does not have a compatible dataflash chip available."
}, },
"dataflashFirmwareUpgradeRequired": {
"message": "Dataflash requires firmware &gt;= 1.8.0."
},
"dataflashButtonSaveFile": { "dataflashButtonSaveFile": {
"message": "Save flash to file..." "message": "Save flash to file..."
}, },

View file

@ -102,7 +102,7 @@ function configuration_backup(callback) {
configuration.RCMAP = jQuery.extend(true, [], RC_MAP); configuration.RCMAP = jQuery.extend(true, [], RC_MAP);
configuration.BF_CONFIG = jQuery.extend(true, {}, BF_CONFIG); configuration.BF_CONFIG = jQuery.extend(true, {}, BF_CONFIG);
configuration.SERIAL_CONFIG = jQuery.extend(true, {}, SERIAL_CONFIG); configuration.SERIAL_CONFIG = jQuery.extend(true, {}, SERIAL_CONFIG);
configuration.LED_STRIP = jQuery.extend(true, {}, LED_STRIP); configuration.LED_STRIP = jQuery.extend(true, [], LED_STRIP);
save(); save();
} }
@ -332,9 +332,56 @@ function configuration_restore(callback) {
if (!compareVersions(migratedVersion, '0.63.0')) { if (!compareVersions(migratedVersion, '0.63.0')) {
// Serial configuation redesigned. Until a migration is written just reset the serial port configuration // LED Strip was saved as object instead of array.
if (typeof(configuration.LED_STRIP) == 'object') {
var fixed_led_strip = [];
var index = 0;
while (configuration.LED_STRIP[index]) {
fixed_led_strip.push(configuration.LED_STRIP[index++]);
}
configuration.LED_STRIP = fixed_led_strip;
}
// Serial configuation redesigned
var ports = [];
for (var portIndex = 0; portIndex < configuration.SERIAL_CONFIG.ports.length; portIndex++) {
var oldPort = configuration.SERIAL_CONFIG.ports[portIndex];
var newPort = {
identifier: oldPort.identifier,
functionMask: 0,
msp_baudrate: configuration.SERIAL_CONFIG.mspBaudRate,
gps_baudrate: configuration.SERIAL_CONFIG.gpsBaudRate,
telemetry_baudrate: 0, // auto
blackbox_baudrate: 5, // 115200
};
switch(oldPort.scenario) {
case 1: // MSP, CLI, TELEMETRY, SMARTPORT TELEMETRY, GPS-PASSTHROUGH
case 5: // MSP, CLI, GPS-PASSTHROUGH
case 8: // MSP ONLY
newPort.functionMask = 1; // FUCNTION_MSP
break;
case 2: // GPS
newPort.functionMask = 2; // FUNCTION_GPS
break;
case 3: // RX_SERIAL
newPort.functionMask = 64; // FUNCTION_RX_SERIAL
break;
case 10: // BLACKBOX ONLY
newPort.functionMask = 128; // FUNCTION_BLACKBOX
break;
case 11: // MSP, CLI, BLACKBOX, GPS-PASSTHROUGH
newPort.functionMask = 1 + 128; // FUNCTION_BLACKBOX
break;
}
ports.push(newPort);
}
configuration.SERIAL_CONFIG = { configuration.SERIAL_CONFIG = {
ports: [] ports: ports
}; };
for (var profileIndex = 0; profileIndex < 3; profileIndex++) { for (var profileIndex = 0; profileIndex < 3; profileIndex++) {

View file

@ -3,9 +3,9 @@
var CONFIGURATOR = { var CONFIGURATOR = {
'releaseDate': 1424462791805, // new Date().getTime() - 2015.02.20 'releaseDate': 1424462791805, // new Date().getTime() - 2015.02.20
'apiVersionAccepted': 1.2, 'apiVersionAccepted': 1.2,
'backupRestoreMinApiVersionAccepted': 1.6, 'backupRestoreMinApiVersionAccepted': 1.5,
'pidControllerChangeMinApiVersion': 1.5, 'pidControllerChangeMinApiVersion': 1.5,
'backupFileMinVersionAccepted': '0.63', // chrome.runtime.getManifest().version is stored as string, so does this one 'backupFileMinVersionAccepted': '0.55', // chrome.runtime.getManifest().version is stored as string, so does this one
'connectionValid': false, 'connectionValid': false,
'connectionValidCliOnly': false, 'connectionValidCliOnly': false,
'cliActive': false, 'cliActive': false,
@ -89,6 +89,8 @@ var SERVO_CONFIG = [];
var SERIAL_CONFIG = { var SERIAL_CONFIG = {
ports: [], ports: [],
// pre 1.6 settings
mspBaudRate: 0, mspBaudRate: 0,
gpsBaudRate: 0, gpsBaudRate: 0,
gpsPassthroughBaudRate: 0, gpsPassthroughBaudRate: 0,

View file

@ -62,6 +62,6 @@
<a href="#" class="save-flash" i18n="dataflashButtonSaveFile"></a> <a href="#" class="save-flash" i18n="dataflashButtonSaveFile"></a>
</div> </div>
</div> </div>
<div class="note require-no-dataflash" i18n="dataflashNotSupportedNote"> <div class="note require-no-dataflash">
</div> </div>
</div> </div>

View file

@ -1,6 +1,8 @@
'use strict'; 'use strict';
TABS.dataflash = {}; TABS.dataflash = {
available: false
};
TABS.dataflash.initialize = function (callback) { TABS.dataflash.initialize = function (callback) {
var var
self = this, self = this,
@ -18,10 +20,19 @@ TABS.dataflash.initialize = function (callback) {
log_buffer = []; log_buffer = [];
if (CONFIGURATOR.connectionValid) { if (CONFIGURATOR.connectionValid) {
MSP.send_message(MSP_codes.MSP_DATAFLASH_SUMMARY, false, false, function() { if (CONFIG.apiVersion < 1.6) {
$('#content').load("./tabs/dataflash.html", function() { load_html();
create_html(); return;
}); }
TABS.dataflash.available = true;
MSP.send_message(MSP_codes.MSP_DATAFLASH_SUMMARY, false, false, load_html);
}
function load_html() {
$('#content').load("./tabs/dataflash.html", function() {
create_html();
}); });
} }
@ -71,27 +82,34 @@ TABS.dataflash.initialize = function (callback) {
} }
function create_html() { function create_html() {
var
supportsDataflash = DATAFLASH.totalSize > 0;
// translate to user-selected language // translate to user-selected language
localize(); localize();
if (TABS.dataflash.available) {
var supportsDataflash = DATAFLASH.totalSize > 0;
$(".tab-dataflash").toggleClass("supported", supportsDataflash);
$(".tab-dataflash").toggleClass("supported", supportsDataflash); if (supportsDataflash) {
// UI hooks
$('.tab-dataflash a.erase-flash').click(ask_to_erase_flash);
$('.tab-dataflash a.erase-flash-confirm').click(flash_erase);
$('.tab-dataflash a.erase-flash-cancel').click(flash_erase_cancel);
if (supportsDataflash) { $('.tab-dataflash a.save-flash').click(flash_save_begin);
// UI hooks $('.tab-dataflash a.save-flash-cancel').click(flash_save_cancel);
$('.tab-dataflash a.erase-flash').click(ask_to_erase_flash); $('.tab-dataflash a.save-flash-dismiss').click(dismiss_saving_dialog);
$('.tab-dataflash a.erase-flash-confirm').click(flash_erase); update_html();
$('.tab-dataflash a.erase-flash-cancel').click(flash_erase_cancel); } else {
$(".tab-dataflash .note").html(chrome.i18n.getMessage('dataflashNotSupportedNote'));
$('.tab-dataflash a.save-flash').click(flash_save_begin); }
$('.tab-dataflash a.save-flash-cancel').click(flash_save_cancel); } else {
$('.tab-dataflash a.save-flash-dismiss').click(dismiss_saving_dialog); $(".tab-dataflash .note").html(chrome.i18n.getMessage('dataflashFirmwareUpgradeRequired'));
update_html();
} }
if (callback) callback(); if (callback) callback();
} }

View file

@ -64,4 +64,22 @@
} }
.tab-ports .save:hover { .tab-ports .save:hover {
background-color: #dedcdc; background-color: #dedcdc;
} }
.tab-ports .note {
padding: 5px;
border: 1px dashed silver;
margin-bottom: 8px;
}
.require-support {
display:none;
}
.tab-ports.supported .require-support {
display:block;
}
.require-upgrade {
display:block;
}
.tab-ports.supported .require-upgrade {
display:none;
}

View file

@ -1,25 +1,29 @@
<div id="content-watermark"></div> <div id="content-watermark"></div>
<div class="tab-ports"> <div class="tab-ports">
<div class="help"> <div class="require-support">
<p i18n="portsHelp"></p> <div class="help">
<p i18n="portsHelp"></p>
</div>
<table class="ports">
<thead>
<tr>
<td>Identifier</td>
<td>Data</td>
<td>Logging</td>
<td>Telemetry</td>
<td>RX</td>
<td>GPS</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="clear-both"></div>
<div class="buttons">
<a class="save" href="#" i18n="portsButtonSave"></a>
</div>
</div> </div>
<table class="ports"> <div class="note require-upgrade" i18n="portsFirmwareUpgradeRequired">
<thead>
<tr>
<td>Identifier</td>
<td>Data</td>
<td>Logging</td>
<td>Telemetry</td>
<td>RX</td>
<td>GPS</td>
</tr>
</thead>
<tbody>
</tbody>
</table>
<div class="clear-both"></div>
<div class="buttons">
<a class="save" href="#" i18n="portsButtonSave"></a>
</div> </div>
</div> </div>

View file

@ -75,6 +75,13 @@ TABS.ports.initialize = function (callback, scrollPosition) {
function update_ui() { function update_ui() {
if (CONFIG.apiVersion < 1.6) {
$(".tab-ports").removeClass("supported");
return;
}
$(".tab-ports").addClass("supported");
var portIdentifierToNameMapping = { var portIdentifierToNameMapping = {
0: 'UART1', 0: 'UART1',