1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 22:35:23 +03:00

pretty pretty pretty

This commit is contained in:
cTn 2014-08-12 16:20:26 +02:00 committed by Dominic Clifton
parent 118715ef85
commit 36c4fef051
6 changed files with 128 additions and 128 deletions

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
TABS.logging = {}; TABS.logging = {};
TABS.logging.initialize = function(callback) { TABS.logging.initialize = function (callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'logging'; GUI.active_tab = 'logging';
googleAnalytics.sendAppView('Logging'); googleAnalytics.sendAppView('Logging');
@ -41,7 +41,7 @@ TABS.logging.initialize = function(callback) {
// UI hooks // UI hooks
$('a.log_file').click(prepare_file); $('a.log_file').click(prepare_file);
$('a.logging').click(function() { $('a.logging').click(function () {
if (GUI.connected_to) { if (GUI.connected_to) {
if (fileEntry != null) { if (fileEntry != null) {
var clicks = $(this).data('clicks'); var clicks = $(this).data('clicks');
@ -53,7 +53,7 @@ TABS.logging.initialize = function(callback) {
log_buffer = []; log_buffer = [];
requested_properties = []; requested_properties = [];
$('.properties input:checked').each(function() { $('.properties input:checked').each(function () {
requested_properties.push($(this).prop('name')); requested_properties.push($(this).prop('name'));
}); });
@ -118,7 +118,7 @@ TABS.logging.initialize = function(callback) {
if (GUI.connected_to) { if (GUI.connected_to) {
$('a.connect').click(); $('a.connect').click();
} else { } else {
GUI.tab_switch_cleanup(function() { GUI.tab_switch_cleanup(function () {
CONFIGURATOR.mspPassThrough = false; CONFIGURATOR.mspPassThrough = false;
$('#tabs > ul li').removeClass('active'); $('#tabs > ul li').removeClass('active');
TABS.default.initialize(); TABS.default.initialize();
@ -127,9 +127,9 @@ TABS.logging.initialize = function(callback) {
}); });
} }
chrome.storage.local.get('logging_file_entry', function(result) { chrome.storage.local.get('logging_file_entry', function (result) {
if (result.logging_file_entry) { if (result.logging_file_entry) {
chrome.fileSystem.restoreEntry(result.logging_file_entry, function(entry) { chrome.fileSystem.restoreEntry(result.logging_file_entry, function (entry) {
fileEntry = entry; fileEntry = entry;
prepare_writer(true); prepare_writer(true);
}); });
@ -201,9 +201,10 @@ TABS.logging.initialize = function(callback) {
append_to_file(head); append_to_file(head);
} }
var samples = 0; var samples = 0,
var requests = 0; requests = 0,
var log_buffer = []; log_buffer = [];
function crunch_data() { function crunch_data() {
var sample = millitime(); var sample = millitime();
@ -255,8 +256,8 @@ TABS.logging.initialize = function(callback) {
} }
// IO related methods // IO related methods
var fileEntry = null; var fileEntry = null,
var fileWriter = null; fileWriter = null;
function prepare_file() { function prepare_file() {
// create or load the file // create or load the file
@ -296,29 +297,29 @@ TABS.logging.initialize = function(callback) {
} }
function prepare_writer(retaining) { function prepare_writer(retaining) {
fileEntry.createWriter(function(writer) { fileEntry.createWriter(function (writer) {
fileWriter = writer; fileWriter = writer;
fileWriter.onerror = function(e) { fileWriter.onerror = function (e) {
console.error(e); console.error(e);
// stop logging if the procedure was/is still running // stop logging if the procedure was/is still running
if ($('a.logging').data('clicks')) $('a.logging').click(); if ($('a.logging').data('clicks')) $('a.logging').click();
}; };
fileWriter.onwriteend = function() { fileWriter.onwriteend = function () {
$('.size').text(bytesToSize(fileWriter.length)); $('.size').text(bytesToSize(fileWriter.length));
}; };
if (retaining) { if (retaining) {
chrome.fileSystem.getDisplayPath(fileEntry, function(path) { chrome.fileSystem.getDisplayPath(fileEntry, function (path) {
GUI.log(chrome.i18n.getMessage('loggingAutomaticallyRetained', [path])); GUI.log(chrome.i18n.getMessage('loggingAutomaticallyRetained', [path]));
}); });
} }
// update log size in UI on fileWriter creation // update log size in UI on fileWriter creation
$('.size').text(bytesToSize(fileWriter.length)); $('.size').text(bytesToSize(fileWriter.length));
}, function(e) { }, function (e) {
// File is not readable or does not exist! // File is not readable or does not exist!
console.error(e); console.error(e);
@ -337,6 +338,6 @@ TABS.logging.initialize = function(callback) {
} }
}; };
TABS.logging.cleanup = function(callback) { TABS.logging.cleanup = function (callback) {
if (callback) callback(); if (callback) callback();
}; };

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
TABS.motor_outputs = {}; TABS.motor_outputs = {};
TABS.motor_outputs.initialize = function(callback) { TABS.motor_outputs.initialize = function (callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'motor_outputs'; GUI.active_tab = 'motor_outputs';
googleAnalytics.sendAppView('Motor Outputs Page'); googleAnalytics.sendAppView('Motor Outputs Page');
@ -85,17 +85,17 @@ TABS.motor_outputs.initialize = function(callback) {
.scale(helpers.widthScale) .scale(helpers.widthScale)
.ticks(5) .ticks(5)
.orient("bottom") .orient("bottom")
.tickFormat(function(d) {return d;}); .tickFormat(function (d) {return d;});
helpers.yAxis = d3.svg.axis() helpers.yAxis = d3.svg.axis()
.scale(helpers.heightScale) .scale(helpers.heightScale)
.ticks(5) .ticks(5)
.orient("left") .orient("left")
.tickFormat(function(d) {return d;}); .tickFormat(function (d) {return d;});
helpers.line = d3.svg.line() helpers.line = d3.svg.line()
.x(function(d) { return helpers.widthScale(d[0]); }) .x(function (d) { return helpers.widthScale(d[0]); })
.y(function(d) { return helpers.heightScale(d[1]); }); .y(function (d) { return helpers.heightScale(d[1]); });
return helpers; return helpers;
} }
@ -105,7 +105,7 @@ TABS.motor_outputs.initialize = function(callback) {
if (graphHelpers.dynamicHeightDomain) { if (graphHelpers.dynamicHeightDomain) {
var limits = []; var limits = [];
$.each(data, function(idx, datum) { $.each(data, function (idx, datum) {
limits.push(datum.min); limits.push(datum.min);
limits.push(datum.max); limits.push(datum.max);
}); });
@ -119,7 +119,7 @@ TABS.motor_outputs.initialize = function(callback) {
svg.select(".y.axis").call(graphHelpers.yAxis); svg.select(".y.axis").call(graphHelpers.yAxis);
var group = svg.select("g.data"); var group = svg.select("g.data");
var lines = group.selectAll("path").data(data, function(d, i) { return i; }); var lines = group.selectAll("path").data(data, function (d, i) {return i;});
var newLines = lines.enter().append("path").attr("class", "line"); var newLines = lines.enter().append("path").attr("class", "line");
lines.attr('d', graphHelpers.line); lines.attr('d', graphHelpers.line);
} }
@ -154,7 +154,7 @@ TABS.motor_outputs.initialize = function(callback) {
y: [], y: [],
z: [], z: [],
}; };
$('.plot_control .x, .plot_control .y, .plot_control .z').each(function() { $('.plot_control .x, .plot_control .y, .plot_control .z').each(function () {
var el = $(this); var el = $(this);
if (el.hasClass('x')) { if (el.hasClass('x')) {
raw_data_text_ements.x.push(el); raw_data_text_ements.x.push(el);
@ -166,7 +166,7 @@ TABS.motor_outputs.initialize = function(callback) {
}); });
// set refresh speeds according to configuration saved in storage // set refresh speeds according to configuration saved in storage
chrome.storage.local.get('motors_tab_accel_settings', function(result) { chrome.storage.local.get('motors_tab_accel_settings', function (result) {
if (result.motors_tab_accel_settings) { 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_refresh_rate"]').val(result.motors_tab_accel_settings.rate);
$('.tab-motor_outputs select[name="accel_scale"]').val(result.motors_tab_accel_settings.scale); $('.tab-motor_outputs select[name="accel_scale"]').val(result.motors_tab_accel_settings.scale);
@ -179,7 +179,7 @@ TABS.motor_outputs.initialize = function(callback) {
} }
}); });
$('.tab-motor_outputs .rate select, .tab-motor_outputs .scale select').change(function() { $('.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 rate = parseInt($('.tab-motor_outputs select[name="accel_refresh_rate"]').val(), 10);
var scale = parseFloat($('.tab-motor_outputs select[name="accel_scale"]').val()); var scale = parseFloat($('.tab-motor_outputs select[name="accel_scale"]').val());
@ -224,7 +224,7 @@ TABS.motor_outputs.initialize = function(callback) {
} }
}); });
$('a.reset_accel_max').click(function() { $('a.reset_accel_max').click(function () {
accel_max_read = [0, 0, 0]; accel_max_read = [0, 0, 0];
accel_offset_established = false; accel_offset_established = false;
}); });
@ -246,7 +246,7 @@ TABS.motor_outputs.initialize = function(callback) {
$('div.values li:not(:last)').html(MISC.mincommand); $('div.values li:not(:last)').html(MISC.mincommand);
// UI hooks // UI hooks
$('div.sliders input:not(.master)').on('input', function() { $('div.sliders input:not(.master)').on('input', function () {
var index = $(this).index(); var index = $(this).index();
$('div.values li').eq(index).html($(this).val()); $('div.values li').eq(index).html($(this).val());
@ -264,7 +264,7 @@ TABS.motor_outputs.initialize = function(callback) {
MSP.send_message(MSP_codes.MSP_SET_MOTOR, buffer_out); MSP.send_message(MSP_codes.MSP_SET_MOTOR, buffer_out);
}); });
$('div.sliders input.master').on('input', function() { $('div.sliders input.master').on('input', function () {
var val = $(this).val(); var val = $(this).val();
$('div.sliders input:not(:disabled, :last)').val(val); $('div.sliders input:not(:disabled, :last)').val(val);
@ -272,7 +272,7 @@ TABS.motor_outputs.initialize = function(callback) {
$('div.sliders input:not(:last):first').trigger('input'); $('div.sliders input:not(:last):first').trigger('input');
}); });
$('div.notice input[type="checkbox"]').change(function() { $('div.notice input[type="checkbox"]').change(function () {
if ($(this).is(':checked')) { if ($(this).is(':checked')) {
$('div.sliders input').slice(0, number_of_valid_outputs).prop('disabled', false); $('div.sliders input').slice(0, number_of_valid_outputs).prop('disabled', false);
@ -373,6 +373,6 @@ TABS.motor_outputs.initialize = function(callback) {
} }
}; };
TABS.motor_outputs.cleanup = function(callback) { TABS.motor_outputs.cleanup = function (callback) {
if (callback) callback(); if (callback) callback();
}; };

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
TABS.pid_tuning = {}; TABS.pid_tuning = {};
TABS.pid_tuning.initialize = function(callback) { TABS.pid_tuning.initialize = function (callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'pid_tuning'; GUI.active_tab = 'pid_tuning';
googleAnalytics.sendAppView('PID Tuning'); googleAnalytics.sendAppView('PID Tuning');
@ -44,7 +44,7 @@ TABS.pid_tuning.initialize = function(callback) {
// Fill in the data from PIDs array // Fill in the data from PIDs array
var i = 0; var i = 0;
$('.pid_tuning .ROLL input').each(function() { $('.pid_tuning .ROLL input').each(function () {
switch (i) { switch (i) {
case 0: case 0:
$(this).val(PIDs[0][i++].toFixed(1)); $(this).val(PIDs[0][i++].toFixed(1));
@ -59,7 +59,7 @@ TABS.pid_tuning.initialize = function(callback) {
}); });
i = 0; i = 0;
$('.pid_tuning .PITCH input').each(function() { $('.pid_tuning .PITCH input').each(function () {
switch (i) { switch (i) {
case 0: case 0:
$(this).val(PIDs[1][i++].toFixed(1)); $(this).val(PIDs[1][i++].toFixed(1));
@ -74,7 +74,7 @@ TABS.pid_tuning.initialize = function(callback) {
}); });
i = 0; i = 0;
$('.pid_tuning .YAW input').each(function() { $('.pid_tuning .YAW input').each(function () {
switch (i) { switch (i) {
case 0: case 0:
$(this).val(PIDs[2][i++].toFixed(1)); $(this).val(PIDs[2][i++].toFixed(1));
@ -89,7 +89,7 @@ TABS.pid_tuning.initialize = function(callback) {
}); });
i = 0; i = 0;
$('.pid_tuning .ALT input').each(function() { $('.pid_tuning .ALT input').each(function () {
switch (i) { switch (i) {
case 0: case 0:
$(this).val(PIDs[3][i++].toFixed(1)); $(this).val(PIDs[3][i++].toFixed(1));
@ -104,12 +104,12 @@ TABS.pid_tuning.initialize = function(callback) {
}); });
i = 0; i = 0;
$('.pid_tuning .Pos input').each(function() { $('.pid_tuning .Pos input').each(function () {
$(this).val(PIDs[4][i++].toFixed(2)); $(this).val(PIDs[4][i++].toFixed(2));
}); });
i = 0; i = 0;
$('.pid_tuning .PosR input').each(function() { $('.pid_tuning .PosR input').each(function () {
switch (i) { switch (i) {
case 0: case 0:
$(this).val(PIDs[5][i++].toFixed(1)); $(this).val(PIDs[5][i++].toFixed(1));
@ -124,7 +124,7 @@ TABS.pid_tuning.initialize = function(callback) {
}); });
i = 0; i = 0;
$('.pid_tuning .NavR input').each(function() { $('.pid_tuning .NavR input').each(function () {
switch (i) { switch (i) {
case 0: case 0:
$(this).val(PIDs[6][i++].toFixed(1)); $(this).val(PIDs[6][i++].toFixed(1));
@ -139,7 +139,7 @@ TABS.pid_tuning.initialize = function(callback) {
}); });
i = 0; i = 0;
$('.pid_tuning .LEVEL input').each(function() { $('.pid_tuning .LEVEL input').each(function () {
switch (i) { switch (i) {
case 0: case 0:
$(this).val(PIDs[7][i++].toFixed(1)); $(this).val(PIDs[7][i++].toFixed(1));
@ -154,12 +154,12 @@ TABS.pid_tuning.initialize = function(callback) {
}); });
i = 0; i = 0;
$('.pid_tuning .MAG input').each(function() { $('.pid_tuning .MAG input').each(function () {
$(this).val(PIDs[8][i++].toFixed(1)); $(this).val(PIDs[8][i++].toFixed(1));
}); });
i = 0; i = 0;
$('.pid_tuning .Vario input').each(function() { $('.pid_tuning .Vario input').each(function () {
switch (i) { switch (i) {
case 0: case 0:
$(this).val(PIDs[9][i++].toFixed(1)); $(this).val(PIDs[9][i++].toFixed(1));
@ -182,74 +182,74 @@ TABS.pid_tuning.initialize = function(callback) {
$('input[name="profile"]').val(CONFIG.profile + 1); // +1 because the range is 0-2 $('input[name="profile"]').val(CONFIG.profile + 1); // +1 because the range is 0-2
// UI Hooks // UI Hooks
$('input[name="profile"]').change(function() { $('input[name="profile"]').change(function () {
var profile = parseInt($(this).val()); var profile = parseInt($(this).val());
MSP.send_message(MSP_codes.MSP_SELECT_SETTING, [profile - 1], false, function() { MSP.send_message(MSP_codes.MSP_SELECT_SETTING, [profile - 1], false, function () {
GUI.log(chrome.i18n.getMessage('pidTuningLoadedProfile', [profile])); GUI.log(chrome.i18n.getMessage('pidTuningLoadedProfile', [profile]));
GUI.tab_switch_cleanup(function() { GUI.tab_switch_cleanup(function () {
TABS.pid_tuning.initialize(); TABS.pid_tuning.initialize();
}); });
}); });
}); });
$('a.refresh').click(function() { $('a.refresh').click(function () {
GUI.tab_switch_cleanup(function() { GUI.tab_switch_cleanup(function () {
GUI.log(chrome.i18n.getMessage('pidTuningDataRefreshed')); GUI.log(chrome.i18n.getMessage('pidTuningDataRefreshed'));
TABS.pid_tuning.initialize(); TABS.pid_tuning.initialize();
}); });
}); });
$('a.update').click(function() { $('a.update').click(function () {
// Catch all the changes and stuff the inside PIDs array // Catch all the changes and stuff the inside PIDs array
var i = 0; var i = 0;
$('table.pid_tuning tr.ROLL input').each(function() { $('table.pid_tuning tr.ROLL input').each(function () {
PIDs[0][i++] = parseFloat($(this).val()); PIDs[0][i++] = parseFloat($(this).val());
}); });
i = 0; i = 0;
$('table.pid_tuning tr.PITCH input').each(function() { $('table.pid_tuning tr.PITCH input').each(function () {
PIDs[1][i++] = parseFloat($(this).val()); PIDs[1][i++] = parseFloat($(this).val());
}); });
i = 0; i = 0;
$('table.pid_tuning tr.YAW input').each(function() { $('table.pid_tuning tr.YAW input').each(function () {
PIDs[2][i++] = parseFloat($(this).val()); PIDs[2][i++] = parseFloat($(this).val());
}); });
i = 0; i = 0;
$('table.pid_tuning tr.ALT input').each(function() { $('table.pid_tuning tr.ALT input').each(function () {
PIDs[3][i++] = parseFloat($(this).val()); PIDs[3][i++] = parseFloat($(this).val());
}); });
i = 0; i = 0;
$('table.pid_tuning tr.Vario input').each(function() { $('table.pid_tuning tr.Vario input').each(function () {
PIDs[9][i++] = parseFloat($(this).val()); PIDs[9][i++] = parseFloat($(this).val());
}); });
i = 0; i = 0;
$('table.pid_tuning tr.Pos input').each(function() { $('table.pid_tuning tr.Pos input').each(function () {
PIDs[4][i++] = parseFloat($(this).val()); PIDs[4][i++] = parseFloat($(this).val());
}); });
i = 0; i = 0;
$('table.pid_tuning tr.PosR input').each(function() { $('table.pid_tuning tr.PosR input').each(function () {
PIDs[5][i++] = parseFloat($(this).val()); PIDs[5][i++] = parseFloat($(this).val());
}); });
i = 0; i = 0;
$('table.pid_tuning tr.NavR input').each(function() { $('table.pid_tuning tr.NavR input').each(function () {
PIDs[6][i++] = parseFloat($(this).val()); PIDs[6][i++] = parseFloat($(this).val());
}); });
i = 0; i = 0;
$('table.pid_tuning tr.LEVEL input').each(function() { $('table.pid_tuning tr.LEVEL input').each(function () {
PIDs[7][i++] = parseFloat($(this).val()); PIDs[7][i++] = parseFloat($(this).val());
}); });
i = 0; i = 0;
$('table.pid_tuning tr.MAG input').each(function() { $('table.pid_tuning tr.MAG input').each(function () {
PIDs[8][i++] = parseFloat($(this).val()); PIDs[8][i++] = parseFloat($(this).val());
}); });
@ -304,14 +304,14 @@ TABS.pid_tuning.initialize = function(callback) {
} }
function save_to_eeprom() { function save_to_eeprom() {
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, function() { MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, function () {
GUI.log(chrome.i18n.getMessage('pidTuningEepromSaved')); GUI.log(chrome.i18n.getMessage('pidTuningEepromSaved'));
}); });
} }
}); });
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function() { GUI.interval_add('status_pull', function () {
MSP.send_message(MSP_codes.MSP_STATUS); MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true); }, 250, true);
@ -319,6 +319,6 @@ TABS.pid_tuning.initialize = function(callback) {
} }
}; };
TABS.pid_tuning.cleanup = function(callback) { TABS.pid_tuning.cleanup = function (callback) {
if (callback) callback(); if (callback) callback();
} }

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
TABS.receiver = {}; TABS.receiver = {};
TABS.receiver.initialize = function(callback) { TABS.receiver.initialize = function (callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'receiver'; GUI.active_tab = 'receiver';
googleAnalytics.sendAppView('Receiver Page'); googleAnalytics.sendAppView('Receiver Page');
@ -27,7 +27,7 @@ TABS.receiver.initialize = function(callback) {
$('.tunings .rate input[name="rate"]').val(RC_tuning.RC_RATE.toFixed(2)); $('.tunings .rate input[name="rate"]').val(RC_tuning.RC_RATE.toFixed(2));
$('.tunings .rate input[name="expo"]').val(RC_tuning.RC_EXPO.toFixed(2)); $('.tunings .rate input[name="expo"]').val(RC_tuning.RC_EXPO.toFixed(2));
chrome.storage.local.get('rx_refresh_rate', function(result) { chrome.storage.local.get('rx_refresh_rate', function (result) {
if (typeof result.rx_refresh_rate != 'undefined') { if (typeof result.rx_refresh_rate != 'undefined') {
$('select[name="rx_refresh_rate"]').val(result.rx_refresh_rate).change(); $('select[name="rx_refresh_rate"]').val(result.rx_refresh_rate).change();
} else { } else {
@ -36,9 +36,9 @@ TABS.receiver.initialize = function(callback) {
}); });
// generate bars // generate bars
var bar_names = ['Roll', 'Pitch', 'Yaw', 'Throttle']; var bar_names = ['Roll', 'Pitch', 'Yaw', 'Throttle'],
var bar_container = $('.tab-receiver .bars'); bar_container = $('.tab-receiver .bars'),
var aux_index = 1; aux_index = 1;
for (var i = 0; i < RC.active_channels; i++) { for (var i = 0; i < RC.active_channels; i++) {
var name; var name;
@ -59,19 +59,19 @@ TABS.receiver.initialize = function(callback) {
} }
var meter_array = []; var meter_array = [];
$('meter', bar_container).each(function() { $('meter', bar_container).each(function () {
meter_array.push($(this)); meter_array.push($(this));
}); });
var meter_values_array = []; var meter_values_array = [];
$('.value', bar_container).each(function() { $('.value', bar_container).each(function () {
meter_values_array.push($(this)); meter_values_array.push($(this));
}); });
// UI Hooks // UI Hooks
// curves // curves
$('.tunings .throttle input').change(function() { $('.tunings .throttle input').change(function () {
setTimeout(function() { setTimeout(function () {
var mid = parseFloat($('.tunings .throttle input[name="mid"]').val()); var mid = parseFloat($('.tunings .throttle input[name="mid"]').val());
var expo = parseFloat($('.tunings .throttle input[name="expo"]').val()); var expo = parseFloat($('.tunings .throttle input[name="expo"]').val());
@ -98,8 +98,8 @@ TABS.receiver.initialize = function(callback) {
}, 0); // race condition, that should always trigger after all events are processed }, 0); // race condition, that should always trigger after all events are processed
}).change(); }).change();
$('.tunings .rate input').change(function() { $('.tunings .rate input').change(function () {
setTimeout(function() { setTimeout(function () {
var rate = parseFloat($('.tunings .rate input[name="rate"]').val()); var rate = parseFloat($('.tunings .rate input[name="rate"]').val());
var expo = parseFloat($('.tunings .rate input[name="expo"]').val()); var expo = parseFloat($('.tunings .rate input[name="expo"]').val());
@ -118,8 +118,8 @@ TABS.receiver.initialize = function(callback) {
}, 0); // race condition, that should always trigger after all events are processed }, 0); // race condition, that should always trigger after all events are processed
}).change(); }).change();
$('a.refresh').click(function() { $('a.refresh').click(function () {
MSP.send_message(MSP_codes.MSP_RC_TUNING, false, false, function() { MSP.send_message(MSP_codes.MSP_RC_TUNING, false, false, function () {
GUI.log(chrome.i18n.getMessage('receiverDataRefreshed')); GUI.log(chrome.i18n.getMessage('receiverDataRefreshed'));
// fill in data from RC_tuning // fill in data from RC_tuning
@ -135,7 +135,7 @@ TABS.receiver.initialize = function(callback) {
}); });
}); });
$('a.update').click(function() { $('a.update').click(function () {
// catch RC_tuning changes // catch RC_tuning changes
RC_tuning.throttle_MID = parseFloat($('.tunings .throttle input[name="mid"]').val()); RC_tuning.throttle_MID = parseFloat($('.tunings .throttle input[name="mid"]').val());
RC_tuning.throttle_EXPO = parseFloat($('.tunings .throttle input[name="expo"]').val()); RC_tuning.throttle_EXPO = parseFloat($('.tunings .throttle input[name="expo"]').val());
@ -156,13 +156,13 @@ TABS.receiver.initialize = function(callback) {
MSP.send_message(MSP_codes.MSP_SET_RC_TUNING, RC_tuning_buffer_out, false, save_to_eeprom); MSP.send_message(MSP_codes.MSP_SET_RC_TUNING, RC_tuning_buffer_out, false, save_to_eeprom);
function save_to_eeprom() { function save_to_eeprom() {
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, function() { MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, function () {
GUI.log(chrome.i18n.getMessage('receiverEepromSaved')); GUI.log(chrome.i18n.getMessage('receiverEepromSaved'));
}); });
} }
}); });
$('select[name="rx_refresh_rate"]').change(function() { $('select[name="rx_refresh_rate"]').change(function () {
var plot_update_rate = parseInt($(this).val(), 10); var plot_update_rate = parseInt($(this).val(), 10);
// save update rate // save update rate
@ -178,12 +178,12 @@ TABS.receiver.initialize = function(callback) {
RX_plot_data[i] = []; RX_plot_data[i] = [];
} }
var samples = 0; var samples = 0,
var svg = d3.select("svg"); svg = d3.select("svg"),
RX_plot_e = $('#RX_plot'),
margin = {top: 20, right: 0, bottom: 10, left: 40},
width, height, widthScale, heightScale;
var RX_plot_e = $('#RX_plot');
var margin = {top: 20, right: 0, bottom: 10, left: 40};
var width, height, widthScale, heightScale;
function update_receiver_plot_size() { function update_receiver_plot_size() {
width = RX_plot_e.width() - margin.left - margin.right; width = RX_plot_e.width() - margin.left - margin.right;
height = RX_plot_e.height() - margin.top - margin.bottom; height = RX_plot_e.height() - margin.top - margin.bottom;
@ -235,25 +235,25 @@ TABS.receiver.initialize = function(callback) {
var xAxis = d3.svg.axis(). var xAxis = d3.svg.axis().
scale(widthScale). scale(widthScale).
orient("bottom"). orient("bottom").
tickFormat(function(d) {return d;}); tickFormat(function (d) {return d;});
var yAxis = d3.svg.axis(). var yAxis = d3.svg.axis().
scale(heightScale). scale(heightScale).
orient("left"). orient("left").
tickFormat(function(d) {return d;}); tickFormat(function (d) {return d;});
var line = d3.svg.line(). var line = d3.svg.line().
x(function(d) {return widthScale(d[0]);}). x(function (d) {return widthScale(d[0]);}).
y(function(d) {return heightScale(d[1]);}); y(function (d) {return heightScale(d[1]);});
svg.select(".x.grid").call(xGrid); svg.select(".x.grid").call(xGrid);
svg.select(".y.grid").call(yGrid); svg.select(".y.grid").call(yGrid);
svg.select(".x.axis").call(xAxis); svg.select(".x.axis").call(xAxis);
svg.select(".y.axis").call(yAxis); svg.select(".y.axis").call(yAxis);
var data = svg.select("g.data"); var data = svg.select("g.data"),
var lines = data.selectAll("path").data(RX_plot_data, function(d, i) { return i; }); lines = data.selectAll("path").data(RX_plot_data, function (d, i) {return i;}),
var newLines = lines.enter().append("path").attr("class", "line"); newLines = lines.enter().append("path").attr("class", "line");
lines.attr('d', line); lines.attr('d', line);
samples++; samples++;
@ -267,7 +267,7 @@ TABS.receiver.initialize = function(callback) {
}); });
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function() { GUI.interval_add('status_pull', function () {
MSP.send_message(MSP_codes.MSP_STATUS); MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true); }, 250, true);
@ -275,6 +275,6 @@ TABS.receiver.initialize = function(callback) {
} }
}; };
TABS.receiver.cleanup = function(callback) { TABS.receiver.cleanup = function (callback) {
if (callback) callback(); if (callback) callback();
}; };

View file

@ -1,7 +1,7 @@
'use strict'; 'use strict';
TABS.sensors = {}; TABS.sensors = {};
TABS.sensors.initialize = function(callback) { TABS.sensors.initialize = function (callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'sensors'; GUI.active_tab = 'sensors';
googleAnalytics.sendAppView('Sensor Page'); googleAnalytics.sendAppView('Sensor Page');
@ -88,17 +88,17 @@ TABS.sensors.initialize = function(callback) {
.scale(helpers.widthScale) .scale(helpers.widthScale)
.ticks(5) .ticks(5)
.orient("bottom") .orient("bottom")
.tickFormat(function(d) {return d;}); .tickFormat(function (d) {return d;});
helpers.yAxis = d3.svg.axis() helpers.yAxis = d3.svg.axis()
.scale(helpers.heightScale) .scale(helpers.heightScale)
.ticks(5) .ticks(5)
.orient("left") .orient("left")
.tickFormat(function(d) {return d;}); .tickFormat(function (d) {return d;});
helpers.line = d3.svg.line() helpers.line = d3.svg.line()
.x(function(d) { return helpers.widthScale(d[0]); }) .x(function (d) {return helpers.widthScale(d[0]);})
.y(function(d) { return helpers.heightScale(d[1]); }); .y(function (d) {return helpers.heightScale(d[1]);});
return helpers; return helpers;
} }
@ -108,7 +108,7 @@ TABS.sensors.initialize = function(callback) {
if (graphHelpers.dynamicHeightDomain) { if (graphHelpers.dynamicHeightDomain) {
var limits = []; var limits = [];
$.each(data, function(idx, datum) { $.each(data, function (idx, datum) {
limits.push(datum.min); limits.push(datum.min);
limits.push(datum.max); limits.push(datum.max);
}); });
@ -122,7 +122,7 @@ TABS.sensors.initialize = function(callback) {
svg.select(".y.axis").call(graphHelpers.yAxis); svg.select(".y.axis").call(graphHelpers.yAxis);
var group = svg.select("g.data"); var group = svg.select("g.data");
var lines = group.selectAll("path").data(data, function(d, i) { return i; }); var lines = group.selectAll("path").data(data, function (d, i) {return i;});
var newLines = lines.enter().append("path").attr("class", "line"); var newLines = lines.enter().append("path").attr("class", "line");
lines.attr('d', graphHelpers.line); lines.attr('d', graphHelpers.line);
} }
@ -180,7 +180,7 @@ TABS.sensors.initialize = function(callback) {
checkboxes.eq(2).prop('disabled', true); checkboxes.eq(2).prop('disabled', true);
} }
$('.tab-sensors .info .checkboxes input').change(function() { $('.tab-sensors .info .checkboxes input').change(function () {
var enable = $(this).prop('checked'); var enable = $(this).prop('checked');
var index = $(this).parent().index(); var index = $(this).parent().index();
@ -203,7 +203,7 @@ TABS.sensors.initialize = function(callback) {
} }
var checkboxes = []; var checkboxes = [];
$('.tab-sensors .info .checkboxes input').each(function() { $('.tab-sensors .info .checkboxes input').each(function () {
checkboxes.push($(this).prop('checked')); checkboxes.push($(this).prop('checked'));
}); });
@ -212,7 +212,7 @@ TABS.sensors.initialize = function(callback) {
chrome.storage.local.set({'graphs_enabled': checkboxes}); chrome.storage.local.set({'graphs_enabled': checkboxes});
}); });
chrome.storage.local.get('graphs_enabled', function(result) { chrome.storage.local.get('graphs_enabled', function (result) {
if (result.graphs_enabled) { if (result.graphs_enabled) {
var checkboxes = $('.tab-sensors .info .checkboxes input'); var checkboxes = $('.tab-sensors .info .checkboxes input');
for (var i = 0; i < result.graphs_enabled.length; i++) { for (var i = 0; i < result.graphs_enabled.length; i++) {
@ -227,17 +227,16 @@ TABS.sensors.initialize = function(callback) {
initSensorData(); initSensorData();
// Setup variables // Setup variables
var samples_gyro_i = 0; var samples_gyro_i = 0,
var samples_accel_i = 0; samples_accel_i = 0,
var samples_mag_i = 0; samples_mag_i = 0,
var samples_baro_i = 0; samples_baro_i = 0,
var samples_debug_i = 0; samples_debug_i = 0,
gyro_data = initDataArray(3),
var gyro_data = initDataArray(3); accel_data = initDataArray(3),
var accel_data = initDataArray(3); mag_data = initDataArray(3),
var mag_data = initDataArray(3); baro_data = initDataArray(1),
var baro_data = initDataArray(1); debug_data = [
var debug_data = [
initDataArray(1), initDataArray(1),
initDataArray(1), initDataArray(1),
initDataArray(1), initDataArray(1),
@ -260,7 +259,7 @@ TABS.sensors.initialize = function(callback) {
y: [], y: [],
z: [], z: [],
}; };
$('.plot_control .x, .plot_control .y, .plot_control .z').each(function() { $('.plot_control .x, .plot_control .y, .plot_control .z').each(function () {
var el = $(this); var el = $(this);
if (el.hasClass('x')) { if (el.hasClass('x')) {
raw_data_text_ements.x.push(el); raw_data_text_ements.x.push(el);
@ -272,7 +271,7 @@ TABS.sensors.initialize = function(callback) {
}); });
// set refresh speeds according to configuration saved in storage // set refresh speeds according to configuration saved in storage
chrome.storage.local.get('sensor_settings', function(result) { chrome.storage.local.get('sensor_settings', function (result) {
if (result.sensor_settings) { if (result.sensor_settings) {
$('.tab-sensors select[name="gyro_refresh_rate"]').val(result.sensor_settings.rates.gyro); $('.tab-sensors select[name="gyro_refresh_rate"]').val(result.sensor_settings.rates.gyro);
$('.tab-sensors select[name="gyro_scale"]').val(result.sensor_settings.scales.gyro); $('.tab-sensors select[name="gyro_scale"]').val(result.sensor_settings.scales.gyro);
@ -294,7 +293,7 @@ TABS.sensors.initialize = function(callback) {
} }
}); });
$('.tab-sensors .rate select, .tab-sensors .scale select').change(function() { $('.tab-sensors .rate select, .tab-sensors .scale select').change(function () {
// if any of the select fields change value, all of the select values are grabbed // if any of the select fields change value, all of the select values are grabbed
// and timers are re-initialized with the new settings // and timers are re-initialized with the new settings
var rates = { var rates = {
@ -327,7 +326,7 @@ TABS.sensors.initialize = function(callback) {
// fetch currently enabled plots // fetch currently enabled plots
var checkboxes = []; var checkboxes = [];
$('.tab-sensors .info .checkboxes input').each(function() { $('.tab-sensors .info .checkboxes input').each(function () {
checkboxes.push($(this).prop('checked')); checkboxes.push($(this).prop('checked'));
}); });
@ -406,7 +405,7 @@ TABS.sensors.initialize = function(callback) {
}); });
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function() { GUI.interval_add('status_pull', function () {
MSP.send_message(MSP_codes.MSP_STATUS); MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true); }, 250, true);
@ -414,7 +413,7 @@ TABS.sensors.initialize = function(callback) {
}); });
}; };
TABS.sensors.cleanup = function(callback) { TABS.sensors.cleanup = function (callback) {
serial.empty_output_buffer(); serial.empty_output_buffer();
if (callback) callback(); if (callback) callback();

View file

@ -7,7 +7,7 @@
'use strict'; 'use strict';
TABS.servos = {}; TABS.servos = {};
TABS.servos.initialize = function(callback) { TABS.servos.initialize = function (callback) {
GUI.active_tab_ref = this; GUI.active_tab_ref = this;
GUI.active_tab = 'servos'; GUI.active_tab = 'servos';
googleAnalytics.sendAppView('Servos'); googleAnalytics.sendAppView('Servos');
@ -114,7 +114,7 @@ TABS.servos.initialize = function(callback) {
// UI hooks // UI hooks
// only one checkbox for indicating a channel to forward can be selected at a time, perhaps a radio group would be best here. // only one checkbox for indicating a channel to forward can be selected at a time, perhaps a radio group would be best here.
$('div.tab-servos table.fields tr:last td.channel input').click(function() { $('div.tab-servos table.fields tr:last td.channel input').click(function () {
if($(this).is(':checked')) { if($(this).is(':checked')) {
$(this).parent().parent().find('.channel input').not($(this)).prop('checked', false); $(this).parent().parent().find('.channel input').not($(this)).prop('checked', false);
} }
@ -123,7 +123,7 @@ TABS.servos.initialize = function(callback) {
function servos_update(save_to_eeprom) { function servos_update(save_to_eeprom) {
// update bitfields // update bitfields
$('div.tab-servos table.directions tr:not(".main")').each(function() { $('div.tab-servos table.directions tr:not(".main")').each(function () {
var info = $('select', this).data('info'); var info = $('select', this).data('info');
var val = parseInt($('select', this).val()); var val = parseInt($('select', this).val());
@ -133,7 +133,7 @@ TABS.servos.initialize = function(callback) {
}); });
// update the rest // update the rest
$('div.tab-servos table.fields tr:not(".main")').each(function() { $('div.tab-servos table.fields tr:not(".main")').each(function () {
var info = $(this).data('info'); var info = $(this).data('info');
@ -189,7 +189,7 @@ TABS.servos.initialize = function(callback) {
if (save_to_eeprom) { if (save_to_eeprom) {
// Save changes to EEPROM // Save changes to EEPROM
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, function() { MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, function () {
GUI.log(chrome.i18n.getMessage('servosEepromSave')); GUI.log(chrome.i18n.getMessage('servosEepromSave'));
}); });
} }
@ -287,14 +287,14 @@ TABS.servos.initialize = function(callback) {
} }
// UI hooks for dynamically generated elements // UI hooks for dynamically generated elements
$('table.directions select, table.directions input, table.fields select, table.fields input').change(function() { $('table.directions select, table.directions input, table.fields select, table.fields input').change(function () {
if ($('div.live input').is(':checked')) { if ($('div.live input').is(':checked')) {
// apply small delay as there seems to be some funky update business going wrong // apply small delay as there seems to be some funky update business going wrong
GUI.timeout_add('servos_update', servos_update, 10); GUI.timeout_add('servos_update', servos_update, 10);
} }
}); });
$('a.update').click(function() { $('a.update').click(function () {
// standard check for supported_models + custom implementation for feature servo_tilt // standard check for supported_models + custom implementation for feature servo_tilt
if (supported_models.indexOf(CONFIG.multiType) != -1 || AUX_CONFIG.indexOf('CAMSTAB') > -1 || AUX_CONFIG.indexOf('CAMTRIG') > -1) { if (supported_models.indexOf(CONFIG.multiType) != -1 || AUX_CONFIG.indexOf('CAMSTAB') > -1 || AUX_CONFIG.indexOf('CAMTRIG') > -1) {
servos_update(true); servos_update(true);
@ -302,7 +302,7 @@ TABS.servos.initialize = function(callback) {
}); });
// status data pulled via separate timer with static speed // status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function() { GUI.interval_add('status_pull', function () {
MSP.send_message(MSP_codes.MSP_STATUS); MSP.send_message(MSP_codes.MSP_STATUS);
}, 250, true); }, 250, true);
@ -310,6 +310,6 @@ TABS.servos.initialize = function(callback) {
} }
}; };
TABS.servos.cleanup = function(callback) { TABS.servos.cleanup = function (callback) {
if (callback) callback(); if (callback) callback();
}; };