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

fixes for global status pull handler

This commit is contained in:
Pawel Spychalski (DzikuVx) 2017-01-18 20:20:26 +01:00
parent 3f196a9505
commit eff3eb2420
6 changed files with 40 additions and 38 deletions

View file

@ -76,7 +76,7 @@ GUI_control.prototype.log = function (message) {
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
helper.interval.killAll();
helper.interval.killAll(['global_data_refresh']);
if (this.active_tab) {
TABS[this.active_tab].cleanup(callback);

View file

@ -18,6 +18,12 @@ helper.interval = (function () {
* @returns {{name: *, timer: null, code: *, interval: *, fired: number, paused: boolean}}
*/
publicScope.add = function (name, code, interval, first) {
/*
* Kill existing interval with this name if exists
*/
publicScope.remove(name);
var data = {
'name': name,
'timer': null,

View file

@ -98,15 +98,15 @@ $(document).ready(function () {
serial.connect(selected_port, {bitrate: selected_baud}, onOpen);
} else {
helper.timeout.killAll();
helper.interval.killAll();
var wasConnected = CONFIGURATOR.connectionValid;
helper.timeout.killAll(['global_data_refresh']);
helper.interval.killAll(['global_data_refresh']);
GUI.tab_switch_cleanup();
GUI.tab_switch_in_progress = false;
serial.disconnect(onClosed);
var wasConnected = CONFIGURATOR.connectionValid;
GUI.connected_to = false;
CONFIGURATOR.connectionValid = false;
GUI.allowedTabs = GUI.defaultAllowedTabsWhenDisconnected.slice();
@ -324,7 +324,8 @@ function onConnect() {
$('#portsinput').hide();
$('#dataflash_wrapper_global').show();
startLiveDataRefreshTimer();
console.log('ready to start');
helper.interval.add('global_data_refresh', update_live_status, 100, true);
}
function onClosed(result) {
@ -458,42 +459,39 @@ function lowByte(num) {
}
function update_dataflash_global() {
var supportsDataflash = DATAFLASH.totalSize > 0;
if (supportsDataflash){
var supportsDataflash = DATAFLASH.totalSize > 0;
if (supportsDataflash) {
$(".noflash_global").css({
display: 'none'
});
$(".noflash_global").css({
display: 'none'
});
$(".dataflash-contents_global").css({
display: 'block'
});
$(".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-contents_global").css({
display: 'none'
});
}
$(".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'
});
}
function startLiveDataRefreshTimer() {
// live data refresh
helper.timeout.add('data_refresh', function () { update_live_status(); }, 100);
}
function update_live_status() {
var statuswrapper = $('#quad-status_wrapper');
if (!CONFIGURATOR.connectionValid) {
return;
}
$(".quad-status-contents").css({
display: 'inline-block'
@ -570,9 +568,7 @@ function update_live_status() {
$(".battery-legend").text(ANALOG.voltage + " V");
}
statuswrapper.show();
helper.timeout.remove('data_refresh');
startLiveDataRefreshTimer();
$('#quad-status_wrapper').show();
}
function specificByte(num, pos) {

View file

@ -87,7 +87,7 @@ TABS.logging.initialize = function (callback) {
GUI.log(chrome.i18n.getMessage('loggingErrorOneProperty'));
}
} else {
helper.interval.killAll();
helper.interval.killAll(['global_data_refresh']);
$('.speed').prop('disabled', false);
$(this).text(chrome.i18n.getMessage('loggingStart'));

View file

@ -235,7 +235,7 @@ TABS.motors.initialize = function (callback) {
accelHelpers = initGraphHelpers('#accel', samples_accel_i, [-scale, scale]);
// 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() {
MSP.send_message(MSPCodes.MSP_RAW_IMU, false, false, update_accel_graph);

View file

@ -356,7 +356,7 @@ TABS.sensors.initialize = function (callback) {
});
// timer initialization
helper.interval.killAll(['status_pull']);
helper.interval.killAll(['status_pull', 'global_data_refresh']);
// data pulling timers
if (checkboxes[0] || checkboxes[1] || checkboxes[2]) {