using IDENT as first callback to draw initial tab

fixes #10
10.3.x-maintenance
cTn 2013-12-05 10:25:13 +01:00
parent 42101ec791
commit 0344110c2d
2 changed files with 164 additions and 160 deletions

View File

@ -132,6 +132,11 @@ GUI_control.prototype.timeout_kill_all = function() {
// default switch doesn't require callback to be set // default switch doesn't require callback to be set
GUI_control.prototype.tab_switch_cleanup = function(callback) { GUI_control.prototype.tab_switch_cleanup = function(callback) {
switch (this.active_tab) { switch (this.active_tab) {
case 'initial_setup':
GUI.interval_remove('initial_setup_data_pull');
if (callback) callback();
break;
case 'auxiliary_configuration': case 'auxiliary_configuration':
GUI.interval_remove('aux_data_poll'); GUI.interval_remove('aux_data_poll');

View File

@ -4,170 +4,169 @@ function tab_initialize_initial_setup() {
ga_tracker.sendAppView('Initial Setup'); ga_tracker.sendAppView('Initial Setup');
GUI.active_tab = 'initial_setup'; GUI.active_tab = 'initial_setup';
// Fill in the accel trimms from CONFIG object send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT, false, function() {
$('input[name="pitch"]').val(CONFIG.accelerometerTrims[0]); // Fill in the accel trimms from CONFIG object
$('input[name="roll"]').val(CONFIG.accelerometerTrims[1]); $('input[name="pitch"]').val(CONFIG.accelerometerTrims[0]);
$('input[name="roll"]').val(CONFIG.accelerometerTrims[1]);
// Display multiType // Display multiType
var str = ''; var str = '';
switch (CONFIG.multiType) { switch (CONFIG.multiType) {
case 1: // TRI case 1: // TRI
str = 'TRI'; str = 'TRI';
break; break;
case 2: // QUAD + case 2: // QUAD +
str = 'Quad +'; str = 'Quad +';
break; break;
case 3: // QUAD X case 3: // QUAD X
str = 'Quad X'; str = 'Quad X';
break; break;
case 4: // BI case 4: // BI
str = 'BI'; str = 'BI';
break; break;
case 5: // GIMBAL case 5: // GIMBAL
str = 'Gimbal'; str = 'Gimbal';
break; break;
case 6: // Y6 case 6: // Y6
str = 'Y6'; str = 'Y6';
break; break;
case 7: // HEX 6 case 7: // HEX 6
str = 'HEX 6'; str = 'HEX 6';
break; break;
case 8: // FLYING_WING case 8: // FLYING_WING
str = 'Flying Wing'; str = 'Flying Wing';
break; break;
case 9: // Y4 case 9: // Y4
str = 'Y4'; str = 'Y4';
break; break;
case 10: // HEX6 X case 10: // HEX6 X
str = 'HEX6 X'; str = 'HEX6 X';
break; break;
case 11: // OCTO X8 case 11: // OCTO X8
case 12: case 12:
case 13: case 13:
str = 'OCTO X8'; str = 'OCTO X8';
break; break;
case 14: // AIRPLANE case 14: // AIRPLANE
str = 'Airplane'; str = 'Airplane';
break; break;
case 15: // Heli 120 case 15: // Heli 120
str = 'Heli 120'; str = 'Heli 120';
break; break;
case 16: // Heli 90 case 16: // Heli 90
str = 'Heli 90'; str = 'Heli 90';
break; break;
case 17: // Vtail case 17: // Vtail
str = 'Vtail'; str = 'Vtail';
break; break;
case 18: // HEX6 H case 18: // HEX6 H
str = 'HEX6 H'; str = 'HEX6 H';
break; break;
case 19: // PPM to SERVO case 19: // PPM to SERVO
str = 'PPM to SERVO'; str = 'PPM to SERVO';
break; break;
case 20: // Dualcopter case 20: // Dualcopter
str = 'Dualcopter'; str = 'Dualcopter';
break; break;
case 21: // case 21: //
str = 'Singlecopter'; str = 'Singlecopter';
break; 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
// which will in turn result in MSP CRC error (don't be alarmed)
send_message(MSP_codes.MSP_ACC_CALIBRATION, MSP_codes.MSP_ACC_CALIBRATION);
GUI.timeout_add('button_reset', function() {
self.removeClass('calibrating');
}, 1000);
} }
$('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
// which will in turn result in MSP CRC error (don't be alarmed)
send_message(MSP_codes.MSP_ACC_CALIBRATION, MSP_codes.MSP_ACC_CALIBRATION);
GUI.timeout_add('button_reset', function() {
self.removeClass('calibrating');
}, 1000);
}
});
$('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);
GUI.timeout_add('button_reset', function() {
self.removeClass('calibrating');
}, 30000);
}
});
$('a.resetSettings').click(function() {
send_message(MSP_codes.MSP_RESET_CONF, MSP_codes.MSP_RESET_CONF);
});
$('input[name="pitch"], input[name="roll"]').change(function() {
// if any of the fields changed, unlock update button
$('a.update').addClass('active');
});
$('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);
// Save changes to EEPROM
send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE);
// remove the active status
$(this).removeClass('active');
});
// 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 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 + '°');
// Update voltage indicator
$('span.bat-voltage').html(BATTERY.voltage + ' V');
// Request new data
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
send_message(MSP_codes.MSP_ATTITUDE, MSP_codes.MSP_ATTITUDE);
send_message(MSP_codes.MSP_COMP_GPS, MSP_codes.MSP_COMP_GPS);
send_message(MSP_codes.MSP_ANALOG, MSP_codes.MSP_ANALOG);
}, 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);
GUI.timeout_add('button_reset', function() {
self.removeClass('calibrating');
}, 30000);
}
});
$('a.resetSettings').click(function() {
send_message(MSP_codes.MSP_RESET_CONF, MSP_codes.MSP_RESET_CONF);
});
$('input[name="pitch"], input[name="roll"]').change(function() {
// if any of the fields changed, unlock update button
$('a.update').addClass('active');
});
$('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);
// Save changes to EEPROM
send_message(MSP_codes.MSP_EEPROM_WRITE, MSP_codes.MSP_EEPROM_WRITE);
// remove the active status
$(this).removeClass('active');
});
// 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);
// enable data pulling
timers.push(setInterval(data_poll, 50));
}
function data_poll() {
// 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 + '°');
// Update voltage indicator
$('span.bat-voltage').html(BATTERY.voltage + ' V');
// Request new data
send_message(MSP_codes.MSP_STATUS, MSP_codes.MSP_STATUS);
send_message(MSP_codes.MSP_ATTITUDE, MSP_codes.MSP_ATTITUDE);
send_message(MSP_codes.MSP_COMP_GPS, MSP_codes.MSP_COMP_GPS);
send_message(MSP_codes.MSP_ANALOG, MSP_codes.MSP_ANALOG);
} }