mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-16 04:45:20 +03:00
Issue #74: Show battery & statuses in top bar
- Battery voltage appears as a horizontal bar - Autodetection of battery type is used to calculate the bar min, max & alarm values according to the battery configuration parameters. - Color changes to red when battery level goes under the alarm setting - Armed, failsafe and Serial Link status icons below battery voltage monitor - Change calibration button contents to "Calibrating" during calibration
This commit is contained in:
parent
81a49d48b2
commit
0518ed6993
15 changed files with 433 additions and 40 deletions
|
@ -264,7 +264,9 @@ function onConnect() {
|
|||
port_picker.hide();
|
||||
|
||||
var dataflash = $('#dataflash_wrapper_global');
|
||||
dataflash.show();
|
||||
dataflash.show();
|
||||
|
||||
startLiveDataRefreshTimer();
|
||||
|
||||
}
|
||||
|
||||
|
@ -286,6 +288,9 @@ function onClosed(result) {
|
|||
|
||||
var dataflash = $('#dataflash_wrapper_global');
|
||||
dataflash.hide();
|
||||
|
||||
var battery = $('#quad-status_wrapper');
|
||||
battery.hide();
|
||||
}
|
||||
|
||||
function read_serial(info) {
|
||||
|
@ -339,7 +344,7 @@ function sensor_status(sensors_detected) {
|
|||
|
||||
if (have_sensor(sensors_detected, 'mag')) {
|
||||
$('.mag', e_sensor_status).addClass('on');
|
||||
$('.magicon', e_sensor_status).addClass('active');
|
||||
$('.magicon', e_sensor_status).addClass('active');
|
||||
} else {
|
||||
$('.mag', e_sensor_status).removeClass('on');
|
||||
$('.magicon', e_sensor_status).removeClass('active');
|
||||
|
@ -347,7 +352,7 @@ function sensor_status(sensors_detected) {
|
|||
|
||||
if (have_sensor(sensors_detected, 'gps')) {
|
||||
$('.gps', e_sensor_status).addClass('on');
|
||||
$('.gpsicon', e_sensor_status).addClass('active');
|
||||
$('.gpsicon', e_sensor_status).addClass('active');
|
||||
} else {
|
||||
$('.gps', e_sensor_status).removeClass('on');
|
||||
$('.gpsicon', e_sensor_status).removeClass('active');
|
||||
|
@ -385,34 +390,117 @@ function highByte(num) {
|
|||
|
||||
function lowByte(num) {
|
||||
return 0x00FF & num;
|
||||
}function update_dataflash_global() {
|
||||
var supportsDataflash = DATAFLASH.totalSize > 0;
|
||||
if (supportsDataflash){
|
||||
}
|
||||
|
||||
$(".noflash_global").css({
|
||||
display: 'none'
|
||||
});
|
||||
function update_dataflash_global() {
|
||||
var supportsDataflash = DATAFLASH.totalSize > 0;
|
||||
if (supportsDataflash){
|
||||
|
||||
$(".dataflash-contents_global").css({
|
||||
display: 'block'
|
||||
});
|
||||
$(".noflash_global").css({
|
||||
display: 'none'
|
||||
});
|
||||
|
||||
$(".dataflash-contents_global").css({
|
||||
display: 'block'
|
||||
});
|
||||
|
||||
$(".dataflash-free_global").css({
|
||||
width: (100-(DATAFLASH.totalSize - DATAFLASH.usedSize) / DATAFLASH.totalSize * 100) + "%",
|
||||
display: 'block'
|
||||
});
|
||||
$(".dataflash-free_global div").text('Dataflash: free ' + formatFilesize(DATAFLASH.totalSize - DATAFLASH.usedSize));
|
||||
} else {
|
||||
$(".noflash_global").css({
|
||||
display: 'block'
|
||||
});
|
||||
$(".dataflash-free_global").css({
|
||||
width: (100-(DATAFLASH.totalSize - DATAFLASH.usedSize) / DATAFLASH.totalSize * 100) + "%",
|
||||
display: 'block'
|
||||
});
|
||||
$(".dataflash-free_global div").text('Dataflash: free ' + formatFilesize(DATAFLASH.totalSize - DATAFLASH.usedSize));
|
||||
} else {
|
||||
$(".noflash_global").css({
|
||||
display: 'block'
|
||||
});
|
||||
|
||||
$(".dataflash-contents_global").css({
|
||||
display: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
$(".dataflash-contents_global").css({
|
||||
display: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function startLiveDataRefreshTimer() {
|
||||
// live data refresh
|
||||
GUI.timeout_add('data_refresh', function () { update_live_status(); }, 100);
|
||||
}
|
||||
|
||||
function update_live_status() {
|
||||
|
||||
var statuswrapper = $('#quad-status_wrapper');
|
||||
|
||||
$(".quad-status-contents").css({
|
||||
display: 'inline-block'
|
||||
});
|
||||
|
||||
if (GUI.active_tab != 'cli') {
|
||||
MSP.send_message(MSP_codes.MSP_BOXNAMES, false, false);
|
||||
MSP.send_message(MSP_codes.MSP_STATUS, false, false);
|
||||
MSP.send_message(MSP_codes.MSP_ANALOG, false, false);
|
||||
}
|
||||
|
||||
var active = ((Date.now() - MSP.analog_last_received_timestamp) < 300);
|
||||
|
||||
for (var i = 0; i < AUX_CONFIG.length; i++) {
|
||||
if (AUX_CONFIG[i] == 'ARM') {
|
||||
if (bit_check(CONFIG.mode, i))
|
||||
$(".armedicon").css({
|
||||
'background-image': 'url(images/icons/cf_icon_armed_active.svg)'
|
||||
});
|
||||
else
|
||||
$(".armedicon").css({
|
||||
'background-image': 'url(images/icons/cf_icon_armed_grey.svg)'
|
||||
});
|
||||
}
|
||||
if (AUX_CONFIG[i] == 'FAILSAFE') {
|
||||
if (bit_check(CONFIG.mode, i))
|
||||
$(".failsafeicon").css({
|
||||
'background-image': 'url(images/icons/cf_icon_failsafe_active.svg)'
|
||||
});
|
||||
else
|
||||
$(".failsafeicon").css({
|
||||
'background-image': 'url(images/icons/cf_icon_failsafe_grey.svg)'
|
||||
});
|
||||
}
|
||||
}
|
||||
if (ANALOG != undefined) {
|
||||
var nbCells = Math.floor(ANALOG.voltage / MISC.vbatmaxcellvoltage) + 1;
|
||||
if (ANALOG.voltage == 0)
|
||||
nbCells = 1;
|
||||
|
||||
var min = MISC.vbatmincellvoltage * nbCells;
|
||||
var max = MISC.vbatmaxcellvoltage * nbCells;
|
||||
var warn = MISC.vbatwarningcellvoltage * nbCells;
|
||||
|
||||
$(".battery-status").css({
|
||||
width: ((ANALOG.voltage - min) / (max - min) * 100) + "%",
|
||||
display: 'inline-block'
|
||||
});
|
||||
|
||||
if (active) {
|
||||
$(".linkicon").css({
|
||||
'background-image': 'url(images/icons/cf_icon_link_active.svg)'
|
||||
});
|
||||
} else {
|
||||
$(".linkicon").css({
|
||||
'background-image': 'url(images/icons/cf_icon_link_grey.svg)'
|
||||
});
|
||||
}
|
||||
|
||||
if (ANALOG.voltage < warn) {
|
||||
$(".battery-status").css('background-color', '#D42133');
|
||||
} else {
|
||||
$(".battery-status").css('background-color', '#59AA29');
|
||||
}
|
||||
|
||||
$(".battery-legend").text(ANALOG.voltage + " V");
|
||||
}
|
||||
|
||||
statuswrapper.show();
|
||||
GUI.timeout_remove('data_refresh');
|
||||
startLiveDataRefreshTimer();
|
||||
}
|
||||
|
||||
function specificByte(num, pos) {
|
||||
return 0x000000FF & (num >> (8 * pos));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue