1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-24 00:35:26 +03:00

add an alternative to chrome.storage.local

This commit is contained in:
Kyle K 2019-08-02 06:13:39 +00:00
parent 5eedc3b507
commit 426e753b53
11 changed files with 141 additions and 99 deletions

View file

@ -260,26 +260,6 @@ TABS.motors.initialize = function (callback) {
}
});
// set refresh speeds according to configuration saved in storage
chrome.storage.local.get(['motors_tab_sensor_settings', 'motors_tab_gyro_settings', 'motors_tab_accel_settings'], function (result) {
if (result.motors_tab_sensor_settings) {
var sensor = result.motors_tab_sensor_settings.sensor;
$('.tab-motors select[name="sensor_choice"]').val(result.motors_tab_sensor_settings.sensor);
}
if (result.motors_tab_gyro_settings) {
TABS.motors.sensorGyroRate = result.motors_tab_gyro_settings.rate;
TABS.motors.sensorGyroScale = result.motors_tab_gyro_settings.scale;
}
if (result.motors_tab_accel_settings) {
TABS.motors.sensorAccelRate = result.motors_tab_accel_settings.rate;
TABS.motors.sensorAccelScale = result.motors_tab_accel_settings.scale;
}
$('.tab-motors .sensor select:first').change();
});
function loadScaleSelector(selectorValues, selectedValue) {
$('.tab-motors select[name="scale"]').find('option').remove();
@ -296,7 +276,7 @@ TABS.motors.initialize = function (callback) {
$('.tab-motors .sensor select').change(function(){
TABS.motors.sensor = $('.tab-motors select[name="sensor_choice"]').val()
chrome.storage.local.set({'motors_tab_sensor_settings': {'sensor': TABS.motors.sensor}});
ConfigStorage.set({'motors_tab_sensor_settings': {'sensor': TABS.motors.sensor}});
switch(TABS.motors.sensor){
case "gyro":
@ -314,7 +294,6 @@ TABS.motors.initialize = function (callback) {
$('.tab-motors .rate select:first').change();
});
$('.tab-motors .rate select, .tab-motors .scale select').change(function () {
var rate = parseInt($('.tab-motors select[name="rate"]').val(), 10);
var scale = parseFloat($('.tab-motors select[name="scale"]').val());
@ -323,7 +302,7 @@ TABS.motors.initialize = function (callback) {
switch(TABS.motors.sensor) {
case "gyro":
chrome.storage.local.set({'motors_tab_gyro_settings': {'rate': rate, 'scale': scale}});
ConfigStorage.set({'motors_tab_gyro_settings': {'rate': rate, 'scale': scale}});
TABS.motors.sensorGyroRate = rate;
TABS.motors.sensorGyroScale = scale;
@ -334,7 +313,7 @@ TABS.motors.initialize = function (callback) {
}, rate, true);
break;
case "accel":
chrome.storage.local.set({'motors_tab_accel_settings': {'rate': rate, 'scale': scale}});
ConfigStorage.set({'motors_tab_accel_settings': {'rate': rate, 'scale': scale}});
TABS.motors.sensorAccelRate = rate;
TABS.motors.sensorAccelScale = scale;
accel_helpers = initGraphHelpers('#graph', samples_accel_i, [-scale, scale]);
@ -402,6 +381,27 @@ TABS.motors.initialize = function (callback) {
}
});
// set refresh speeds according to configuration saved in storage
ConfigStorage.get(['motors_tab_sensor_settings', 'motors_tab_gyro_settings', 'motors_tab_accel_settings'], function (result) {
if (result.motors_tab_sensor_settings) {
var sensor = result.motors_tab_sensor_settings.sensor;
$('.tab-motors select[name="sensor_choice"]').val(result.motors_tab_sensor_settings.sensor);
}
if (result.motors_tab_gyro_settings) {
TABS.motors.sensorGyroRate = result.motors_tab_gyro_settings.rate;
TABS.motors.sensorGyroScale = result.motors_tab_gyro_settings.scale;
}
if (result.motors_tab_accel_settings) {
TABS.motors.sensorAccelRate = result.motors_tab_accel_settings.rate;
TABS.motors.sensorAccelScale = result.motors_tab_accel_settings.scale;
}
$('.tab-motors .sensor select:first').change();
});
// Amperage
function power_data_pull() {
motor_voltage_e.text(i18n.getMessage('motorsVoltageValue', [ANALOG.voltage]));