mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-16 21:05:30 +03:00
Finish up work on unified targets
This commit is contained in:
parent
59d9832efa
commit
000e537283
3 changed files with 94 additions and 23 deletions
|
@ -2582,9 +2582,6 @@
|
||||||
"firmwareFlasherReleaseDate": {
|
"firmwareFlasherReleaseDate": {
|
||||||
"message": "Date:"
|
"message": "Date:"
|
||||||
},
|
},
|
||||||
"firmwareFlasherReleaseStatus": {
|
|
||||||
"message": "State:"
|
|
||||||
},
|
|
||||||
"firmwareFlasherReleaseTarget": {
|
"firmwareFlasherReleaseTarget": {
|
||||||
"message": "Target:"
|
"message": "Target:"
|
||||||
},
|
},
|
||||||
|
@ -2616,6 +2613,9 @@
|
||||||
"firmwareFlasherLoadFirmwareFile": {
|
"firmwareFlasherLoadFirmwareFile": {
|
||||||
"message": "Please load firmware file"
|
"message": "Please load firmware file"
|
||||||
},
|
},
|
||||||
|
"firmwareFlasherLoadedConfig": {
|
||||||
|
"message": "Loaded target, please load firmware file"
|
||||||
|
},
|
||||||
"firmwareFlasherNoReboot": {
|
"firmwareFlasherNoReboot": {
|
||||||
"message": "No reboot sequence"
|
"message": "No reboot sequence"
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,7 +4,8 @@ TABS.firmware_flasher = {
|
||||||
releases: null,
|
releases: null,
|
||||||
releaseChecker: new ReleaseChecker('firmware', 'https://api.github.com/repos/betaflight/betaflight/releases'),
|
releaseChecker: new ReleaseChecker('firmware', 'https://api.github.com/repos/betaflight/betaflight/releases'),
|
||||||
jenkinsLoader: new JenkinsLoader('https://ci.betaflight.tech'),
|
jenkinsLoader: new JenkinsLoader('https://ci.betaflight.tech'),
|
||||||
localFileLoaded: false,
|
localFirmwareLoaded: false,
|
||||||
|
selectedBoard: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
TABS.firmware_flasher.initialize = function (callback) {
|
TABS.firmware_flasher.initialize = function (callback) {
|
||||||
|
@ -14,19 +15,25 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
GUI.active_tab = 'firmware_flasher';
|
GUI.active_tab = 'firmware_flasher';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TABS.firmware_flasher.selectedBoard = undefined;
|
||||||
|
TABS.firmware_flasher.localFirmwareLoaded = false;
|
||||||
var intel_hex = false; // standard intel hex in string format
|
var intel_hex = false; // standard intel hex in string format
|
||||||
var parsed_hex = false; // parsed raw hex in array format
|
var parsed_hex = false; // parsed raw hex in array format
|
||||||
var targetConfig; // the Unified Target configuration to be spliced into the configuration
|
var targetConfig; // the Unified Target configuration to be spliced into the configuration
|
||||||
var isConfigLocal = false; // Set to true if the user loads one locally
|
var isConfigLocal = false; // Set to true if the user loads one locally
|
||||||
var unifiedConfig; // Unified target configuration loaded from the menu, used when throwing out a local config
|
var unifiedConfig; // Unified target configuration loaded from the menu, used when throwing out a local config
|
||||||
|
|
||||||
self.peekTargetConfig = function () { // This maybe should get removed before merging.
|
|
||||||
return targetConfig;
|
|
||||||
}
|
|
||||||
var unifiedSource = 'https://api.github.com/repos/betaflight/unified-targets/contents/configs/default';
|
var unifiedSource = 'https://api.github.com/repos/betaflight/unified-targets/contents/configs/default';
|
||||||
|
|
||||||
|
|
||||||
|
// These two functions are handy for peeking under the hood. Please don't call them in code.
|
||||||
|
self.peekTargetConfig = function () {
|
||||||
|
return targetConfig;
|
||||||
|
}
|
||||||
|
self.peekHex = function () {
|
||||||
|
return parsed_hex;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change boldness of firmware option depending on cache status
|
* Change boldness of firmware option depending on cache status
|
||||||
*
|
*
|
||||||
|
@ -62,10 +69,9 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
|
|
||||||
self.enableFlashing(true);
|
self.enableFlashing(true);
|
||||||
|
|
||||||
$('div.release_info .target').text(summary.target);
|
$('div.release_info .target').text(TABS.firmware_flasher.selectedBoard);
|
||||||
$('div.release_info .name').text(summary.version).prop('href', summary.releaseUrl);
|
$('div.release_info .name').text(summary.version).prop('href', summary.releaseUrl);
|
||||||
$('div.release_info .date').text(summary.date);
|
$('div.release_info .date').text(summary.date);
|
||||||
$('div.release_info .status').text(summary.status);
|
|
||||||
$('div.release_info .file').text(summary.file).prop('href', summary.url);
|
$('div.release_info .file').text(summary.file).prop('href', summary.url);
|
||||||
|
|
||||||
var formattedNotes = summary.notes.replace(/#(\d+)/g, '[#$1](https://github.com/betaflight/betaflight/pull/$1)');
|
var formattedNotes = summary.notes.replace(/#(\d+)/g, '[#$1](https://github.com/betaflight/betaflight/pull/$1)');
|
||||||
|
@ -99,6 +105,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLoadSuccess(data, summary) {
|
function onLoadSuccess(data, summary) {
|
||||||
|
self.localFirmwareLoaded = false;
|
||||||
// The path from getting a firmware doesn't fill in summary.
|
// The path from getting a firmware doesn't fill in summary.
|
||||||
summary = typeof summary === "object"
|
summary = typeof summary === "object"
|
||||||
? summary
|
? summary
|
||||||
|
@ -146,7 +153,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
|
|
||||||
ConfigStorage.get('selected_board', function (result) {
|
ConfigStorage.get('selected_board', function (result) {
|
||||||
if (result.selected_board) {
|
if (result.selected_board) {
|
||||||
var boardBuilds = builds[result.selected_board]
|
var boardBuilds = builds[result.selected_board];
|
||||||
$('select[name="board"]').val(boardBuilds ? result.selected_board : 0).trigger('change');
|
$('select[name="board"]').val(boardBuilds ? result.selected_board : 0).trigger('change');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -432,10 +439,18 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function grabBuildNameFromConfig(config) {
|
function grabBuildNameFromConfig(config) {
|
||||||
return config.split("\n")[0].split(' ')[3];
|
let bareBoard;
|
||||||
|
try {
|
||||||
|
bareBoard = config.split("\n")[0].split(' ')[3];
|
||||||
|
} catch (e) {
|
||||||
|
bareBoard = undefined;
|
||||||
|
console.log('grabBuildNameFromConfig failed: ', e.message);
|
||||||
|
}
|
||||||
|
return bareBoard;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setUnifiedConfig(target, configText, bareBoard) {
|
function setUnifiedConfig(target, configText, bareBoard) {
|
||||||
|
// a target might request a firmware with the same name, remove configuration in this case.
|
||||||
if (bareBoard == target) {
|
if (bareBoard == target) {
|
||||||
console.log(bareBoard, '==', target);
|
console.log(bareBoard, '==', target);
|
||||||
if (!isConfigLocal) {
|
if (!isConfigLocal) {
|
||||||
|
@ -450,26 +465,48 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
unifiedConfig = configText;
|
unifiedConfig = configText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function clearBufferedFirmware() {
|
||||||
|
isConfigLocal = false;
|
||||||
|
targetConfig = undefined;
|
||||||
|
unifiedConfig = undefined;
|
||||||
|
intel_hex = false;
|
||||||
|
parsed_hex = false;
|
||||||
|
self.localFirmwareLoaded = false;
|
||||||
|
}
|
||||||
|
|
||||||
$('select[name="board"]').change(function() {
|
$('select[name="board"]').change(function() {
|
||||||
$("a.load_remote_file").addClass('disabled');
|
$("a.load_remote_file").addClass('disabled');
|
||||||
var target = $(this).val();
|
var target = $(this).val();
|
||||||
ConfigStorage.set({'selected_board': target});
|
|
||||||
console.log('board changed to', target);
|
|
||||||
|
|
||||||
if (!GUI.connect_lock) {
|
if (!GUI.connect_lock) {
|
||||||
|
if (TABS.firmware_flasher.selectedBoard != target) {
|
||||||
|
// We're sure the board actually changed
|
||||||
|
if (isConfigLocal) {
|
||||||
|
console.log('Board changed, unloading local config');
|
||||||
|
isConfigLocal = false;
|
||||||
|
targetConfig = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ConfigStorage.set({'selected_board': target});
|
||||||
|
TABS.firmware_flasher.selectedBoard = target;
|
||||||
|
TABS.firmware_flasher.bareBoard = undefined;
|
||||||
|
console.log('board changed to', target);
|
||||||
|
|
||||||
self.flashingMessage('firmwareFlasherLoadFirmwareFile', self.FLASH_MESSAGE_TYPES.NEUTRAL)
|
self.flashingMessage('firmwareFlasherLoadFirmwareFile', self.FLASH_MESSAGE_TYPES.NEUTRAL)
|
||||||
.flashProgress(0);
|
.flashProgress(0);
|
||||||
|
|
||||||
$('div.git_info').slideUp();
|
$('div.git_info').slideUp();
|
||||||
$('div.release_info').slideUp();
|
$('div.release_info').slideUp();
|
||||||
|
|
||||||
if (!self.localFileLoaded) {
|
if (!self.localFirmwareLoaded) {
|
||||||
self.enableFlashing(false);
|
self.enableFlashing(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var versions_e = $('select[name="firmware_version"]');
|
var versions_e = $('select[name="firmware_version"]');
|
||||||
if(target == 0) {
|
if(target == 0) {
|
||||||
|
// target == 0 is the "Choose a Board" option. Throw out anything loaded
|
||||||
|
clearBufferedFirmware();
|
||||||
|
|
||||||
versions_e.empty();
|
versions_e.empty();
|
||||||
versions_e.append($("<option value='0'>{0}</option>".format(i18n.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersion'))));
|
versions_e.append($("<option value='0'>{0}</option>".format(i18n.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersion'))));
|
||||||
} else {
|
} else {
|
||||||
|
@ -499,6 +536,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
chrome.storage.local.set(newStorageObj);
|
chrome.storage.local.set(newStorageObj);
|
||||||
|
|
||||||
bareBoard = grabBuildNameFromConfig(data);
|
bareBoard = grabBuildNameFromConfig(data);
|
||||||
|
TABS.firmware_flasher.bareBoard = bareBoard;
|
||||||
setUnifiedConfig(target, data, bareBoard);
|
setUnifiedConfig(target, data, bareBoard);
|
||||||
populateVersions(versions_e, TABS.firmware_flasher.releases[bareBoard], target);
|
populateVersions(versions_e, TABS.firmware_flasher.releases[bareBoard], target);
|
||||||
}).fail(xhr => {
|
}).fail(xhr => {
|
||||||
|
@ -515,6 +553,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
var data = storageObj.data;
|
var data = storageObj.data;
|
||||||
|
|
||||||
bareBoard = grabBuildNameFromConfig(data);
|
bareBoard = grabBuildNameFromConfig(data);
|
||||||
|
TABS.firmware_flasher.bareBoard = bareBoard;
|
||||||
setUnifiedConfig(target, data, bareBoard);
|
setUnifiedConfig(target, data, bareBoard);
|
||||||
populateVersions(versions_e, TABS.firmware_flasher.releases[bareBoard], target);
|
populateVersions(versions_e, TABS.firmware_flasher.releases[bareBoard], target);
|
||||||
}
|
}
|
||||||
|
@ -526,6 +565,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
} else {
|
} else {
|
||||||
unifiedConfig = undefined;
|
unifiedConfig = undefined;
|
||||||
}
|
}
|
||||||
|
TABS.firmware_flasher.bareBoard = target;
|
||||||
populateVersions(versions_e, TABS.firmware_flasher.releases[target], target);
|
populateVersions(versions_e, TABS.firmware_flasher.releases[target], target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -533,10 +573,24 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function flashingMessageLocal() {
|
||||||
|
// used by the a.load_file hook, evaluate the loaded information, and enable flashing if suitable
|
||||||
|
if (isConfigLocal && !parsed_hex) {
|
||||||
|
self.flashingMessage(i18n.getMessage('firmwareFlasherLoadedConfig'), self.FLASH_MESSAGE_TYPES.NEUTRAL);
|
||||||
|
}
|
||||||
|
if (isConfigLocal && parsed_hex && !self.localFirmwareLoaded) {
|
||||||
|
self.enableFlashing(true);
|
||||||
|
self.flashingMessage(i18n.getMessage('firmwareFlasherFirmwareLocalLoaded', parsed_hex.bytes_total), self.FLASH_MESSAGE_TYPES.NEUTRAL);
|
||||||
|
}
|
||||||
|
if (self.localFirmwareLoaded) {
|
||||||
|
self.enableFlashing(true);
|
||||||
|
self.flashingMessage(i18n.getMessage('firmwareFlasherFirmwareLocalLoaded', parsed_hex.bytes_total), self.FLASH_MESSAGE_TYPES.NEUTRAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
// UI Hooks
|
// UI Hooks
|
||||||
$('a.load_file').click(function () {
|
$('a.load_file').click(function () {
|
||||||
self.enableFlashing(false);
|
self.enableFlashing(false);
|
||||||
self.localFileLoaded = true;
|
//self.localFileLoaded = true;
|
||||||
|
|
||||||
analytics.setFirmwareData(analytics.DATA.FIRMWARE_CHANNEL, undefined);
|
analytics.setFirmwareData(analytics.DATA.FIRMWARE_CHANNEL, undefined);
|
||||||
analytics.setFirmwareData(analytics.DATA.FIRMWARE_SOURCE, 'file');
|
analytics.setFirmwareData(analytics.DATA.FIRMWARE_SOURCE, 'file');
|
||||||
|
@ -580,16 +634,17 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
|
|
||||||
if (parsed_hex) {
|
if (parsed_hex) {
|
||||||
analytics.setFirmwareData(analytics.DATA.FIRMWARE_SIZE, parsed_hex.bytes_total);
|
analytics.setFirmwareData(analytics.DATA.FIRMWARE_SIZE, parsed_hex.bytes_total);
|
||||||
|
self.localFirmwareLoaded = true;
|
||||||
self.enableFlashing(true);
|
flashingMessageLocal();
|
||||||
|
|
||||||
self.flashingMessage(i18n.getMessage('firmwareFlasherFirmwareLocalLoaded', parsed_hex.bytes_total), self.FLASH_MESSAGE_TYPES.NEUTRAL);
|
|
||||||
} else {
|
} else {
|
||||||
self.flashingMessage('firmwareFlasherHexCorrupted', self.FLASH_MESSAGE_TYPES.INVALID);
|
self.flashingMessage('firmwareFlasherHexCorrupted', self.FLASH_MESSAGE_TYPES.INVALID);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
clearBufferedFirmware();
|
||||||
targetConfig = e.target.result;
|
targetConfig = e.target.result;
|
||||||
|
isConfigLocal = true;
|
||||||
|
flashingMessageLocal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -606,8 +661,15 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
$('select[name="firmware_version"]').change(function(evt){
|
$('select[name="firmware_version"]').change(function(evt){
|
||||||
$('div.release_info').slideUp();
|
$('div.release_info').slideUp();
|
||||||
|
|
||||||
if (!self.localFileLoaded) {
|
if (!self.localFirmwareLoaded) {
|
||||||
self.enableFlashing(false);
|
self.enableFlashing(false);
|
||||||
|
self.flashingMessage(i18n.getMessage('firmwareFlasherLoadFirmwareFile'), self.FLASH_MESSAGE_TYPES.NEUTRAL);
|
||||||
|
if(parsed_hex && parsed_hex.bytes_total) {
|
||||||
|
// Changing the board triggers a version change, so we need only dump it here.
|
||||||
|
console.log('throw out loaded hex');
|
||||||
|
intel_hex = false;
|
||||||
|
parsed_hex = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let release = $("option:selected", evt.target).data("summary");
|
let release = $("option:selected", evt.target).data("summary");
|
||||||
|
@ -631,7 +693,7 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
|
|
||||||
$('a.load_remote_file').click(function (evt) {
|
$('a.load_remote_file').click(function (evt) {
|
||||||
self.enableFlashing(false);
|
self.enableFlashing(false);
|
||||||
self.localFileLoaded = false;
|
self.localFirmwareLoaded = false;
|
||||||
|
|
||||||
analytics.setFirmwareData(analytics.DATA.FIRMWARE_SOURCE, 'http');
|
analytics.setFirmwareData(analytics.DATA.FIRMWARE_SOURCE, 'http');
|
||||||
|
|
||||||
|
@ -649,6 +711,16 @@ TABS.firmware_flasher.initialize = function (callback) {
|
||||||
|
|
||||||
var summary = $('select[name="firmware_version"] option:selected').data('summary');
|
var summary = $('select[name="firmware_version"] option:selected').data('summary');
|
||||||
if (summary) { // undefined while list is loading or while running offline
|
if (summary) { // undefined while list is loading or while running offline
|
||||||
|
if (isConfigLocal && FirmwareCache.has(summary)) {
|
||||||
|
// Load the .hex from Cache if available when the user is providing their own config.
|
||||||
|
analytics.setFirmwareData(analytics.DATA.FIRMWARE_SOURCE, 'cache');
|
||||||
|
FirmwareCache.get(summary, cached => {
|
||||||
|
analytics.setFirmwareData(analytics.DATA.FIRMWARE_NAME, summary.file);
|
||||||
|
console.info("Release found in cache: " + summary.file);
|
||||||
|
onLoadSuccess(cached.hexdata, summary);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
analytics.setFirmwareData(analytics.DATA.FIRMWARE_NAME, summary.file);
|
analytics.setFirmwareData(analytics.DATA.FIRMWARE_NAME, summary.file);
|
||||||
$("a.load_remote_file").text(i18n.getMessage('firmwareFlasherButtonDownloading'));
|
$("a.load_remote_file").text(i18n.getMessage('firmwareFlasherButtonDownloading'));
|
||||||
$("a.load_remote_file").addClass('disabled');
|
$("a.load_remote_file").addClass('disabled');
|
||||||
|
|
|
@ -93,7 +93,6 @@
|
||||||
href="#" target="_blank"></a><br /> <strong i18n="firmwareFlasherReleaseFile"></strong> <a
|
href="#" target="_blank"></a><br /> <strong i18n="firmwareFlasherReleaseFile"></strong> <a
|
||||||
i18n_title="firmwareFlasherReleaseFileUrl" class="file" href="#" target="_blank"></a><br /> <strong
|
i18n_title="firmwareFlasherReleaseFileUrl" class="file" href="#" target="_blank"></a><br /> <strong
|
||||||
i18n="firmwareFlasherReleaseDate"></strong> <span class="date"></span><br /> <strong
|
i18n="firmwareFlasherReleaseDate"></strong> <span class="date"></span><br /> <strong
|
||||||
i18n="firmwareFlasherReleaseStatus"></strong> <span class="status"></span><br /> <strong
|
|
||||||
i18n="firmwareFlasherReleaseNotes"></strong>
|
i18n="firmwareFlasherReleaseNotes"></strong>
|
||||||
<div class=notes></div>
|
<div class=notes></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue