mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-23 16:25:22 +03:00
Merge pull request #697 from wind0r/add_firmware_to_topbar
add firmware version to top bar
This commit is contained in:
commit
0b1a8b0bcc
3 changed files with 70 additions and 53 deletions
|
@ -68,10 +68,10 @@ $(document).ready(function () {
|
||||||
GUI.interval_kill_all();
|
GUI.interval_kill_all();
|
||||||
GUI.tab_switch_cleanup();
|
GUI.tab_switch_cleanup();
|
||||||
GUI.tab_switch_in_progress = false;
|
GUI.tab_switch_in_progress = false;
|
||||||
|
|
||||||
if (semver.gte(CONFIG.apiVersion, "1.37.0") && CONFIG.arming_disabled) {
|
if (semver.gte(CONFIG.apiVersion, "1.37.0") && CONFIG.arming_disabled) {
|
||||||
CONFIG.arming_disabled = false;
|
CONFIG.arming_disabled = false;
|
||||||
|
|
||||||
MSP.send_message(MSPCodes.MSP_ARMING_DISABLE, false, false, function () {
|
MSP.send_message(MSPCodes.MSP_ARMING_DISABLE, false, false, function () {
|
||||||
GUI.log(chrome.i18n.getMessage('armingEnabled'));
|
GUI.log(chrome.i18n.getMessage('armingEnabled'));
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ $(document).ready(function () {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
finishClose(toggleStatus);
|
finishClose(toggleStatus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
function finishClose(finishedCallback) {
|
function finishClose(finishedCallback) {
|
||||||
var wasConnected = CONFIGURATOR.connectionValid;
|
var wasConnected = CONFIGURATOR.connectionValid;
|
||||||
|
|
||||||
serial.disconnect(onClosed);
|
serial.disconnect(onClosed);
|
||||||
|
|
||||||
MSP.disconnect_cleanup();
|
MSP.disconnect_cleanup();
|
||||||
|
@ -149,7 +149,7 @@ function finishClose(finishedCallback) {
|
||||||
// reset connect / disconnect button
|
// reset connect / disconnect button
|
||||||
$('div.connect_controls a.connect').removeClass('active');
|
$('div.connect_controls a.connect').removeClass('active');
|
||||||
$('div.connect_controls a.connect_state').text(chrome.i18n.getMessage('connect'));
|
$('div.connect_controls a.connect_state').text(chrome.i18n.getMessage('connect'));
|
||||||
|
|
||||||
// reset active sensor indicators
|
// reset active sensor indicators
|
||||||
sensor_status(0);
|
sensor_status(0);
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ function onOpen(openInfo) {
|
||||||
MSP.listen(update_packet_error);
|
MSP.listen(update_packet_error);
|
||||||
mspHelper = new MspHelper();
|
mspHelper = new MspHelper();
|
||||||
MSP.listen(mspHelper.process_data.bind(mspHelper));
|
MSP.listen(mspHelper.process_data.bind(mspHelper));
|
||||||
|
|
||||||
// request configuration data
|
// request configuration data
|
||||||
MSP.send_message(MSPCodes.MSP_API_VERSION, false, false, function () {
|
MSP.send_message(MSPCodes.MSP_API_VERSION, false, false, function () {
|
||||||
GUI.log(chrome.i18n.getMessage('apiVersionReceived', [CONFIG.apiVersion]));
|
GUI.log(chrome.i18n.getMessage('apiVersionReceived', [CONFIG.apiVersion]));
|
||||||
|
@ -215,6 +215,7 @@ function onOpen(openInfo) {
|
||||||
|
|
||||||
GUI.log(chrome.i18n.getMessage('fcInfoReceived', [CONFIG.flightControllerIdentifier, CONFIG.flightControllerVersion]));
|
GUI.log(chrome.i18n.getMessage('fcInfoReceived', [CONFIG.flightControllerIdentifier, CONFIG.flightControllerVersion]));
|
||||||
updateStatusBarVersion(CONFIG.flightControllerVersion, CONFIG.flightControllerIdentifier);
|
updateStatusBarVersion(CONFIG.flightControllerVersion, CONFIG.flightControllerIdentifier);
|
||||||
|
updateTopBarVersion(CONFIG.flightControllerVersion, CONFIG.flightControllerIdentifier);
|
||||||
|
|
||||||
MSP.send_message(MSPCodes.MSP_BUILD_INFO, false, false, function () {
|
MSP.send_message(MSPCodes.MSP_BUILD_INFO, false, false, function () {
|
||||||
|
|
||||||
|
@ -224,6 +225,7 @@ function onOpen(openInfo) {
|
||||||
|
|
||||||
GUI.log(chrome.i18n.getMessage('boardInfoReceived', [CONFIG.boardIdentifier, CONFIG.boardVersion]));
|
GUI.log(chrome.i18n.getMessage('boardInfoReceived', [CONFIG.boardIdentifier, CONFIG.boardVersion]));
|
||||||
updateStatusBarVersion(CONFIG.flightControllerVersion, CONFIG.flightControllerIdentifier, CONFIG.boardIdentifier);
|
updateStatusBarVersion(CONFIG.flightControllerVersion, CONFIG.flightControllerIdentifier, CONFIG.boardIdentifier);
|
||||||
|
updateTopBarVersion(CONFIG.flightControllerVersion, CONFIG.flightControllerIdentifier, CONFIG.boardIdentifier);
|
||||||
|
|
||||||
MSP.send_message(MSPCodes.MSP_UID, false, false, function () {
|
MSP.send_message(MSPCodes.MSP_UID, false, false, function () {
|
||||||
GUI.log(chrome.i18n.getMessage('uniqueDeviceIdReceived', [CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16)]));
|
GUI.log(chrome.i18n.getMessage('uniqueDeviceIdReceived', [CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16)]));
|
||||||
|
@ -234,7 +236,7 @@ function onOpen(openInfo) {
|
||||||
|
|
||||||
if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
|
if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
|
||||||
CONFIG.arming_disabled = true;
|
CONFIG.arming_disabled = true;
|
||||||
|
|
||||||
MSP.send_message(MSPCodes.MSP_ARMING_DISABLE, false, false, function () {
|
MSP.send_message(MSPCodes.MSP_ARMING_DISABLE, false, false, function () {
|
||||||
GUI.log(chrome.i18n.getMessage('armingDisabled'));
|
GUI.log(chrome.i18n.getMessage('armingDisabled'));
|
||||||
|
|
||||||
|
@ -303,15 +305,15 @@ function onConnect() {
|
||||||
GUI.timeout_remove('connecting'); // kill connecting timer
|
GUI.timeout_remove('connecting'); // kill connecting timer
|
||||||
$('div#connectbutton a.connect_state').text(chrome.i18n.getMessage('disconnect')).addClass('active');
|
$('div#connectbutton a.connect_state').text(chrome.i18n.getMessage('disconnect')).addClass('active');
|
||||||
$('div#connectbutton a.connect').addClass('active');
|
$('div#connectbutton a.connect').addClass('active');
|
||||||
|
|
||||||
$('#tabs ul.mode-disconnected').hide();
|
$('#tabs ul.mode-disconnected').hide();
|
||||||
$('#tabs ul.mode-connected-cli').show();
|
$('#tabs ul.mode-connected-cli').show();
|
||||||
|
|
||||||
|
|
||||||
// show only appropriate tabs
|
// show only appropriate tabs
|
||||||
$('#tabs ul.mode-connected li').hide();
|
$('#tabs ul.mode-connected li').hide();
|
||||||
$('#tabs ul.mode-connected li').filter(function (index) {
|
$('#tabs ul.mode-connected li').filter(function (index) {
|
||||||
var classes = $(this).attr("class").split(/\s+/);
|
var classes = $(this).attr("class").split(/\s+/);
|
||||||
var found = false;
|
var found = false;
|
||||||
$.each(GUI.allowedTabs, function (index, value) {
|
$.each(GUI.allowedTabs, function (index, value) {
|
||||||
var tabName = "tab_" + value;
|
var tabName = "tab_" + value;
|
||||||
|
@ -325,10 +327,10 @@ function onConnect() {
|
||||||
found = false;
|
found = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return found;
|
return found;
|
||||||
}).show();
|
}).show();
|
||||||
|
|
||||||
if (CONFIG.flightControllerVersion !== '') {
|
if (CONFIG.flightControllerVersion !== '') {
|
||||||
FEATURE_CONFIG.features = new Features(CONFIG);
|
FEATURE_CONFIG.features = new Features(CONFIG);
|
||||||
BEEPER_CONFIG.beepers = new Beepers(CONFIG);
|
BEEPER_CONFIG.beepers = new Beepers(CONFIG);
|
||||||
|
@ -346,12 +348,12 @@ function onConnect() {
|
||||||
startLiveDataRefreshTimer();
|
startLiveDataRefreshTimer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var sensor_state = $('#sensor-status');
|
var sensor_state = $('#sensor-status');
|
||||||
sensor_state.show();
|
sensor_state.show();
|
||||||
|
|
||||||
var port_picker = $('#portsinput');
|
var port_picker = $('#portsinput');
|
||||||
port_picker.hide();
|
port_picker.hide();
|
||||||
|
|
||||||
var dataflash = $('#dataflash_wrapper_global');
|
var dataflash = $('#dataflash_wrapper_global');
|
||||||
dataflash.show();
|
dataflash.show();
|
||||||
|
@ -369,21 +371,22 @@ function onClosed(result) {
|
||||||
$('#tabs ul.mode-disconnected').show();
|
$('#tabs ul.mode-disconnected').show();
|
||||||
|
|
||||||
updateStatusBarVersion();
|
updateStatusBarVersion();
|
||||||
|
updateTopBarVersion();
|
||||||
|
|
||||||
var sensor_state = $('#sensor-status');
|
var sensor_state = $('#sensor-status');
|
||||||
sensor_state.hide();
|
sensor_state.hide();
|
||||||
|
|
||||||
var port_picker = $('#portsinput');
|
var port_picker = $('#portsinput');
|
||||||
port_picker.show();
|
port_picker.show();
|
||||||
|
|
||||||
var dataflash = $('#dataflash_wrapper_global');
|
var dataflash = $('#dataflash_wrapper_global');
|
||||||
dataflash.hide();
|
dataflash.hide();
|
||||||
|
|
||||||
var battery = $('#quad-status_wrapper');
|
var battery = $('#quad-status_wrapper');
|
||||||
battery.hide();
|
battery.hide();
|
||||||
|
|
||||||
MSP.clearListeners();
|
MSP.clearListeners();
|
||||||
|
|
||||||
CONFIGURATOR.connectionValid = false;
|
CONFIGURATOR.connectionValid = false;
|
||||||
CONFIGURATOR.cliValid = false;
|
CONFIGURATOR.cliValid = false;
|
||||||
CONFIGURATOR.cliActive = false;
|
CONFIGURATOR.cliActive = false;
|
||||||
|
@ -491,12 +494,12 @@ function update_dataflash_global() {
|
||||||
|
|
||||||
$(".noflash_global").css({
|
$(".noflash_global").css({
|
||||||
display: 'none'
|
display: 'none'
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".dataflash-contents_global").css({
|
$(".dataflash-contents_global").css({
|
||||||
display: 'block'
|
display: 'block'
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".dataflash-free_global").css({
|
$(".dataflash-free_global").css({
|
||||||
width: (100-(DATAFLASH.totalSize - DATAFLASH.usedSize) / DATAFLASH.totalSize * 100) + "%",
|
width: (100-(DATAFLASH.totalSize - DATAFLASH.usedSize) / DATAFLASH.totalSize * 100) + "%",
|
||||||
display: 'block'
|
display: 'block'
|
||||||
|
@ -505,12 +508,12 @@ function update_dataflash_global() {
|
||||||
} else {
|
} else {
|
||||||
$(".noflash_global").css({
|
$(".noflash_global").css({
|
||||||
display: 'block'
|
display: 'block'
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".dataflash-contents_global").css({
|
$(".dataflash-contents_global").css({
|
||||||
display: 'none'
|
display: 'none'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,15 +521,15 @@ function startLiveDataRefreshTimer() {
|
||||||
// live data refresh
|
// live data refresh
|
||||||
GUI.timeout_add('data_refresh', function () { update_live_status(); }, 100);
|
GUI.timeout_add('data_refresh', function () { update_live_status(); }, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_live_status() {
|
function update_live_status() {
|
||||||
|
|
||||||
var statuswrapper = $('#quad-status_wrapper');
|
var statuswrapper = $('#quad-status_wrapper');
|
||||||
|
|
||||||
$(".quad-status-contents").css({
|
$(".quad-status-contents").css({
|
||||||
display: 'inline-block'
|
display: 'inline-block'
|
||||||
});
|
});
|
||||||
|
|
||||||
if (GUI.active_tab != 'cli') {
|
if (GUI.active_tab != 'cli') {
|
||||||
MSP.send_message(MSPCodes.MSP_BOXNAMES, false, false);
|
MSP.send_message(MSPCodes.MSP_BOXNAMES, false, false);
|
||||||
if (semver.gte(CONFIG.apiVersion, "1.32.0"))
|
if (semver.gte(CONFIG.apiVersion, "1.32.0"))
|
||||||
|
@ -535,7 +538,7 @@ function update_live_status() {
|
||||||
MSP.send_message(MSPCodes.MSP_STATUS, false, false);
|
MSP.send_message(MSPCodes.MSP_STATUS, false, false);
|
||||||
MSP.send_message(MSPCodes.MSP_ANALOG, false, false);
|
MSP.send_message(MSPCodes.MSP_ANALOG, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var active = ((Date.now() - ANALOG.last_received_timestamp) < 300);
|
var active = ((Date.now() - ANALOG.last_received_timestamp) < 300);
|
||||||
|
|
||||||
for (var i = 0; i < AUX_CONFIG.length; i++) {
|
for (var i = 0; i < AUX_CONFIG.length; i++) {
|
||||||
|
@ -561,19 +564,19 @@ function update_live_status() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ANALOG != undefined) {
|
if (ANALOG != undefined) {
|
||||||
var nbCells = Math.floor(ANALOG.voltage / BATTERY_CONFIG.vbatmaxcellvoltage) + 1;
|
var nbCells = Math.floor(ANALOG.voltage / BATTERY_CONFIG.vbatmaxcellvoltage) + 1;
|
||||||
if (ANALOG.voltage == 0)
|
if (ANALOG.voltage == 0)
|
||||||
nbCells = 1;
|
nbCells = 1;
|
||||||
|
|
||||||
var min = BATTERY_CONFIG.vbatmincellvoltage * nbCells;
|
var min = BATTERY_CONFIG.vbatmincellvoltage * nbCells;
|
||||||
var max = BATTERY_CONFIG.vbatmaxcellvoltage * nbCells;
|
var max = BATTERY_CONFIG.vbatmaxcellvoltage * nbCells;
|
||||||
var warn = BATTERY_CONFIG.vbatwarningcellvoltage * nbCells;
|
var warn = BATTERY_CONFIG.vbatwarningcellvoltage * nbCells;
|
||||||
|
|
||||||
$(".battery-status").css({
|
$(".battery-status").css({
|
||||||
width: ((ANALOG.voltage - min) / (max - min) * 100) + "%",
|
width: ((ANALOG.voltage - min) / (max - min) * 100) + "%",
|
||||||
display: 'inline-block'
|
display: 'inline-block'
|
||||||
});
|
});
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
$(".linkicon").css({
|
$(".linkicon").css({
|
||||||
'background-image': 'url(images/icons/cf_icon_link_active.svg)'
|
'background-image': 'url(images/icons/cf_icon_link_active.svg)'
|
||||||
|
@ -582,14 +585,14 @@ function update_live_status() {
|
||||||
$(".linkicon").css({
|
$(".linkicon").css({
|
||||||
'background-image': 'url(images/icons/cf_icon_link_grey.svg)'
|
'background-image': 'url(images/icons/cf_icon_link_grey.svg)'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ANALOG.voltage < warn) {
|
if (ANALOG.voltage < warn) {
|
||||||
$(".battery-status").css('background-color', '#D42133');
|
$(".battery-status").css('background-color', '#D42133');
|
||||||
} else {
|
} else {
|
||||||
$(".battery-status").css('background-color', '#59AA29');
|
$(".battery-status").css('background-color', '#59AA29');
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".battery-legend").text(ANALOG.voltage + " V");
|
$(".battery-legend").text(ANALOG.voltage + " V");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -620,27 +623,27 @@ function update_dataflash_global() {
|
||||||
return bytes + "B";
|
return bytes + "B";
|
||||||
}
|
}
|
||||||
var kilobytes = bytes / 1024;
|
var kilobytes = bytes / 1024;
|
||||||
|
|
||||||
if (kilobytes < 1024) {
|
if (kilobytes < 1024) {
|
||||||
return Math.round(kilobytes) + "kB";
|
return Math.round(kilobytes) + "kB";
|
||||||
}
|
}
|
||||||
|
|
||||||
var megabytes = kilobytes / 1024;
|
var megabytes = kilobytes / 1024;
|
||||||
|
|
||||||
return megabytes.toFixed(1) + "MB";
|
return megabytes.toFixed(1) + "MB";
|
||||||
}
|
}
|
||||||
|
|
||||||
var supportsDataflash = DATAFLASH.totalSize > 0;
|
var supportsDataflash = DATAFLASH.totalSize > 0;
|
||||||
|
|
||||||
if (supportsDataflash){
|
if (supportsDataflash){
|
||||||
$(".noflash_global").css({
|
$(".noflash_global").css({
|
||||||
display: 'none'
|
display: 'none'
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".dataflash-contents_global").css({
|
$(".dataflash-contents_global").css({
|
||||||
display: 'block'
|
display: 'block'
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".dataflash-free_global").css({
|
$(".dataflash-free_global").css({
|
||||||
width: (100-(DATAFLASH.totalSize - DATAFLASH.usedSize) / DATAFLASH.totalSize * 100) + "%",
|
width: (100-(DATAFLASH.totalSize - DATAFLASH.usedSize) / DATAFLASH.totalSize * 100) + "%",
|
||||||
display: 'block'
|
display: 'block'
|
||||||
|
@ -649,10 +652,10 @@ function update_dataflash_global() {
|
||||||
} else {
|
} else {
|
||||||
$(".noflash_global").css({
|
$(".noflash_global").css({
|
||||||
display: 'block'
|
display: 'block'
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".dataflash-contents_global").css({
|
$(".dataflash-contents_global").css({
|
||||||
display: 'none'
|
display: 'none'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
main.css
2
main.css
|
@ -134,7 +134,7 @@ input[type="number"]::-webkit-inner-spin-button {
|
||||||
.logo_text {
|
.logo_text {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
width: 125px;
|
width: 200px;
|
||||||
left: 80px;
|
left: 80px;
|
||||||
top: 50px;
|
top: 50px;
|
||||||
color: #949494;
|
color: #949494;
|
||||||
|
|
18
main.js
18
main.js
|
@ -11,6 +11,7 @@ $(document).ready(function () {
|
||||||
|
|
||||||
$('#logo .version').text(chrome.runtime.getManifest().version);
|
$('#logo .version').text(chrome.runtime.getManifest().version);
|
||||||
updateStatusBarVersion();
|
updateStatusBarVersion();
|
||||||
|
updateTopBarVersion();
|
||||||
|
|
||||||
// notification messages for various operating systems
|
// notification messages for various operating systems
|
||||||
switch (GUI.operating_system) {
|
switch (GUI.operating_system) {
|
||||||
|
@ -158,7 +159,7 @@ $(document).ready(function () {
|
||||||
case 'setup_osd':
|
case 'setup_osd':
|
||||||
TABS.setup_osd.initialize(content_ready);
|
TABS.setup_osd.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'configuration':
|
case 'configuration':
|
||||||
TABS.configuration.initialize(content_ready);
|
TABS.configuration.initialize(content_ready);
|
||||||
break;
|
break;
|
||||||
|
@ -500,7 +501,7 @@ function generateFilename(prefix, suffix) {
|
||||||
|
|
||||||
if (CONFIG) {
|
if (CONFIG) {
|
||||||
if (CONFIG.flightControllerIdentifier) {
|
if (CONFIG.flightControllerIdentifier) {
|
||||||
filename = CONFIG.flightControllerIdentifier + '_' + filename;
|
filename = CONFIG.flightControllerIdentifier + '_' + filename;
|
||||||
}
|
}
|
||||||
if(CONFIG.name && CONFIG.name.trim() !== '') {
|
if(CONFIG.name && CONFIG.name.trim() !== '') {
|
||||||
filename = filename + '_' + CONFIG.name.trim().replace(' ', '_');
|
filename = filename + '_' + CONFIG.name.trim().replace(' ', '_');
|
||||||
|
@ -517,6 +518,19 @@ function generateFilename(prefix, suffix) {
|
||||||
return filename + '.' + suffix;
|
return filename + '.' + suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateTopBarVersion(firmwareVersion, firmwareId, hardwareId) {
|
||||||
|
var versionText = chrome.i18n.getMessage('versionLabelConfigurator') + ': ' + chrome.runtime.getManifest().version + '<br />';
|
||||||
|
|
||||||
|
if (firmwareVersion) {
|
||||||
|
versionText += chrome.i18n.getMessage('versionLabelFirmware') + ': ' + firmwareId + ' ' + firmwareVersion;
|
||||||
|
if (hardwareId) {
|
||||||
|
versionText += ' (Target: ' + hardwareId + ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#logo .logo_text').html(versionText);
|
||||||
|
}
|
||||||
|
|
||||||
function updateStatusBarVersion(firmwareVersion, firmwareId, hardwareId) {
|
function updateStatusBarVersion(firmwareVersion, firmwareId, hardwareId) {
|
||||||
var versionText = '';
|
var versionText = '';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue