1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-14 20:10:11 +03:00

tab tasks unified

This commit is contained in:
Pawel Spychalski (DzikuVx) 2017-01-18 16:50:35 +01:00
parent d1fcb81017
commit d1483e5e26
18 changed files with 46 additions and 99 deletions

View file

@ -53,6 +53,7 @@ var mspHelper = (function (gui) {
CONFIG.capability = data.getUint32(3, true); CONFIG.capability = data.getUint32(3, true);
break; break;
case MSPCodes.MSP_STATUS: case MSPCodes.MSP_STATUS:
console.log('Using deprecated msp command: MSP_STATUS');
CONFIG.cycleTime = data.getUint16(0, true); CONFIG.cycleTime = data.getUint16(0, true);
CONFIG.i2cError = data.getUint16(2, true); CONFIG.i2cError = data.getUint16(2, true);
CONFIG.activeSensors = data.getUint16(4, true); CONFIG.activeSensors = data.getUint16(4, true);
@ -86,6 +87,7 @@ var mspHelper = (function (gui) {
sensor_status(CONFIG.activeSensors); sensor_status(CONFIG.activeSensors);
} }
gui.updateStatusBar(); gui.updateStatusBar();
gui.updateProfileChange();
break; break;
case MSPCodes.MSP_SENSOR_STATUS: case MSPCodes.MSP_SENSOR_STATUS:

View file

@ -499,6 +499,7 @@ function update_live_status() {
display: 'inline-block' display: 'inline-block'
}); });
//FIXME probably this is a duplication on status polling... one of those is probably very very not needed
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.flightControllerVersion, "1.2.0")) if (semver.gte(CONFIG.flightControllerVersion, "1.2.0"))

27
js/tasks.js Normal file
View file

@ -0,0 +1,27 @@
'use strict';
var helper = helper || {};
helper.task = (function () {
var publicScope = {},
privateScope = {};
privateScope.getStatusPullInterval = function () {
//TODO use serial connection speed to determine update interval
return 250;
};
publicScope.statusPullStart = function () {
helper.interval.add('status_pull', function () {
MSP.send_message(MSPCodes.MSP_STATUS, false, false, function () {
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
}
});
}, privateScope.getStatusPullInterval(), true);
};
return publicScope;
})();

View file

@ -69,6 +69,7 @@
<script type="text/javascript" src="./js/protocols/stm32usbdfu.js"></script> <script type="text/javascript" src="./js/protocols/stm32usbdfu.js"></script>
<script type="text/javascript" src="./js/localization.js"></script> <script type="text/javascript" src="./js/localization.js"></script>
<script type="text/javascript" src="./js/boards.js"></script> <script type="text/javascript" src="./js/boards.js"></script>
<script type="text/javascript" src="./js/tasks.js"></script>
<script type="text/javascript" src="./main.js"></script> <script type="text/javascript" src="./main.js"></script>
<script type="text/javascript" src="./tabs/landing.js"></script> <script type="text/javascript" src="./tabs/landing.js"></script>
<script type="text/javascript" src="./tabs/setup.js"></script> <script type="text/javascript" src="./tabs/setup.js"></script>

View file

@ -271,14 +271,7 @@ TABS.adjustments.initialize = function (callback) {
// enable data pulling // enable data pulling
helper.interval.add('aux_data_pull', get_rc_data, 50); helper.interval.add('aux_data_pull', get_rc_data, 50);
// status data pulled via separate timer with static speed helper.task.statusPullStart();
helper.interval.add('status_pull', function () {
MSP.send_message(MSPCodes.MSP_STATUS);
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
}
}, 250, true);
GUI.content_ready(callback); GUI.content_ready(callback);
} }

View file

@ -290,14 +290,7 @@ TABS.auxiliary.initialize = function (callback) {
// enable data pulling // enable data pulling
helper.interval.add('aux_data_pull', get_rc_data, 50); helper.interval.add('aux_data_pull', get_rc_data, 50);
// status data pulled via separate timer with static speed helper.task.statusPullStart();
helper.interval.add('status_pull', function () {
MSP.send_message(MSPCodes.MSP_STATUS);
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
}
}, 250, true);
GUI.content_ready(callback); GUI.content_ready(callback);
} }

View file

@ -633,13 +633,8 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}); });
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
helper.interval.add('status_pull', function status_pull() { helper.task.statusPullStart();
MSP.send_message(MSPCodes.MSP_STATUS);
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
}
}, 250, true);
helper.interval.add('config_load_analog', function () { helper.interval.add('config_load_analog', function () {
MSP.send_message(MSPCodes.MSP_ANALOG, false, false, function () { MSP.send_message(MSPCodes.MSP_ANALOG, false, false, function () {
$('#batteryvoltage').val([ANALOG.voltage.toFixed(1)]); $('#batteryvoltage').val([ANALOG.voltage.toFixed(1)]);

View file

@ -358,14 +358,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
} }
}); });
// status data pulled via separate timer with static speed helper.task.statusPullStart();
helper.interval.add('status_pull', function status_pull() {
MSP.send_message(MSPCodes.MSP_STATUS);
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
}
}, 250, true);
GUI.content_ready(callback); GUI.content_ready(callback);
} }

View file

@ -111,15 +111,7 @@ TABS.gps.initialize = function (callback) {
get_raw_gps_data(); get_raw_gps_data();
}, 75, true); }, 75, true);
// status data pulled via separate timer with static speed helper.task.statusPullStart();
helper.interval.add('status_pull', function status_pull() {
MSP.send_message(MSPCodes.MSP_STATUS);
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
}
}, 250, true);
//check for internet connection on load //check for internet connection on load
if (navigator.onLine) { if (navigator.onLine) {

View file

@ -144,14 +144,7 @@ TABS.modes.initialize = function (callback) {
// enable data pulling // enable data pulling
helper.interval.add('aux_data_pull', get_rc_data, 50); helper.interval.add('aux_data_pull', get_rc_data, 50);
// status data pulled via separate timer with static speed helper.task.statusPullStart();
helper.interval.add('status_pull', function status_pull() {
MSP.send_message(MSPCodes.MSP_STATUS);
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
}
}, 250, true);
GUI.content_ready(callback); GUI.content_ready(callback);
} }

View file

@ -289,10 +289,7 @@ TABS.pid_tuning.initialize = function (callback) {
send_pids(); send_pids();
}); });
// status data pulled via separate timer with static speed helper.task.statusPullStart();
helper.interval.add('status_pull', function status_pull() {
MSP.send_message(MSPCodes.MSP_STATUS);
}, 250, true);
GUI.content_ready(callback); GUI.content_ready(callback);
} }

View file

@ -221,14 +221,7 @@ TABS.ports.initialize = function (callback, scrollPosition) {
$('a.save').click(on_save_handler); $('a.save').click(on_save_handler);
// status data pulled via separate timer with static speed helper.task.statusPullStart();
helper.interval.add('status_pull', function status_pull() {
MSP.send_message(MSPCodes.MSP_STATUS);
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
}
}, 250, true);
GUI.content_ready(callback); GUI.content_ready(callback);
} }

View file

@ -368,13 +368,7 @@ TABS.profiles.initialize = function (callback, scrollPosition) {
content: $('#presetApplyContent') content: $('#presetApplyContent')
}); });
helper.interval.add('status_pull', function status_pull() { helper.task.statusPullStart();
MSP.send_message(MSPCodes.MSP_STATUS);
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
}
}, 250, true);
GUI.content_ready(callback); GUI.content_ready(callback);
} }
}; };

View file

@ -470,15 +470,7 @@ TABS.receiver.initialize = function (callback) {
helper.interval.add('receiver_pull', get_rc_data, plot_update_rate, true); helper.interval.add('receiver_pull', get_rc_data, plot_update_rate, true);
}); });
// status data pulled via separate timer with static speed helper.task.statusPullStart();
helper.interval.add('status_pull', function status_pull() {
MSP.send_message(MSPCodes.MSP_STATUS);
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
}
}, 250, true);
GUI.content_ready(callback); GUI.content_ready(callback);
} }
}; };

View file

@ -443,14 +443,7 @@ TABS.sensors.initialize = function (callback) {
} }
}); });
// status data pulled via separate timer with static speed helper.task.statusPullStart();
helper.interval.add('status_pull', function status_pull() {
MSP.send_message(MSPCodes.MSP_STATUS);
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
}
}, 250, true);
GUI.content_ready(callback); GUI.content_ready(callback);
}); });

View file

@ -188,14 +188,7 @@ TABS.servos.initialize = function (callback) {
// translate to user-selected language // translate to user-selected language
localize(); localize();
// status data pulled via separate timer with static speed helper.task.statusPullStart();
helper.interval.add('status_pull', function () {
MSP.send_message(MSPCodes.MSP_STATUS);
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
}
}, 250, true);
GUI.content_ready(callback); GUI.content_ready(callback);
} }

View file

@ -175,6 +175,7 @@ TABS.setup.initialize = function (callback) {
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS); MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
} }
//TODO ah man.... compare with update_live_status from serial_backend.js
MSP.send_message(MSPCodes.MSP_ANALOG, false, false, function () { MSP.send_message(MSPCodes.MSP_ANALOG, false, false, function () {
bat_voltage_e.text(chrome.i18n.getMessage('initialSetupBatteryValue', [ANALOG.voltage])); bat_voltage_e.text(chrome.i18n.getMessage('initialSetupBatteryValue', [ANALOG.voltage]));
bat_mah_drawn_e.text(chrome.i18n.getMessage('initialSetupBatteryMahValue', [ANALOG.mAhdrawn])); bat_mah_drawn_e.text(chrome.i18n.getMessage('initialSetupBatteryMahValue', [ANALOG.mAhdrawn]));

View file

@ -91,14 +91,8 @@ TABS.transponder.initialize = function (callback, scrollPosition) {
save_transponder_config(); save_transponder_config();
}); });
} }
// status data pulled via separate timer with static speed
helper.interval.add('status_pull', function status_pull() {
MSP.send_message(MSPCodes.MSP_STATUS);
if (semver.gte(CONFIG.flightControllerVersion, "1.5.0")) { helper.task.statusPullStart();
MSP.send_message(MSPCodes.MSP_SENSOR_STATUS);
}
}, 250, true);
GUI.content_ready(callback); GUI.content_ready(callback);
} }