mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-14 20:10:11 +03:00
fixes for global status pull handler
This commit is contained in:
parent
3f196a9505
commit
eff3eb2420
6 changed files with 40 additions and 38 deletions
|
@ -76,7 +76,7 @@ GUI_control.prototype.log = function (message) {
|
||||||
GUI_control.prototype.tab_switch_cleanup = function (callback) {
|
GUI_control.prototype.tab_switch_cleanup = function (callback) {
|
||||||
MSP.callbacks_cleanup(); // we don't care about any old data that might or might not arrive
|
MSP.callbacks_cleanup(); // we don't care about any old data that might or might not arrive
|
||||||
|
|
||||||
helper.interval.killAll();
|
helper.interval.killAll(['global_data_refresh']);
|
||||||
|
|
||||||
if (this.active_tab) {
|
if (this.active_tab) {
|
||||||
TABS[this.active_tab].cleanup(callback);
|
TABS[this.active_tab].cleanup(callback);
|
||||||
|
|
|
@ -18,6 +18,12 @@ helper.interval = (function () {
|
||||||
* @returns {{name: *, timer: null, code: *, interval: *, fired: number, paused: boolean}}
|
* @returns {{name: *, timer: null, code: *, interval: *, fired: number, paused: boolean}}
|
||||||
*/
|
*/
|
||||||
publicScope.add = function (name, code, interval, first) {
|
publicScope.add = function (name, code, interval, first) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Kill existing interval with this name if exists
|
||||||
|
*/
|
||||||
|
publicScope.remove(name);
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'timer': null,
|
'timer': null,
|
||||||
|
|
|
@ -98,15 +98,15 @@ $(document).ready(function () {
|
||||||
|
|
||||||
serial.connect(selected_port, {bitrate: selected_baud}, onOpen);
|
serial.connect(selected_port, {bitrate: selected_baud}, onOpen);
|
||||||
} else {
|
} else {
|
||||||
helper.timeout.killAll();
|
var wasConnected = CONFIGURATOR.connectionValid;
|
||||||
helper.interval.killAll();
|
|
||||||
|
helper.timeout.killAll(['global_data_refresh']);
|
||||||
|
helper.interval.killAll(['global_data_refresh']);
|
||||||
GUI.tab_switch_cleanup();
|
GUI.tab_switch_cleanup();
|
||||||
GUI.tab_switch_in_progress = false;
|
GUI.tab_switch_in_progress = false;
|
||||||
|
|
||||||
serial.disconnect(onClosed);
|
serial.disconnect(onClosed);
|
||||||
|
|
||||||
var wasConnected = CONFIGURATOR.connectionValid;
|
|
||||||
|
|
||||||
GUI.connected_to = false;
|
GUI.connected_to = false;
|
||||||
CONFIGURATOR.connectionValid = false;
|
CONFIGURATOR.connectionValid = false;
|
||||||
GUI.allowedTabs = GUI.defaultAllowedTabsWhenDisconnected.slice();
|
GUI.allowedTabs = GUI.defaultAllowedTabsWhenDisconnected.slice();
|
||||||
|
@ -324,7 +324,8 @@ function onConnect() {
|
||||||
$('#portsinput').hide();
|
$('#portsinput').hide();
|
||||||
$('#dataflash_wrapper_global').show();
|
$('#dataflash_wrapper_global').show();
|
||||||
|
|
||||||
startLiveDataRefreshTimer();
|
console.log('ready to start');
|
||||||
|
helper.interval.add('global_data_refresh', update_live_status, 100, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClosed(result) {
|
function onClosed(result) {
|
||||||
|
@ -458,42 +459,39 @@ function lowByte(num) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_dataflash_global() {
|
function update_dataflash_global() {
|
||||||
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'
|
||||||
});
|
});
|
||||||
$(".dataflash-free_global div").text('Dataflash: free ' + formatFilesize(DATAFLASH.totalSize - DATAFLASH.usedSize));
|
$(".dataflash-free_global div").text('Dataflash: free ' + formatFilesize(DATAFLASH.totalSize - DATAFLASH.usedSize));
|
||||||
} else {
|
} else {
|
||||||
$(".noflash_global").css({
|
$(".noflash_global").css({
|
||||||
display: 'block'
|
display: 'block'
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".dataflash-contents_global").css({
|
|
||||||
display: 'none'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
$(".dataflash-contents_global").css({
|
||||||
|
display: 'none'
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function startLiveDataRefreshTimer() {
|
|
||||||
// live data refresh
|
|
||||||
helper.timeout.add('data_refresh', function () { update_live_status(); }, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_live_status() {
|
function update_live_status() {
|
||||||
|
|
||||||
var statuswrapper = $('#quad-status_wrapper');
|
if (!CONFIGURATOR.connectionValid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$(".quad-status-contents").css({
|
$(".quad-status-contents").css({
|
||||||
display: 'inline-block'
|
display: 'inline-block'
|
||||||
|
@ -570,9 +568,7 @@ function update_live_status() {
|
||||||
$(".battery-legend").text(ANALOG.voltage + " V");
|
$(".battery-legend").text(ANALOG.voltage + " V");
|
||||||
}
|
}
|
||||||
|
|
||||||
statuswrapper.show();
|
$('#quad-status_wrapper').show();
|
||||||
helper.timeout.remove('data_refresh');
|
|
||||||
startLiveDataRefreshTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function specificByte(num, pos) {
|
function specificByte(num, pos) {
|
||||||
|
|
|
@ -87,7 +87,7 @@ TABS.logging.initialize = function (callback) {
|
||||||
GUI.log(chrome.i18n.getMessage('loggingErrorOneProperty'));
|
GUI.log(chrome.i18n.getMessage('loggingErrorOneProperty'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
helper.interval.killAll();
|
helper.interval.killAll(['global_data_refresh']);
|
||||||
|
|
||||||
$('.speed').prop('disabled', false);
|
$('.speed').prop('disabled', false);
|
||||||
$(this).text(chrome.i18n.getMessage('loggingStart'));
|
$(this).text(chrome.i18n.getMessage('loggingStart'));
|
||||||
|
|
|
@ -235,7 +235,7 @@ TABS.motors.initialize = function (callback) {
|
||||||
accelHelpers = initGraphHelpers('#accel', samples_accel_i, [-scale, scale]);
|
accelHelpers = initGraphHelpers('#accel', samples_accel_i, [-scale, scale]);
|
||||||
|
|
||||||
// timer initialization
|
// timer initialization
|
||||||
helper.interval.killAll(['motor_and_status_pull']);
|
helper.interval.killAll(['motor_and_status_pull', 'global_data_refresh']);
|
||||||
|
|
||||||
helper.interval.add('IMU_pull', function imu_data_pull() {
|
helper.interval.add('IMU_pull', function imu_data_pull() {
|
||||||
MSP.send_message(MSPCodes.MSP_RAW_IMU, false, false, update_accel_graph);
|
MSP.send_message(MSPCodes.MSP_RAW_IMU, false, false, update_accel_graph);
|
||||||
|
|
|
@ -356,7 +356,7 @@ TABS.sensors.initialize = function (callback) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// timer initialization
|
// timer initialization
|
||||||
helper.interval.killAll(['status_pull']);
|
helper.interval.killAll(['status_pull', 'global_data_refresh']);
|
||||||
|
|
||||||
// data pulling timers
|
// data pulling timers
|
||||||
if (checkboxes[0] || checkboxes[1] || checkboxes[2]) {
|
if (checkboxes[0] || checkboxes[1] || checkboxes[2]) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue