From 6e52d3700dda2466cb0779a234b0be22670f2d7d Mon Sep 17 00:00:00 2001 From: cTn Date: Wed, 25 Jun 2014 13:06:55 +0200 Subject: [PATCH] save accel settings separately in motors tab --- tabs/motor_outputs.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tabs/motor_outputs.js b/tabs/motor_outputs.js index c3bf1058..d751a23f 100644 --- a/tabs/motor_outputs.js +++ b/tabs/motor_outputs.js @@ -158,10 +158,27 @@ function tab_initialize_motor_outputs() { } }); + // set refresh speeds according to configuration saved in storage + chrome.storage.local.get('motors_tab_accel_settings', function(result) { + if (result.motors_tab_accel_settings) { + $('.tab-motor_outputs select[name="accel_refresh_rate"]').val(result.motors_tab_accel_settings.rate); + $('.tab-motor_outputs select[name="accel_scale"]').val(result.motors_tab_accel_settings.scale); + + // start polling data by triggering refresh rate change event + $('.tab-motor_outputs .rate select:first').change(); + } else { + // start polling immediatly (as there is no configuration saved in the storage) + $('.tab-motor_outputs .rate select:first').change(); + } + }); + $('.tab-motor_outputs .rate select, .tab-motor_outputs .scale select').change(function() { var rate = parseInt($('.tab-motor_outputs select[name="accel_refresh_rate"]').val(), 10); var scale = parseFloat($('.tab-motor_outputs select[name="accel_scale"]').val()); + // store current/latest refresh rates in the storage + chrome.storage.local.set({'motors_tab_accel_settings': {'rate': rate, 'scale': scale}}); + accelHelpers = initGraphHelpers('#accel', samples_accel_i, [-scale, scale]); // timer initialization @@ -182,10 +199,6 @@ function tab_initialize_motor_outputs() { } }); - // fire change event to start accel plot - $('.tab-motor_outputs .rate select:first').change(); - - // if CAP_DYNBALANCE is true if (bit_check(CONFIG.capability, 2)) { $('div.motor_testing').show();