diff --git a/js/serial_queue.js b/js/serial_queue.js index c6f2b315..188c9498 100644 --- a/js/serial_queue.js +++ b/js/serial_queue.js @@ -11,8 +11,8 @@ helper.mspQueue = (function (serial, MSP) { privateScope.balancerFrequency = 10; privateScope.loadFilter = new classes.SimpleSmoothFilter(0.5, 0.995); - privateScope.roundtripFilter = new classes.SimpleSmoothFilter(20, 0.95); - privateScope.hardwareRoundtripFilter = new classes.SimpleSmoothFilter(5, 0.95); + privateScope.roundtripFilter = new classes.SimpleSmoothFilter(20, 0.97); + privateScope.hardwareRoundtripFilter = new classes.SimpleSmoothFilter(5, 0.97); /** * Target load for MSP queue. When load is above target, throttling might start to appear @@ -255,13 +255,13 @@ helper.mspQueue = (function (serial, MSP) { * @returns {number} */ publicScope.getIntervalPrediction = function (requestedInterval, messagesInInterval) { - var openWindow = publicScope.getRoundtrip() * 1.25, - requestedWindow = requestedInterval / messagesInInterval; + var requestedRate = (1000 / requestedInterval) * messagesInInterval, + availableRate = (1000 / publicScope.getRoundtrip()) * 0.75; - if (requestedWindow < openWindow) { - return openWindow; - } else { + if (requestedRate < availableRate) { return requestedInterval; + } else { + return (1000 / availableRate) * messagesInInterval; } }; diff --git a/tabs/adjustments.js b/tabs/adjustments.js index 84cfd680..04a2de8d 100644 --- a/tabs/adjustments.js +++ b/tabs/adjustments.js @@ -254,6 +254,11 @@ TABS.adjustments.initialize = function (callback) { // data pulling functions used inside interval timer function get_rc_data() { + + if (helper.mspQueue.shouldDrop()) { + return; + } + MSP.send_message(MSPCodes.MSP_RC, false, false, update_ui); } @@ -269,7 +274,7 @@ TABS.adjustments.initialize = function (callback) { update_ui(); // enable data pulling - helper.interval.add('aux_data_pull', get_rc_data, 50); + helper.interval.add('aux_data_pull', get_rc_data, helper.mspQueue.getIntervalPrediction(50, 1)); GUI.content_ready(callback); } diff --git a/tabs/auxiliary.js b/tabs/auxiliary.js index f03c1034..49f18dcc 100644 --- a/tabs/auxiliary.js +++ b/tabs/auxiliary.js @@ -258,6 +258,11 @@ TABS.auxiliary.initialize = function (callback) { // data pulling functions used inside interval timer function get_rc_data() { + + if (helper.mspQueue.shouldDrop()) { + return; + } + MSP.send_message(MSPCodes.MSP_RC, false, false, update_ui); } @@ -288,7 +293,7 @@ TABS.auxiliary.initialize = function (callback) { update_ui(); // enable data pulling - helper.interval.add('aux_data_pull', get_rc_data, 50); + helper.interval.add('aux_data_pull', get_rc_data, helper.mspQueue.getIntervalPrediction(50, 1)); GUI.content_ready(callback); } diff --git a/tabs/gps.js b/tabs/gps.js index 47f77887..80761dc1 100644 --- a/tabs/gps.js +++ b/tabs/gps.js @@ -2,7 +2,6 @@ TABS.gps = {}; TABS.gps.initialize = function (callback) { - var self = this; if (GUI.active_tab != 'gps') { GUI.active_tab = 'gps'; @@ -115,7 +114,7 @@ TABS.gps.initialize = function (callback) { } get_raw_gps_data(); - }, 250, true); + }, helper.mspQueue.getIntervalPrediction(200, 3), true); //check for internet connection on load if (navigator.onLine) { @@ -159,8 +158,6 @@ TABS.gps.initialize = function (callback) { }; - - TABS.gps.cleanup = function (callback) { if (callback) callback(); }; \ No newline at end of file