33 lines
1.3 KiB
JavaScript
33 lines
1.3 KiB
JavaScript
function tab_initialize_motor_outputs() {
|
|
ga_tracker.sendAppView('Motor Outputs Page');
|
|
|
|
// enable Motor data pulling
|
|
timers.push(setInterval(motorPoll, 50));
|
|
}
|
|
|
|
function motorPoll() {
|
|
// Request New Motor data
|
|
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
|
|
send_message(MSP_codes.MSP_MOTOR, MSP_codes.MSP_MOTOR);
|
|
|
|
// Update UI
|
|
for (var i = 0; i < MOTOR_DATA.length; i++) {
|
|
MOTOR_DATA[i] -= 1000;
|
|
var margin_top = 330.0 - (MOTOR_DATA[i] * 0.33);
|
|
var height = (MOTOR_DATA[i] * 0.33);
|
|
var color = parseInt(MOTOR_DATA[i] * 0.256);
|
|
$('.motor-' + i + ' .indicator').css({'margin-top' : margin_top + 'px', 'height' : height + 'px', 'background-color' : 'rgb(' + color + ',0,0)'});
|
|
}
|
|
|
|
// Request New Servo data
|
|
send_message(MSP_codes.MSP_SERVO, MSP_codes.MSP_SERVO);
|
|
|
|
// Update UI
|
|
for (var i = 0; i < SERVO_DATA.length; i++) {
|
|
SERVO_DATA[i] -= 1000;
|
|
var margin_top = 330.0 - (SERVO_DATA[i] * 0.33);
|
|
var height = (SERVO_DATA[i] * 0.33);
|
|
var color = parseInt(SERVO_DATA[i] * 0.256);
|
|
$('.servo-' + i + ' .indicator').css({'margin-top' : margin_top + 'px', 'height' : height + 'px', 'background-color' : 'rgb(' + color + ',0,0)'});
|
|
}
|
|
} |