finishing touches (cleanup & optimize)

10.3.x-maintenance
cTn 2014-09-30 16:36:49 +02:00
parent f60de956a4
commit a82b968bee
1 changed files with 13 additions and 12 deletions

View File

@ -142,12 +142,12 @@ TABS.motor_outputs.initialize = function (callback) {
initSensorData(); initSensorData();
// Setup variables // Setup variables
var samples_accel_i = 0; var samples_accel_i = 0,
var accel_data = initDataArray(3); accel_data = initDataArray(3),
var accelHelpers = initGraphHelpers('#accel', samples_accel_i, [-2, 2]); accelHelpers = initGraphHelpers('#accel', samples_accel_i, [-2, 2]),
var accel_max_read = [0, 0, 0]; accel_max_read = [0, 0, 0],
var accel_offset = [0, 0, 0]; accel_offset = [0, 0, 0],
var accel_offset_established = false; accel_offset_established = false;
var raw_data_text_ements = { var raw_data_text_ements = {
x: [], x: [],
@ -237,8 +237,9 @@ TABS.motor_outputs.initialize = function (callback) {
var number_of_valid_outputs = (MOTOR_DATA.indexOf(0) > -1) ? MOTOR_DATA.indexOf(0) : 8; var number_of_valid_outputs = (MOTOR_DATA.indexOf(0) > -1) ? MOTOR_DATA.indexOf(0) : 8;
var motors_wrapper = $('.motors .bar-wrapper'); var motors_wrapper = $('.motors .bar-wrapper'),
var servos_wrapper = $('.servos .bar-wrapper'); servos_wrapper = $('.servos .bar-wrapper');
for (var i = 0; i < 8; i++) { for (var i = 0; i < 8; i++) {
motors_wrapper.append('\ motors_wrapper.append('\
<div class="m-block motor-' + i + '">\ <div class="m-block motor-' + i + '">\
@ -386,8 +387,8 @@ TABS.motor_outputs.initialize = function (callback) {
height = (data * (block_height / full_block_scale)), height = (data * (block_height / full_block_scale)),
color = parseInt(data * 0.256); color = parseInt(data * 0.256);
$('.motor-' + i + ' .label').text(MOTOR_DATA[i]); $('.motor-' + i + ' .label', motors_wrapper).text(MOTOR_DATA[i]);
$('.motor-' + i + ' .indicator').css({'margin-top' : margin_top + 'px', 'height' : height + 'px', 'background-color' : 'rgb(' + color + ',0,0)'}); $('.motor-' + i + ' .indicator', motors_wrapper).css({'margin-top' : margin_top + 'px', 'height' : height + 'px', 'background-color' : 'rgb(' + color + ',0,0)'});
} }
// servo indicators are still using old (not flexible block scale), it will be changed in the future accordingly // servo indicators are still using old (not flexible block scale), it will be changed in the future accordingly
@ -397,8 +398,8 @@ TABS.motor_outputs.initialize = function (callback) {
height = (data * (block_height / 1000)), height = (data * (block_height / 1000)),
color = parseInt(data * 0.256); color = parseInt(data * 0.256);
$('.servo-' + i + ' .label').text(SERVO_DATA[i]); $('.servo-' + i + ' .label', servos_wrapper).text(SERVO_DATA[i]);
$('.servo-' + i + ' .indicator').css({'margin-top' : margin_top + 'px', 'height' : height + 'px', 'background-color' : 'rgb(' + color + ',0,0)'}); $('.servo-' + i + ' .indicator', servos_wrapper).css({'margin-top' : margin_top + 'px', 'height' : height + 'px', 'background-color' : 'rgb(' + color + ',0,0)'});
} }
} }