mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 22:35:23 +03:00
new UI population / JS execution order
(blink bugfix for several tabs)
This commit is contained in:
parent
d4dbb880d6
commit
ce351d7521
10 changed files with 588 additions and 597 deletions
|
@ -1,11 +1,10 @@
|
||||||
function tab_initialize_auxiliary_configuration() {
|
function tab_initialize_auxiliary_configuration() {
|
||||||
ga_tracker.sendAppView('Auxiliary Configuration');
|
ga_tracker.sendAppView('Auxiliary Configuration');
|
||||||
|
GUI.active_tab = 'auxiliary_configuration';
|
||||||
$('#content').load("./tabs/auxiliary_configuration.html", function() {
|
|
||||||
GUI.active_tab = 'auxiliary_configuration';
|
|
||||||
|
|
||||||
send_message(MSP_codes.MSP_BOXNAMES, MSP_codes.MSP_BOXNAMES, false, function() {
|
send_message(MSP_codes.MSP_BOXNAMES, MSP_codes.MSP_BOXNAMES, false, function() {
|
||||||
send_message(MSP_codes.MSP_BOX, MSP_codes.MSP_BOX, false, function() {
|
send_message(MSP_codes.MSP_BOX, MSP_codes.MSP_BOX, false, function() {
|
||||||
|
$('#content').load("./tabs/auxiliary_configuration.html", function() {
|
||||||
// generate table from the supplied AUX names and AUX data
|
// generate table from the supplied AUX names and AUX data
|
||||||
for (var i = 0; i < AUX_CONFIG.length; i++) {
|
for (var i = 0; i < AUX_CONFIG.length; i++) {
|
||||||
$('.boxes > tbody:last').append(
|
$('.boxes > tbody:last').append(
|
||||||
|
@ -77,25 +76,25 @@ function tab_initialize_auxiliary_configuration() {
|
||||||
|
|
||||||
// enable data pulling
|
// enable data pulling
|
||||||
GUI.interval_add('aux_data_poll', function() {
|
GUI.interval_add('aux_data_poll', function() {
|
||||||
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
|
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
|
||||||
send_message(MSP_codes.MSP_RC, MSP_codes.MSP_RC, false, function() {
|
send_message(MSP_codes.MSP_RC, MSP_codes.MSP_RC, false, function() {
|
||||||
for (var i = 0; i < AUX_CONFIG.length; i++) {
|
for (var i = 0; i < AUX_CONFIG.length; i++) {
|
||||||
if (bit_check(CONFIG.mode, i)) {
|
if (bit_check(CONFIG.mode, i)) {
|
||||||
$('td.name').eq(i).addClass('on').removeClass('off');
|
$('td.name').eq(i).addClass('on').removeClass('off');
|
||||||
} else {
|
} else {
|
||||||
$('td.name').eq(i).removeClass('on').removeClass('off');
|
$('td.name').eq(i).removeClass('on').removeClass('off');
|
||||||
|
|
||||||
if (AUX_CONFIG_values[i] > 0) {
|
if (AUX_CONFIG_values[i] > 0) {
|
||||||
$('td.name').eq(i).addClass('off');
|
$('td.name').eq(i).addClass('off');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
box_highlight(RC.AUX1, 2);
|
||||||
box_highlight(RC.AUX1, 2);
|
box_highlight(RC.AUX2, 5);
|
||||||
box_highlight(RC.AUX2, 5);
|
box_highlight(RC.AUX3, 8);
|
||||||
box_highlight(RC.AUX3, 8);
|
box_highlight(RC.AUX4, 11);
|
||||||
box_highlight(RC.AUX4, 11);
|
});
|
||||||
});
|
|
||||||
}, 50, true);
|
}, 50, true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
11
tabs/cli.js
11
tabs/cli.js
|
@ -23,13 +23,12 @@ cli_history = new CliHistory();
|
||||||
|
|
||||||
function tab_initialize_cli() {
|
function tab_initialize_cli() {
|
||||||
ga_tracker.sendAppView('CLI Page');
|
ga_tracker.sendAppView('CLI Page');
|
||||||
|
GUI.active_tab = 'cli';
|
||||||
|
|
||||||
$('#content').load("./tabs/cli.html", function() {
|
// remove any active interval for delayed command
|
||||||
GUI.active_tab = 'cli';
|
MSP.callbacks_cleanup();
|
||||||
|
|
||||||
// remove any active interval for delayed command
|
$('#content').load("./tabs/cli.html", function() {
|
||||||
MSP.callbacks_cleanup();
|
|
||||||
|
|
||||||
CLI_active = true;
|
CLI_active = true;
|
||||||
|
|
||||||
// Enter CLI mode
|
// Enter CLI mode
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
function tab_initialize_default() {
|
function tab_initialize_default() {
|
||||||
$('#content').load("./tabs/default.html", function() {
|
GUI.active_tab = 'default';
|
||||||
GUI.active_tab = 'default';
|
|
||||||
|
$('#content').load("./tabs/default.html", function() {
|
||||||
// load changelog content
|
// load changelog content
|
||||||
$('div.changelog.configurator .wrapper').load('./changelog.html');
|
$('div.changelog.configurator .wrapper').load('./changelog.html');
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
function tab_initialize_gps () {
|
function tab_initialize_gps () {
|
||||||
ga_tracker.sendAppView('GPS Page');
|
ga_tracker.sendAppView('GPS Page');
|
||||||
|
GUI.active_tab = 'gps';
|
||||||
|
|
||||||
$('#content').load("./tabs/gps.html", function() {
|
$('#content').load("./tabs/gps.html", function() {
|
||||||
GUI.active_tab = 'gps';
|
|
||||||
|
|
||||||
// enable data pulling
|
// enable data pulling
|
||||||
GUI.interval_add('gps_pull', function() {
|
GUI.interval_add('gps_pull', function() {
|
||||||
// Update GPS data
|
// Update GPS data
|
||||||
|
|
|
@ -1,248 +1,245 @@
|
||||||
function tab_initialize_initial_setup() {
|
function tab_initialize_initial_setup() {
|
||||||
ga_tracker.sendAppView('Initial Setup');
|
ga_tracker.sendAppView('Initial Setup');
|
||||||
|
GUI.active_tab = 'initial_setup';
|
||||||
|
|
||||||
$('#content').load("./tabs/initial_setup.html", function() {
|
send_message(MSP_codes.MSP_ACC_TRIM, MSP_codes.MSP_ACC_TRIM, false, function() {
|
||||||
GUI.active_tab = 'initial_setup';
|
send_message(MSP_codes.MSP_MISC, MSP_codes.MSP_MISC, false, function() {
|
||||||
|
$('#content').load("./tabs/initial_setup.html", function() {
|
||||||
send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT, false, function() {
|
var yaw_fix = 0.0;
|
||||||
send_message(MSP_codes.MSP_ACC_TRIM, MSP_codes.MSP_ACC_TRIM, false, function() {
|
|
||||||
send_message(MSP_codes.MSP_MISC, MSP_codes.MSP_MISC, false, function() {
|
// Fill in misc stuff
|
||||||
var yaw_fix = 0.0;
|
$('input[name="mincellvoltage"]').val(MISC.vbatmincellvoltage);
|
||||||
|
$('input[name="maxcellvoltage"]').val(MISC.vbatmaxcellvoltage);
|
||||||
|
$('input[name="voltagescale"]').val(MISC.vbatscale);
|
||||||
|
|
||||||
|
$('input[name="minthrottle"]').val(MISC.minthrottle);
|
||||||
|
$('input[name="maxthrottle"]').val(MISC.maxthrottle);
|
||||||
|
$('input[name="failsafe_throttle"]').val(MISC.failsafe_throttle);
|
||||||
|
$('input[name="mincommand"]').val(MISC.mincommand);
|
||||||
|
|
||||||
|
$('input[name="mag_declination"]').val(MISC.mag_declination / 10);
|
||||||
|
|
||||||
|
// Fill in the accel trimms from CONFIG object
|
||||||
|
$('input[name="pitch"]').val(CONFIG.accelerometerTrims[0]);
|
||||||
|
$('input[name="roll"]').val(CONFIG.accelerometerTrims[1]);
|
||||||
|
|
||||||
|
// Display multiType
|
||||||
|
var str = '';
|
||||||
|
switch (CONFIG.multiType) {
|
||||||
|
case 1: // TRI
|
||||||
|
str = 'TRI';
|
||||||
|
break;
|
||||||
|
case 2: // QUAD +
|
||||||
|
str = 'Quad +';
|
||||||
|
break;
|
||||||
|
case 3: // QUAD X
|
||||||
|
str = 'Quad X';
|
||||||
|
break;
|
||||||
|
case 4: // BI
|
||||||
|
str = 'BI';
|
||||||
|
break;
|
||||||
|
case 5: // GIMBAL
|
||||||
|
str = 'Gimbal';
|
||||||
|
break;
|
||||||
|
case 6: // Y6
|
||||||
|
str = 'Y6';
|
||||||
|
break;
|
||||||
|
case 7: // HEX 6
|
||||||
|
str = 'HEX 6';
|
||||||
|
break;
|
||||||
|
case 8: // FLYING_WING
|
||||||
|
str = 'Flying Wing';
|
||||||
|
break;
|
||||||
|
case 9: // Y4
|
||||||
|
str = 'Y4';
|
||||||
|
break;
|
||||||
|
case 10: // HEX6 X
|
||||||
|
str = 'HEX6 X';
|
||||||
|
break;
|
||||||
|
case 11: // OCTO X8
|
||||||
|
case 12:
|
||||||
|
case 13:
|
||||||
|
str = 'OCTO X8';
|
||||||
|
break;
|
||||||
|
case 14: // AIRPLANE
|
||||||
|
str = 'Airplane';
|
||||||
|
break;
|
||||||
|
case 15: // Heli 120
|
||||||
|
str = 'Heli 120';
|
||||||
|
break;
|
||||||
|
case 16: // Heli 90
|
||||||
|
str = 'Heli 90';
|
||||||
|
break;
|
||||||
|
case 17: // Vtail
|
||||||
|
str = 'Vtail';
|
||||||
|
break;
|
||||||
|
case 18: // HEX6 H
|
||||||
|
str = 'HEX6 H';
|
||||||
|
break;
|
||||||
|
case 19: // PPM to SERVO
|
||||||
|
str = 'PPM to SERVO';
|
||||||
|
break;
|
||||||
|
case 20: // Dualcopter
|
||||||
|
str = 'Dualcopter';
|
||||||
|
break;
|
||||||
|
case 21: //
|
||||||
|
str = 'Singlecopter';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$('span.model').html('Model: ' + str);
|
||||||
|
|
||||||
|
// UI Hooks
|
||||||
|
$('a.calibrateAccel').click(function() {
|
||||||
|
var self = $(this);
|
||||||
|
|
||||||
// Fill in misc stuff
|
if (!self.hasClass('calibrating')) {
|
||||||
$('input[name="mincellvoltage"]').val(MISC.vbatmincellvoltage);
|
self.addClass('calibrating');
|
||||||
$('input[name="maxcellvoltage"]').val(MISC.vbatmaxcellvoltage);
|
|
||||||
$('input[name="voltagescale"]').val(MISC.vbatscale);
|
// During this period MCU won't be able to process any serial commands because its locked in a for/while loop
|
||||||
|
// until this operation finishes, sending more commands through data_poll() will result in serial buffer overflow
|
||||||
$('input[name="minthrottle"]').val(MISC.minthrottle);
|
GUI.interval_pause('initial_setup_data_pull');
|
||||||
$('input[name="maxthrottle"]').val(MISC.maxthrottle);
|
send_message(MSP_codes.MSP_ACC_CALIBRATION, MSP_codes.MSP_ACC_CALIBRATION, false, function() {
|
||||||
$('input[name="failsafe_throttle"]').val(MISC.failsafe_throttle);
|
GUI.log('Accelerometer calibration started');
|
||||||
$('input[name="mincommand"]').val(MISC.mincommand);
|
});
|
||||||
|
|
||||||
$('input[name="mag_declination"]').val(MISC.mag_declination / 10);
|
GUI.timeout_add('button_reset', function() {
|
||||||
|
GUI.interval_resume('initial_setup_data_pull');
|
||||||
// Fill in the accel trimms from CONFIG object
|
|
||||||
$('input[name="pitch"]').val(CONFIG.accelerometerTrims[0]);
|
GUI.log('Accelerometer calibration finished');
|
||||||
$('input[name="roll"]').val(CONFIG.accelerometerTrims[1]);
|
|
||||||
|
self.removeClass('calibrating');
|
||||||
// Display multiType
|
}, 2000);
|
||||||
var str = '';
|
|
||||||
switch (CONFIG.multiType) {
|
|
||||||
case 1: // TRI
|
|
||||||
str = 'TRI';
|
|
||||||
break;
|
|
||||||
case 2: // QUAD +
|
|
||||||
str = 'Quad +';
|
|
||||||
break;
|
|
||||||
case 3: // QUAD X
|
|
||||||
str = 'Quad X';
|
|
||||||
break;
|
|
||||||
case 4: // BI
|
|
||||||
str = 'BI';
|
|
||||||
break;
|
|
||||||
case 5: // GIMBAL
|
|
||||||
str = 'Gimbal';
|
|
||||||
break;
|
|
||||||
case 6: // Y6
|
|
||||||
str = 'Y6';
|
|
||||||
break;
|
|
||||||
case 7: // HEX 6
|
|
||||||
str = 'HEX 6';
|
|
||||||
break;
|
|
||||||
case 8: // FLYING_WING
|
|
||||||
str = 'Flying Wing';
|
|
||||||
break;
|
|
||||||
case 9: // Y4
|
|
||||||
str = 'Y4';
|
|
||||||
break;
|
|
||||||
case 10: // HEX6 X
|
|
||||||
str = 'HEX6 X';
|
|
||||||
break;
|
|
||||||
case 11: // OCTO X8
|
|
||||||
case 12:
|
|
||||||
case 13:
|
|
||||||
str = 'OCTO X8';
|
|
||||||
break;
|
|
||||||
case 14: // AIRPLANE
|
|
||||||
str = 'Airplane';
|
|
||||||
break;
|
|
||||||
case 15: // Heli 120
|
|
||||||
str = 'Heli 120';
|
|
||||||
break;
|
|
||||||
case 16: // Heli 90
|
|
||||||
str = 'Heli 90';
|
|
||||||
break;
|
|
||||||
case 17: // Vtail
|
|
||||||
str = 'Vtail';
|
|
||||||
break;
|
|
||||||
case 18: // HEX6 H
|
|
||||||
str = 'HEX6 H';
|
|
||||||
break;
|
|
||||||
case 19: // PPM to SERVO
|
|
||||||
str = 'PPM to SERVO';
|
|
||||||
break;
|
|
||||||
case 20: // Dualcopter
|
|
||||||
str = 'Dualcopter';
|
|
||||||
break;
|
|
||||||
case 21: //
|
|
||||||
str = 'Singlecopter';
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$('span.model').html('Model: ' + str);
|
|
||||||
|
|
||||||
// UI Hooks
|
|
||||||
$('a.calibrateAccel').click(function() {
|
|
||||||
var self = $(this);
|
|
||||||
|
|
||||||
if (!self.hasClass('calibrating')) {
|
|
||||||
self.addClass('calibrating');
|
|
||||||
|
|
||||||
// During this period MCU won't be able to process any serial commands because its locked in a for/while loop
|
|
||||||
// until this operation finishes, sending more commands through data_poll() will result in serial buffer overflow
|
|
||||||
GUI.interval_pause('initial_setup_data_pull');
|
|
||||||
send_message(MSP_codes.MSP_ACC_CALIBRATION, MSP_codes.MSP_ACC_CALIBRATION, false, function() {
|
|
||||||
GUI.log('Accelerometer calibration started');
|
|
||||||
});
|
|
||||||
|
|
||||||
GUI.timeout_add('button_reset', function() {
|
|
||||||
GUI.interval_resume('initial_setup_data_pull');
|
|
||||||
|
|
||||||
GUI.log('Accelerometer calibration finished');
|
|
||||||
|
|
||||||
self.removeClass('calibrating');
|
|
||||||
}, 2000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('a.calibrateMag').click(function() {
|
|
||||||
var self = $(this);
|
|
||||||
|
|
||||||
if (!self.hasClass('calibrating')) {
|
|
||||||
self.addClass('calibrating');
|
|
||||||
|
|
||||||
send_message(MSP_codes.MSP_MAG_CALIBRATION, MSP_codes.MSP_MAG_CALIBRATION, false, function() {
|
|
||||||
GUI.log('Magnetometer calibration started');
|
|
||||||
});
|
|
||||||
|
|
||||||
GUI.timeout_add('button_reset', function() {
|
|
||||||
GUI.log('Magnetometer calibration finished');
|
|
||||||
self.removeClass('calibrating');
|
|
||||||
}, 30000);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('a.resetSettings').click(function() {
|
|
||||||
send_message(MSP_codes.MSP_RESET_CONF, MSP_codes.MSP_RESET_CONF, false, function() {
|
|
||||||
GUI.log('Settings restored to <strong>default</strong>');
|
|
||||||
|
|
||||||
GUI.tab_switch_cleanup(function() {
|
|
||||||
tab_initialize_initial_setup();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$('a.update').click(function() {
|
|
||||||
CONFIG.accelerometerTrims[0] = parseInt($('input[name="pitch"]').val());
|
|
||||||
CONFIG.accelerometerTrims[1] = parseInt($('input[name="roll"]').val());
|
|
||||||
|
|
||||||
var buffer_out = new Array();
|
|
||||||
buffer_out[0] = lowByte(CONFIG.accelerometerTrims[0]);
|
|
||||||
buffer_out[1] = highByte(CONFIG.accelerometerTrims[0]);
|
|
||||||
buffer_out[2] = lowByte(CONFIG.accelerometerTrims[1]);
|
|
||||||
buffer_out[3] = highByte(CONFIG.accelerometerTrims[1]);
|
|
||||||
|
|
||||||
// Send over the new trims
|
|
||||||
send_message(MSP_codes.MSP_SET_ACC_TRIM, buffer_out);
|
|
||||||
|
|
||||||
MISC.vbatmincellvoltage = parseFloat($('input[name="mincellvoltage"]').val()) * 10;
|
|
||||||
MISC.vbatmaxcellvoltage = parseFloat($('input[name="maxcellvoltage"]').val()) * 10;
|
|
||||||
MISC.vbatscale = parseInt($('input[name="voltagescale"]').val());
|
|
||||||
|
|
||||||
MISC.minthrottle = parseInt($('input[name="minthrottle"]').val());
|
|
||||||
MISC.maxthrottle = parseInt($('input[name="maxthrottle"]').val());
|
|
||||||
MISC.failsafe_throttle = parseInt($('input[name="failsafe_throttle"]').val());
|
|
||||||
MISC.mincommand = parseInt($('input[name="mincommand"]').val());
|
|
||||||
|
|
||||||
MISC.mag_declination = parseFloat($('input[name="mag_declination"]').val()) * 10;
|
|
||||||
|
|
||||||
// we also have to fill the unsupported bytes
|
|
||||||
var buffer_out = new Array();
|
|
||||||
buffer_out[0] = 0; // powerfailmeter
|
|
||||||
buffer_out[1] = 0;
|
|
||||||
buffer_out[2] = lowByte(MISC.minthrottle);
|
|
||||||
buffer_out[3] = highByte(MISC.minthrottle);
|
|
||||||
buffer_out[4] = lowByte(MISC.maxthrottle);
|
|
||||||
buffer_out[5] = highByte(MISC.maxthrottle);
|
|
||||||
buffer_out[6] = lowByte(MISC.mincommand);
|
|
||||||
buffer_out[7] = highByte(MISC.mincommand);
|
|
||||||
buffer_out[8] = lowByte(MISC.failsafe_throttle);
|
|
||||||
buffer_out[9] = highByte(MISC.failsafe_throttle);
|
|
||||||
buffer_out[10] = 0;
|
|
||||||
buffer_out[11] = 0;
|
|
||||||
buffer_out[12] = 0;
|
|
||||||
buffer_out[13] = 0;
|
|
||||||
buffer_out[14] = 0;
|
|
||||||
buffer_out[15] = 0;
|
|
||||||
buffer_out[16] = lowByte(MISC.mag_declination);
|
|
||||||
buffer_out[17] = highByte(MISC.mag_declination);
|
|
||||||
buffer_out[18] = MISC.vbatscale;
|
|
||||||
buffer_out[19] = MISC.vbatmincellvoltage;
|
|
||||||
buffer_out[20] = MISC.vbatmaxcellvoltage;
|
|
||||||
buffer_out[21] = 0; // vbatlevel_crit (unused)
|
|
||||||
|
|
||||||
// Send over new misc
|
|
||||||
send_message(MSP_codes.MSP_SET_MISC, buffer_out);
|
|
||||||
|
|
||||||
// Save changes to EEPROM
|
|
||||||
send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE, false, function() {
|
|
||||||
GUI.log('EEPROM <span style="color: green">saved</span>');
|
|
||||||
|
|
||||||
var element = $('a.update');
|
|
||||||
element.addClass('success');
|
|
||||||
|
|
||||||
GUI.timeout_add('success_highlight', function() {
|
|
||||||
element.removeClass('success');
|
|
||||||
}, 2000);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// reset yaw button hook
|
|
||||||
$('div#interactive_block > a.reset').click(function() {
|
|
||||||
yaw_fix = SENSOR_DATA.kinematicsZ * - 1.0;
|
|
||||||
console.log("YAW reset to 0");
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#content .backup').click(configuration_backup);
|
|
||||||
|
|
||||||
$('#content .restore').click(configuration_restore);
|
|
||||||
|
|
||||||
GUI.interval_add('initial_setup_data_pull', function() {
|
|
||||||
// Update voltage indicator
|
|
||||||
$('.bat-voltage').html(ANALOG.voltage + ' V');
|
|
||||||
|
|
||||||
// Request new data, if transmission fails it doesn't matter as new transmission will be requested after 50ms
|
|
||||||
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS, false, function() { // cycle time, active sensors, etc...
|
|
||||||
send_message(MSP_codes.MSP_ANALOG, MSP_codes.MSP_ANALOG, false, function() { // battery voltage
|
|
||||||
send_message(MSP_codes.MSP_ATTITUDE, MSP_codes.MSP_ATTITUDE, false, function() { // kinematics
|
|
||||||
// Update cube
|
|
||||||
var cube = $('div#cube');
|
|
||||||
|
|
||||||
cube.css('-webkit-transform', 'rotateY(' + ((SENSOR_DATA.kinematicsZ * -1.0) - yaw_fix) + 'deg)');
|
|
||||||
$('#cubePITCH', cube).css('-webkit-transform', 'rotateX(' + SENSOR_DATA.kinematicsY + 'deg)');
|
|
||||||
$('#cubeROLL', cube).css('-webkit-transform', 'rotateZ(' + SENSOR_DATA.kinematicsX + 'deg)');
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Update Compass
|
|
||||||
$('div#compass .pointer').css('-webkit-transform', 'rotate(' + (SENSOR_DATA.kinematicsZ) + 'deg)');
|
|
||||||
$('div#compass .value').html(SENSOR_DATA.kinematicsZ + '°');
|
|
||||||
*/
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, 50, true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('a.calibrateMag').click(function() {
|
||||||
|
var self = $(this);
|
||||||
|
|
||||||
|
if (!self.hasClass('calibrating')) {
|
||||||
|
self.addClass('calibrating');
|
||||||
|
|
||||||
|
send_message(MSP_codes.MSP_MAG_CALIBRATION, MSP_codes.MSP_MAG_CALIBRATION, false, function() {
|
||||||
|
GUI.log('Magnetometer calibration started');
|
||||||
|
});
|
||||||
|
|
||||||
|
GUI.timeout_add('button_reset', function() {
|
||||||
|
GUI.log('Magnetometer calibration finished');
|
||||||
|
self.removeClass('calibrating');
|
||||||
|
}, 30000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('a.resetSettings').click(function() {
|
||||||
|
send_message(MSP_codes.MSP_RESET_CONF, MSP_codes.MSP_RESET_CONF, false, function() {
|
||||||
|
GUI.log('Settings restored to <strong>default</strong>');
|
||||||
|
|
||||||
|
GUI.tab_switch_cleanup(function() {
|
||||||
|
tab_initialize_initial_setup();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$('a.update').click(function() {
|
||||||
|
CONFIG.accelerometerTrims[0] = parseInt($('input[name="pitch"]').val());
|
||||||
|
CONFIG.accelerometerTrims[1] = parseInt($('input[name="roll"]').val());
|
||||||
|
|
||||||
|
var buffer_out = new Array();
|
||||||
|
buffer_out[0] = lowByte(CONFIG.accelerometerTrims[0]);
|
||||||
|
buffer_out[1] = highByte(CONFIG.accelerometerTrims[0]);
|
||||||
|
buffer_out[2] = lowByte(CONFIG.accelerometerTrims[1]);
|
||||||
|
buffer_out[3] = highByte(CONFIG.accelerometerTrims[1]);
|
||||||
|
|
||||||
|
// Send over the new trims
|
||||||
|
send_message(MSP_codes.MSP_SET_ACC_TRIM, buffer_out);
|
||||||
|
|
||||||
|
MISC.vbatmincellvoltage = parseFloat($('input[name="mincellvoltage"]').val()) * 10;
|
||||||
|
MISC.vbatmaxcellvoltage = parseFloat($('input[name="maxcellvoltage"]').val()) * 10;
|
||||||
|
MISC.vbatscale = parseInt($('input[name="voltagescale"]').val());
|
||||||
|
|
||||||
|
MISC.minthrottle = parseInt($('input[name="minthrottle"]').val());
|
||||||
|
MISC.maxthrottle = parseInt($('input[name="maxthrottle"]').val());
|
||||||
|
MISC.failsafe_throttle = parseInt($('input[name="failsafe_throttle"]').val());
|
||||||
|
MISC.mincommand = parseInt($('input[name="mincommand"]').val());
|
||||||
|
|
||||||
|
MISC.mag_declination = parseFloat($('input[name="mag_declination"]').val()) * 10;
|
||||||
|
|
||||||
|
// we also have to fill the unsupported bytes
|
||||||
|
var buffer_out = new Array();
|
||||||
|
buffer_out[0] = 0; // powerfailmeter
|
||||||
|
buffer_out[1] = 0;
|
||||||
|
buffer_out[2] = lowByte(MISC.minthrottle);
|
||||||
|
buffer_out[3] = highByte(MISC.minthrottle);
|
||||||
|
buffer_out[4] = lowByte(MISC.maxthrottle);
|
||||||
|
buffer_out[5] = highByte(MISC.maxthrottle);
|
||||||
|
buffer_out[6] = lowByte(MISC.mincommand);
|
||||||
|
buffer_out[7] = highByte(MISC.mincommand);
|
||||||
|
buffer_out[8] = lowByte(MISC.failsafe_throttle);
|
||||||
|
buffer_out[9] = highByte(MISC.failsafe_throttle);
|
||||||
|
buffer_out[10] = 0;
|
||||||
|
buffer_out[11] = 0;
|
||||||
|
buffer_out[12] = 0;
|
||||||
|
buffer_out[13] = 0;
|
||||||
|
buffer_out[14] = 0;
|
||||||
|
buffer_out[15] = 0;
|
||||||
|
buffer_out[16] = lowByte(MISC.mag_declination);
|
||||||
|
buffer_out[17] = highByte(MISC.mag_declination);
|
||||||
|
buffer_out[18] = MISC.vbatscale;
|
||||||
|
buffer_out[19] = MISC.vbatmincellvoltage;
|
||||||
|
buffer_out[20] = MISC.vbatmaxcellvoltage;
|
||||||
|
buffer_out[21] = 0; // vbatlevel_crit (unused)
|
||||||
|
|
||||||
|
// Send over new misc
|
||||||
|
send_message(MSP_codes.MSP_SET_MISC, buffer_out);
|
||||||
|
|
||||||
|
// Save changes to EEPROM
|
||||||
|
send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE, false, function() {
|
||||||
|
GUI.log('EEPROM <span style="color: green">saved</span>');
|
||||||
|
|
||||||
|
var element = $('a.update');
|
||||||
|
element.addClass('success');
|
||||||
|
|
||||||
|
GUI.timeout_add('success_highlight', function() {
|
||||||
|
element.removeClass('success');
|
||||||
|
}, 2000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// reset yaw button hook
|
||||||
|
$('div#interactive_block > a.reset').click(function() {
|
||||||
|
yaw_fix = SENSOR_DATA.kinematicsZ * - 1.0;
|
||||||
|
console.log("YAW reset to 0");
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#content .backup').click(configuration_backup);
|
||||||
|
|
||||||
|
$('#content .restore').click(configuration_restore);
|
||||||
|
|
||||||
|
GUI.interval_add('initial_setup_data_pull', function() {
|
||||||
|
// Update voltage indicator
|
||||||
|
$('.bat-voltage').html(ANALOG.voltage + ' V');
|
||||||
|
|
||||||
|
// Request new data, if transmission fails it doesn't matter as new transmission will be requested after 50ms
|
||||||
|
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS, false, function() { // cycle time, active sensors, etc...
|
||||||
|
send_message(MSP_codes.MSP_ANALOG, MSP_codes.MSP_ANALOG, false, function() { // battery voltage
|
||||||
|
send_message(MSP_codes.MSP_ATTITUDE, MSP_codes.MSP_ATTITUDE, false, function() { // kinematics
|
||||||
|
// Update cube
|
||||||
|
var cube = $('div#cube');
|
||||||
|
|
||||||
|
cube.css('-webkit-transform', 'rotateY(' + ((SENSOR_DATA.kinematicsZ * -1.0) - yaw_fix) + 'deg)');
|
||||||
|
$('#cubePITCH', cube).css('-webkit-transform', 'rotateX(' + SENSOR_DATA.kinematicsY + 'deg)');
|
||||||
|
$('#cubeROLL', cube).css('-webkit-transform', 'rotateZ(' + SENSOR_DATA.kinematicsX + 'deg)');
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Update Compass
|
||||||
|
$('div#compass .pointer').css('-webkit-transform', 'rotate(' + (SENSOR_DATA.kinematicsZ) + 'deg)');
|
||||||
|
$('div#compass .value').html(SENSOR_DATA.kinematicsZ + '°');
|
||||||
|
*/
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, 50, true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
function tab_initialize_motor_outputs() {
|
function tab_initialize_motor_outputs() {
|
||||||
ga_tracker.sendAppView('Motor Outputs Page');
|
ga_tracker.sendAppView('Motor Outputs Page');
|
||||||
|
GUI.active_tab = 'motor_outputs';
|
||||||
|
|
||||||
$('#content').load("./tabs/motor_outputs.html", function() {
|
send_message(MSP_codes.MSP_MISC, MSP_codes.MSP_MISC, false, function() {
|
||||||
GUI.active_tab = 'motor_outputs';
|
$('#content').load("./tabs/motor_outputs.html", function() {
|
||||||
|
// if CAP_DYNBALANCE is true
|
||||||
// if CAP_DYNBALANCE is true
|
if (bit_check(CONFIG.capability, 2)) {
|
||||||
if (bit_check(CONFIG.capability, 2)) {
|
$('div.motor_testing').show();
|
||||||
$('div.motor_testing').show();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
send_message(MSP_codes.MSP_MISC, MSP_codes.MSP_MISC, false, function() {
|
|
||||||
$('input.min').val(MISC.minthrottle);
|
$('input.min').val(MISC.minthrottle);
|
||||||
$('input.max').val(MISC.maxthrottle);
|
$('input.max').val(MISC.maxthrottle);
|
||||||
|
|
||||||
|
@ -18,92 +17,92 @@ function tab_initialize_motor_outputs() {
|
||||||
$('div.sliders input').prop('max', MISC.maxthrottle);
|
$('div.sliders input').prop('max', MISC.maxthrottle);
|
||||||
$('div.sliders input').val(MISC.minthrottle);
|
$('div.sliders input').val(MISC.minthrottle);
|
||||||
$('div.values li:not(:last)').html(MISC.minthrottle);
|
$('div.values li:not(:last)').html(MISC.minthrottle);
|
||||||
});
|
|
||||||
|
|
||||||
// UI hooks
|
|
||||||
$('div.sliders input:not(.master)').change(function() {
|
|
||||||
var index = $(this).index();
|
|
||||||
|
|
||||||
$('div.values li').eq(index).html($(this).val());
|
// UI hooks
|
||||||
|
$('div.sliders input:not(.master)').change(function() {
|
||||||
// send data to mcu
|
var index = $(this).index();
|
||||||
var buffer_out = [];
|
|
||||||
|
|
||||||
for (var i = 0; i < 8; i++) {
|
|
||||||
var val = parseInt($('div.sliders input').eq(i).val());
|
|
||||||
|
|
||||||
buffer_out.push(lowByte(val));
|
$('div.values li').eq(index).html($(this).val());
|
||||||
buffer_out.push(highByte(val));
|
|
||||||
}
|
|
||||||
|
|
||||||
send_message(MSP_codes.MSP_SET_MOTOR, buffer_out);
|
|
||||||
});
|
|
||||||
|
|
||||||
$('div.sliders input.master').change(function() {
|
|
||||||
var val = $(this).val();
|
|
||||||
|
|
||||||
$('div.sliders input').val(val);
|
|
||||||
$('div.sliders input:not(:last):first').change();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('div.notice input[type="checkbox"]').change(function() {
|
|
||||||
if ($(this).is(':checked')) {
|
|
||||||
$('div.sliders input, .notice input[type="number"]').prop('disabled', false);
|
|
||||||
} else {
|
|
||||||
// disable sliders / min max
|
|
||||||
$('div.sliders input, .notice input[type="number"]').prop('disabled', true);
|
|
||||||
|
|
||||||
// change all values to default
|
// send data to mcu
|
||||||
$('div.sliders input').val(1000);
|
var buffer_out = [];
|
||||||
$('div.values li:not(:last)').html(1000);
|
|
||||||
|
for (var i = 0; i < 8; i++) {
|
||||||
|
var val = parseInt($('div.sliders input').eq(i).val());
|
||||||
|
|
||||||
|
buffer_out.push(lowByte(val));
|
||||||
|
buffer_out.push(highByte(val));
|
||||||
|
}
|
||||||
|
|
||||||
|
send_message(MSP_codes.MSP_SET_MOTOR, buffer_out);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('div.sliders input.master').change(function() {
|
||||||
|
var val = $(this).val();
|
||||||
|
|
||||||
|
$('div.sliders input').val(val);
|
||||||
|
$('div.sliders input:not(:last):first').change();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('div.notice input[type="checkbox"]').change(function() {
|
||||||
|
if ($(this).is(':checked')) {
|
||||||
|
$('div.sliders input, .notice input[type="number"]').prop('disabled', false);
|
||||||
|
} else {
|
||||||
|
// disable sliders / min max
|
||||||
|
$('div.sliders input, .notice input[type="number"]').prop('disabled', true);
|
||||||
|
|
||||||
|
// change all values to default
|
||||||
|
$('div.sliders input').val(1000);
|
||||||
|
$('div.values li:not(:last)').html(1000);
|
||||||
|
|
||||||
|
// trigger change event so values are sent to mcu
|
||||||
|
$('div.sliders input').change();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('div.notice input[type="number"]').change(function() {
|
||||||
|
var min = parseInt($('div.notice .min').val());
|
||||||
|
var max = parseInt($('div.notice .max').val());
|
||||||
|
|
||||||
|
|
||||||
|
$('div.sliders input').prop('min', min);
|
||||||
|
$('div.sliders input').prop('max', max);
|
||||||
|
|
||||||
// trigger change event so values are sent to mcu
|
// trigger change event so values are sent to mcu
|
||||||
$('div.sliders input').change();
|
$('div.sliders input').change();
|
||||||
}
|
});
|
||||||
});
|
|
||||||
|
|
||||||
$('div.notice input[type="number"]').change(function() {
|
|
||||||
var min = parseInt($('div.notice .min').val());
|
|
||||||
var max = parseInt($('div.notice .max').val());
|
|
||||||
|
|
||||||
|
// enable Motor data pulling
|
||||||
$('div.sliders input').prop('min', min);
|
GUI.interval_add('motor_poll', function() {
|
||||||
$('div.sliders input').prop('max', max);
|
// Request New data
|
||||||
|
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS, false, function() {
|
||||||
// trigger change event so values are sent to mcu
|
send_message(MSP_codes.MSP_MOTOR, MSP_codes.MSP_MOTOR, false, function() {
|
||||||
$('div.sliders input').change();
|
send_message(MSP_codes.MSP_SERVO, MSP_codes.MSP_SERVO, false, function() {
|
||||||
});
|
// Update UI
|
||||||
|
|
||||||
// enable Motor data pulling
|
|
||||||
GUI.interval_add('motor_poll', function() {
|
|
||||||
// Request New data
|
|
||||||
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS, false, function() {
|
|
||||||
send_message(MSP_codes.MSP_MOTOR, MSP_codes.MSP_MOTOR, false, function() {
|
|
||||||
send_message(MSP_codes.MSP_SERVO, MSP_codes.MSP_SERVO, false, function() {
|
|
||||||
// Update UI
|
|
||||||
|
|
||||||
var block_height = $('div.m-block:first').height();
|
|
||||||
|
|
||||||
for (var i = 0; i < MOTOR_DATA.length; i++) {
|
|
||||||
MOTOR_DATA[i] -= 1000;
|
|
||||||
var margin_top = block_height - (MOTOR_DATA[i] * (block_height / 1000));
|
|
||||||
var height = (MOTOR_DATA[i] * (block_height / 1000));
|
|
||||||
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)'});
|
var block_height = $('div.m-block:first').height();
|
||||||
}
|
|
||||||
|
|
||||||
for (var i = 0; i < SERVO_DATA.length; i++) {
|
|
||||||
SERVO_DATA[i] -= 1000;
|
|
||||||
var margin_top = block_height - (SERVO_DATA[i] * (block_height / 1000));
|
|
||||||
var height = (SERVO_DATA[i] * (block_height / 1000));
|
|
||||||
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)'});
|
for (var i = 0; i < MOTOR_DATA.length; i++) {
|
||||||
}
|
MOTOR_DATA[i] -= 1000;
|
||||||
|
var margin_top = block_height - (MOTOR_DATA[i] * (block_height / 1000));
|
||||||
|
var height = (MOTOR_DATA[i] * (block_height / 1000));
|
||||||
|
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)'});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < SERVO_DATA.length; i++) {
|
||||||
|
SERVO_DATA[i] -= 1000;
|
||||||
|
var margin_top = block_height - (SERVO_DATA[i] * (block_height / 1000));
|
||||||
|
var height = (SERVO_DATA[i] * (block_height / 1000));
|
||||||
|
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)'});
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}, 50, true);
|
||||||
}, 50, true);
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -1,11 +1,10 @@
|
||||||
function tab_initialize_pid_tuning() {
|
function tab_initialize_pid_tuning() {
|
||||||
ga_tracker.sendAppView('PID Tuning');
|
ga_tracker.sendAppView('PID Tuning');
|
||||||
|
GUI.active_tab = 'pid_tuning';
|
||||||
|
|
||||||
$('#content').load("./tabs/pid_tuning.html", function() {
|
send_message(MSP_codes.MSP_PID, MSP_codes.MSP_PID, false, function() {
|
||||||
GUI.active_tab = 'pid_tuning';
|
send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING, false, function() {
|
||||||
|
$('#content').load("./tabs/pid_tuning.html", function() {
|
||||||
send_message(MSP_codes.MSP_PID, MSP_codes.MSP_PID, false, function() {
|
|
||||||
send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING, false, function() {
|
|
||||||
// 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() {
|
||||||
|
@ -281,8 +280,8 @@ function tab_initialize_pid_tuning() {
|
||||||
// enable data pulling
|
// enable data pulling
|
||||||
GUI.interval_add('pid_data_poll', function() {
|
GUI.interval_add('pid_data_poll', function() {
|
||||||
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
|
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
|
||||||
}, 50);
|
}, 50);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
417
tabs/receiver.js
417
tabs/receiver.js
|
@ -1,224 +1,225 @@
|
||||||
function tab_initialize_receiver() {
|
function tab_initialize_receiver() {
|
||||||
ga_tracker.sendAppView('Receiver Page');
|
ga_tracker.sendAppView('Receiver Page');
|
||||||
|
GUI.active_tab = 'receiver';
|
||||||
|
|
||||||
$('#content').load("./tabs/receiver.html", function() {
|
send_message(MSP_codes.MSP_RC, MSP_codes.MSP_RC, false, function() {
|
||||||
GUI.active_tab = 'receiver';
|
|
||||||
|
|
||||||
send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING, false, function() {
|
send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING, false, function() {
|
||||||
// fill in data from RC_tuning
|
$('#content').load("./tabs/receiver.html", function() {
|
||||||
$('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2));
|
// fill in data from RC_tuning
|
||||||
$('.tunings .throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2));
|
$('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2));
|
||||||
|
$('.tunings .throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2));
|
||||||
|
|
||||||
$('.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));
|
||||||
|
|
||||||
// Setup plot variables and plot it self
|
// Setup plot variables and plot it self
|
||||||
var samples_i = 300;
|
var samples_i = 300;
|
||||||
|
|
||||||
RX_plot_data = new Array(8);
|
RX_plot_data = new Array(8);
|
||||||
for (var i = 0; i < 8; i++) {
|
for (var i = 0; i < 8; i++) {
|
||||||
RX_plot_data[i] = new Array();
|
RX_plot_data[i] = new Array();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var i = 0; i <= 300; i++) {
|
for (var i = 0; i <= 300; i++) {
|
||||||
RX_plot_data[0].push([i, 0]);
|
RX_plot_data[0].push([i, 0]);
|
||||||
RX_plot_data[1].push([i, 0]);
|
RX_plot_data[1].push([i, 0]);
|
||||||
RX_plot_data[2].push([i, 0]);
|
RX_plot_data[2].push([i, 0]);
|
||||||
RX_plot_data[3].push([i, 0]);
|
RX_plot_data[3].push([i, 0]);
|
||||||
RX_plot_data[4].push([i, 0]);
|
RX_plot_data[4].push([i, 0]);
|
||||||
RX_plot_data[5].push([i, 0]);
|
RX_plot_data[5].push([i, 0]);
|
||||||
RX_plot_data[6].push([i, 0]);
|
RX_plot_data[6].push([i, 0]);
|
||||||
RX_plot_data[7].push([i, 0]);
|
RX_plot_data[7].push([i, 0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
e_RX_plot = document.getElementById("RX_plot");
|
e_RX_plot = document.getElementById("RX_plot");
|
||||||
|
|
||||||
RX_plot_options = {
|
RX_plot_options = {
|
||||||
title: "Channel width (us)",
|
title: "Channel width (us)",
|
||||||
shadowSize: 0,
|
shadowSize: 0,
|
||||||
yaxis : {
|
yaxis : {
|
||||||
max: 2200,
|
max: 2200,
|
||||||
min: 800,
|
min: 800,
|
||||||
noTicks: 10
|
noTicks: 10
|
||||||
},
|
},
|
||||||
xaxis : {
|
xaxis : {
|
||||||
//noTicks = 0
|
//noTicks = 0
|
||||||
},
|
},
|
||||||
grid : {
|
grid : {
|
||||||
backgroundColor: "#FFFFFF"
|
backgroundColor: "#FFFFFF"
|
||||||
},
|
},
|
||||||
legend : {
|
legend : {
|
||||||
position: "we",
|
position: "we",
|
||||||
backgroundOpacity: 0
|
backgroundOpacity: 0
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 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());
|
||||||
|
|
||||||
var throttle_curve = $('.throttle_curve canvas').get(0);
|
var throttle_curve = $('.throttle_curve canvas').get(0);
|
||||||
var context = throttle_curve.getContext("2d");
|
var context = throttle_curve.getContext("2d");
|
||||||
context.clearRect(0, 0, 220, 58);
|
context.clearRect(0, 0, 220, 58);
|
||||||
|
|
||||||
// math magic by englishman
|
// math magic by englishman
|
||||||
var midx = 220 * mid;
|
var midx = 220 * mid;
|
||||||
var midxl = midx * .5;
|
var midxl = midx * .5;
|
||||||
var midxr = (((220 - midx) * .5) + midx);
|
var midxr = (((220 - midx) * .5) + midx);
|
||||||
var midy = 58 - (midx * (58 / 220));
|
var midy = 58 - (midx * (58 / 220));
|
||||||
var midyl = 58 - ((58 - midy) * .5 *(expo + 1));
|
var midyl = 58 - ((58 - midy) * .5 *(expo + 1));
|
||||||
var midyr = (midy / 2) * (expo + 1);
|
var midyr = (midy / 2) * (expo + 1);
|
||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.moveTo(0, 58);
|
context.moveTo(0, 58);
|
||||||
context.quadraticCurveTo(midxl, midyl, midx, midy);
|
context.quadraticCurveTo(midxl, midyl, midx, midy);
|
||||||
context.moveTo(midx, midy);
|
context.moveTo(midx, midy);
|
||||||
context.quadraticCurveTo(midxr, midyr, 220, 0);
|
context.quadraticCurveTo(midxr, midyr, 220, 0);
|
||||||
|
|
||||||
context.lineWidth = 2;
|
context.lineWidth = 2;
|
||||||
context.stroke();
|
context.stroke();
|
||||||
}, 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());
|
||||||
|
|
||||||
var pitch_roll_curve = $('.pitch_roll_curve canvas').get(0);
|
var pitch_roll_curve = $('.pitch_roll_curve canvas').get(0);
|
||||||
var context = pitch_roll_curve.getContext("2d");
|
var context = pitch_roll_curve.getContext("2d");
|
||||||
context.clearRect(0, 0, 220, 58);
|
context.clearRect(0, 0, 220, 58);
|
||||||
|
|
||||||
// math magic by englishman
|
// math magic by englishman
|
||||||
var ratey = 58 * rate;
|
var ratey = 58 * rate;
|
||||||
|
|
||||||
context.beginPath();
|
context.beginPath();
|
||||||
context.moveTo(0, 58);
|
context.moveTo(0, 58);
|
||||||
context.quadraticCurveTo(110, 58 - ((ratey / 2) * (1 - expo)), 220, 58 - ratey);
|
context.quadraticCurveTo(110, 58 - ((ratey / 2) * (1 - expo)), 220, 58 - ratey);
|
||||||
context.lineWidth = 2;
|
context.lineWidth = 2;
|
||||||
context.stroke();
|
context.stroke();
|
||||||
}, 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() {
|
||||||
send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING, false, function() {
|
send_message(MSP_codes.MSP_RC_TUNING, MSP_codes.MSP_RC_TUNING, false, function() {
|
||||||
// fill in data from RC_tuning
|
// fill in data from RC_tuning
|
||||||
$('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2));
|
$('.tunings .throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2));
|
||||||
$('.tunings .throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2));
|
$('.tunings .throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2));
|
||||||
|
|
||||||
$('.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));
|
||||||
|
|
||||||
// update visual representation
|
// update visual representation
|
||||||
$('.tunings .throttle input').change();
|
$('.tunings .throttle input').change();
|
||||||
$('.tunings .rate input').change();
|
$('.tunings .rate input').change();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
$('a.update').click(function() {
|
|
||||||
// catch RC_tuning changes
|
|
||||||
RC_tuning.throttle_MID = parseFloat($('.tunings .throttle input[name="mid"]').val());
|
|
||||||
RC_tuning.throttle_EXPO = parseFloat($('.tunings .throttle input[name="expo"]').val());
|
|
||||||
|
|
||||||
RC_tuning.RC_RATE = parseFloat($('.tunings .rate input[name="rate"]').val());
|
$('a.update').click(function() {
|
||||||
RC_tuning.RC_EXPO = parseFloat($('.tunings .rate input[name="expo"]').val());
|
// catch RC_tuning changes
|
||||||
|
RC_tuning.throttle_MID = parseFloat($('.tunings .throttle input[name="mid"]').val());
|
||||||
var RC_tuning_buffer_out = new Array();
|
RC_tuning.throttle_EXPO = parseFloat($('.tunings .throttle input[name="expo"]').val());
|
||||||
RC_tuning_buffer_out[0] = parseInt(RC_tuning.RC_RATE * 100);
|
|
||||||
RC_tuning_buffer_out[1] = parseInt(RC_tuning.RC_EXPO * 100);
|
RC_tuning.RC_RATE = parseFloat($('.tunings .rate input[name="rate"]').val());
|
||||||
RC_tuning_buffer_out[2] = parseInt(RC_tuning.roll_pitch_rate * 100);
|
RC_tuning.RC_EXPO = parseFloat($('.tunings .rate input[name="expo"]').val());
|
||||||
RC_tuning_buffer_out[3] = parseInt(RC_tuning.yaw_rate * 100);
|
|
||||||
RC_tuning_buffer_out[4] = parseInt(RC_tuning.dynamic_THR_PID * 100);
|
var RC_tuning_buffer_out = new Array();
|
||||||
RC_tuning_buffer_out[5] = parseInt(RC_tuning.throttle_MID * 100);
|
RC_tuning_buffer_out[0] = parseInt(RC_tuning.RC_RATE * 100);
|
||||||
RC_tuning_buffer_out[6] = parseInt(RC_tuning.throttle_EXPO * 100);
|
RC_tuning_buffer_out[1] = parseInt(RC_tuning.RC_EXPO * 100);
|
||||||
|
RC_tuning_buffer_out[2] = parseInt(RC_tuning.roll_pitch_rate * 100);
|
||||||
// Send over the RC_tuning changes
|
RC_tuning_buffer_out[3] = parseInt(RC_tuning.yaw_rate * 100);
|
||||||
send_message(MSP_codes.MSP_SET_RC_TUNING, RC_tuning_buffer_out);
|
RC_tuning_buffer_out[4] = parseInt(RC_tuning.dynamic_THR_PID * 100);
|
||||||
|
RC_tuning_buffer_out[5] = parseInt(RC_tuning.throttle_MID * 100);
|
||||||
|
RC_tuning_buffer_out[6] = parseInt(RC_tuning.throttle_EXPO * 100);
|
||||||
|
|
||||||
|
// Send over the RC_tuning changes
|
||||||
|
send_message(MSP_codes.MSP_SET_RC_TUNING, RC_tuning_buffer_out);
|
||||||
|
|
||||||
// Save changes to EEPROM
|
// Save changes to EEPROM
|
||||||
send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE, false, function() {
|
send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE, false, function() {
|
||||||
GUI.log('EEPROM <span style="color: green">saved</span>');
|
GUI.log('EEPROM <span style="color: green">saved</span>');
|
||||||
|
|
||||||
var element = $('a.update');
|
var element = $('a.update');
|
||||||
element.addClass('success');
|
element.addClass('success');
|
||||||
|
|
||||||
GUI.timeout_add('success_highlight', function() {
|
GUI.timeout_add('success_highlight', function() {
|
||||||
element.removeClass('success');
|
element.removeClass('success');
|
||||||
}, 2000);
|
}, 2000);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// enable RC data pulling
|
|
||||||
GUI.interval_add('receiver_poll', function() {
|
|
||||||
// Update UI with latest data
|
|
||||||
$('.tab-receiver meter:eq(0)').val(RC.throttle);
|
|
||||||
$('.tab-receiver .value:eq(0)').html(RC.throttle);
|
|
||||||
|
|
||||||
$('.tab-receiver meter:eq(1)').val(RC.pitch);
|
// enable RC data pulling
|
||||||
$('.tab-receiver .value:eq(1)').html(RC.pitch);
|
GUI.interval_add('receiver_poll', function() {
|
||||||
|
// Update UI with latest data
|
||||||
$('.tab-receiver meter:eq(2)').val(RC.roll);
|
$('.tab-receiver meter:eq(0)').val(RC.throttle);
|
||||||
$('.tab-receiver .value:eq(2)').html(RC.roll);
|
$('.tab-receiver .value:eq(0)').html(RC.throttle);
|
||||||
|
|
||||||
$('.tab-receiver meter:eq(3)').val(RC.yaw);
|
|
||||||
$('.tab-receiver .value:eq(3)').html(RC.yaw);
|
|
||||||
|
|
||||||
|
|
||||||
$('.tab-receiver meter:eq(4)').val(RC.AUX1);
|
|
||||||
$('.tab-receiver .value:eq(4)').html(RC.AUX1);
|
|
||||||
|
|
||||||
$('.tab-receiver meter:eq(5)').val(RC.AUX2);
|
|
||||||
$('.tab-receiver .value:eq(5)').html(RC.AUX2);
|
|
||||||
|
|
||||||
$('.tab-receiver meter:eq(6)').val(RC.AUX3);
|
|
||||||
$('.tab-receiver .value:eq(6)').html(RC.AUX3);
|
|
||||||
|
|
||||||
$('.tab-receiver meter:eq(7)').val(RC.AUX4);
|
|
||||||
$('.tab-receiver .value:eq(7)').html(RC.AUX4);
|
|
||||||
|
|
||||||
// push latest data to the main array
|
|
||||||
RX_plot_data[0].push([samples_i, RC.throttle]);
|
|
||||||
RX_plot_data[1].push([samples_i, RC.pitch]);
|
|
||||||
RX_plot_data[2].push([samples_i, RC.roll]);
|
|
||||||
RX_plot_data[3].push([samples_i, RC.yaw]);
|
|
||||||
RX_plot_data[4].push([samples_i, RC.AUX1]);
|
|
||||||
RX_plot_data[5].push([samples_i, RC.AUX2]);
|
|
||||||
RX_plot_data[6].push([samples_i, RC.AUX3]);
|
|
||||||
RX_plot_data[7].push([samples_i, RC.AUX4]);
|
|
||||||
|
|
||||||
// Remove old data from array
|
|
||||||
while (RX_plot_data[0].length > 300) {
|
|
||||||
RX_plot_data[0].shift();
|
|
||||||
RX_plot_data[1].shift();
|
|
||||||
RX_plot_data[2].shift();
|
|
||||||
RX_plot_data[3].shift();
|
|
||||||
RX_plot_data[4].shift();
|
|
||||||
RX_plot_data[5].shift();
|
|
||||||
RX_plot_data[6].shift();
|
|
||||||
RX_plot_data[7].shift();
|
|
||||||
};
|
|
||||||
|
|
||||||
// redraw plot
|
|
||||||
Flotr.draw(e_RX_plot, [
|
|
||||||
{data: RX_plot_data[0], label: "THROTTLE"},
|
|
||||||
{data: RX_plot_data[1], label: "PITCH"},
|
|
||||||
{data: RX_plot_data[2], label: "ROLL"},
|
|
||||||
{data: RX_plot_data[3], label: "YAW"},
|
|
||||||
{data: RX_plot_data[4], label: "AUX1"},
|
|
||||||
{data: RX_plot_data[5], label: "AUX2"},
|
|
||||||
{data: RX_plot_data[6], label: "AUX3"},
|
|
||||||
{data: RX_plot_data[7], label: "AUX4"} ], RX_plot_options);
|
|
||||||
|
|
||||||
samples_i++;
|
$('.tab-receiver meter:eq(1)').val(RC.pitch);
|
||||||
|
$('.tab-receiver .value:eq(1)').html(RC.pitch);
|
||||||
// Request new data
|
|
||||||
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
|
$('.tab-receiver meter:eq(2)').val(RC.roll);
|
||||||
send_message(MSP_codes.MSP_RC, MSP_codes.MSP_RC);
|
$('.tab-receiver .value:eq(2)').html(RC.roll);
|
||||||
}, 50, true);
|
|
||||||
|
$('.tab-receiver meter:eq(3)').val(RC.yaw);
|
||||||
|
$('.tab-receiver .value:eq(3)').html(RC.yaw);
|
||||||
|
|
||||||
|
|
||||||
|
$('.tab-receiver meter:eq(4)').val(RC.AUX1);
|
||||||
|
$('.tab-receiver .value:eq(4)').html(RC.AUX1);
|
||||||
|
|
||||||
|
$('.tab-receiver meter:eq(5)').val(RC.AUX2);
|
||||||
|
$('.tab-receiver .value:eq(5)').html(RC.AUX2);
|
||||||
|
|
||||||
|
$('.tab-receiver meter:eq(6)').val(RC.AUX3);
|
||||||
|
$('.tab-receiver .value:eq(6)').html(RC.AUX3);
|
||||||
|
|
||||||
|
$('.tab-receiver meter:eq(7)').val(RC.AUX4);
|
||||||
|
$('.tab-receiver .value:eq(7)').html(RC.AUX4);
|
||||||
|
|
||||||
|
// push latest data to the main array
|
||||||
|
RX_plot_data[0].push([samples_i, RC.throttle]);
|
||||||
|
RX_plot_data[1].push([samples_i, RC.pitch]);
|
||||||
|
RX_plot_data[2].push([samples_i, RC.roll]);
|
||||||
|
RX_plot_data[3].push([samples_i, RC.yaw]);
|
||||||
|
RX_plot_data[4].push([samples_i, RC.AUX1]);
|
||||||
|
RX_plot_data[5].push([samples_i, RC.AUX2]);
|
||||||
|
RX_plot_data[6].push([samples_i, RC.AUX3]);
|
||||||
|
RX_plot_data[7].push([samples_i, RC.AUX4]);
|
||||||
|
|
||||||
|
// Remove old data from array
|
||||||
|
while (RX_plot_data[0].length > 300) {
|
||||||
|
RX_plot_data[0].shift();
|
||||||
|
RX_plot_data[1].shift();
|
||||||
|
RX_plot_data[2].shift();
|
||||||
|
RX_plot_data[3].shift();
|
||||||
|
RX_plot_data[4].shift();
|
||||||
|
RX_plot_data[5].shift();
|
||||||
|
RX_plot_data[6].shift();
|
||||||
|
RX_plot_data[7].shift();
|
||||||
|
};
|
||||||
|
|
||||||
|
// redraw plot
|
||||||
|
Flotr.draw(e_RX_plot, [
|
||||||
|
{data: RX_plot_data[0], label: "THROTTLE"},
|
||||||
|
{data: RX_plot_data[1], label: "PITCH"},
|
||||||
|
{data: RX_plot_data[2], label: "ROLL"},
|
||||||
|
{data: RX_plot_data[3], label: "YAW"},
|
||||||
|
{data: RX_plot_data[4], label: "AUX1"},
|
||||||
|
{data: RX_plot_data[5], label: "AUX2"},
|
||||||
|
{data: RX_plot_data[6], label: "AUX3"},
|
||||||
|
{data: RX_plot_data[7], label: "AUX4"} ], RX_plot_options);
|
||||||
|
|
||||||
|
samples_i++;
|
||||||
|
|
||||||
|
// Request new data
|
||||||
|
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
|
||||||
|
send_message(MSP_codes.MSP_RC, MSP_codes.MSP_RC);
|
||||||
|
}, 50, true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -1,9 +1,8 @@
|
||||||
function tab_initialize_sensors() {
|
function tab_initialize_sensors() {
|
||||||
ga_tracker.sendAppView('Sensor Page');
|
ga_tracker.sendAppView('Sensor Page');
|
||||||
|
GUI.active_tab = 'sensors';
|
||||||
|
|
||||||
$('#content').load("./tabs/sensors.html", function() {
|
$('#content').load("./tabs/sensors.html", function() {
|
||||||
GUI.active_tab = 'sensors';
|
|
||||||
|
|
||||||
// Setup variables
|
// Setup variables
|
||||||
samples_gyro_i = 300;
|
samples_gyro_i = 300;
|
||||||
samples_accel_i = 300;
|
samples_accel_i = 300;
|
||||||
|
|
|
@ -7,20 +7,19 @@
|
||||||
|
|
||||||
function tab_initialize_servos() {
|
function tab_initialize_servos() {
|
||||||
ga_tracker.sendAppView('Servos');
|
ga_tracker.sendAppView('Servos');
|
||||||
|
GUI.active_tab = 'servos';
|
||||||
|
|
||||||
$('#content').load("./tabs/servos.html", function() {
|
// request current Servos Config
|
||||||
GUI.active_tab = 'servos';
|
send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT, false, function() {
|
||||||
|
send_message(MSP_codes.MSP_SERVO_CONF, MSP_codes.MSP_SERVO_CONF, false, function() {
|
||||||
var model = $('div.tab-servos strong.model');
|
send_message(MSP_codes.MSP_BOXNAMES, MSP_codes.MSP_BOXNAMES, false, function() {
|
||||||
var supported_models = [1, 4, 5, 8, 14, 20, 21];
|
$('#content').load("./tabs/servos.html", function() {
|
||||||
|
|
||||||
// request current Servos Config
|
|
||||||
send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT, false, function() {
|
|
||||||
send_message(MSP_codes.MSP_SERVO_CONF, MSP_codes.MSP_SERVO_CONF, false, function() {
|
|
||||||
send_message(MSP_codes.MSP_BOXNAMES, MSP_codes.MSP_BOXNAMES, false, function() {
|
|
||||||
// drop previous table
|
// drop previous table
|
||||||
$('div.tab-servos table.fields tr:not(:first)').remove();
|
$('div.tab-servos table.fields tr:not(:first)').remove();
|
||||||
|
|
||||||
|
var model = $('div.tab-servos strong.model');
|
||||||
|
var supported_models = [1, 4, 5, 8, 14, 20, 21];
|
||||||
|
|
||||||
switch (CONFIG.multiType) {
|
switch (CONFIG.multiType) {
|
||||||
case 1: // TRI
|
case 1: // TRI
|
||||||
// looking ok so far
|
// looking ok so far
|
||||||
|
@ -92,7 +91,7 @@ function tab_initialize_servos() {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
model.html('Doesn\'t support servos');
|
model.html("This model doesn't support servos");
|
||||||
|
|
||||||
// implementation of feature servo_tilt
|
// implementation of feature servo_tilt
|
||||||
if (AUX_CONFIG.indexOf('CAMSTAB') > -1 || AUX_CONFIG.indexOf('CAMTRIG') > -1) {
|
if (AUX_CONFIG.indexOf('CAMSTAB') > -1 || AUX_CONFIG.indexOf('CAMTRIG') > -1) {
|
||||||
|
@ -113,21 +112,21 @@ function tab_initialize_servos() {
|
||||||
GUI.timeout_add('servos_update', servos_update, 10);
|
GUI.timeout_add('servos_update', servos_update, 10);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('a.update').click(function() {
|
||||||
|
// 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) {
|
||||||
|
servos_update(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// enable data pulling
|
||||||
|
GUI.interval_add('servos_data_poll', function() {
|
||||||
|
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
|
||||||
|
}, 50);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('a.update').click(function() {
|
|
||||||
// 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) {
|
|
||||||
servos_update(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// enable data pulling
|
|
||||||
GUI.interval_add('servos_data_poll', function() {
|
|
||||||
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
|
|
||||||
}, 50);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue