1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-20 06:45:16 +03:00

servos tab bugfix

This commit is contained in:
cTn 2014-01-26 19:56:03 +01:00
parent 2579b7d394
commit 47ef16b575
2 changed files with 111 additions and 109 deletions

View file

@ -71,7 +71,6 @@ $(document).ready(function() {
break; break;
case 'tab_servos': case 'tab_servos':
tab_initialize_servos(); tab_initialize_servos();
$('#content').load("./tabs/servos.html", tab_initialize_servos);
break; break;
case 'tab_gps': case 'tab_gps':
tab_initialize_gps(); tab_initialize_gps();

View file

@ -7,125 +7,128 @@
function tab_initialize_servos() { function tab_initialize_servos() {
ga_tracker.sendAppView('Servos'); ga_tracker.sendAppView('Servos');
GUI.active_tab = 'servos';
var model = $('div.tab-servos strong.model'); $('#content').load("./tabs/servos.html", function() {
var supported_models = [1, 4, 5, 8, 14, 20, 21]; GUI.active_tab = 'servos';
// request current Servos Config var model = $('div.tab-servos strong.model');
send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT, false, function() { var supported_models = [1, 4, 5, 8, 14, 20, 21];
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
$('div.tab-servos table.fields tr:not(:first)').remove();
switch (CONFIG.multiType) { // request current Servos Config
case 1: // TRI send_message(MSP_codes.MSP_IDENT, MSP_codes.MSP_IDENT, false, function() {
// looking ok so far send_message(MSP_codes.MSP_SERVO_CONF, MSP_codes.MSP_SERVO_CONF, false, function() {
model.html('TRI'); send_message(MSP_codes.MSP_BOXNAMES, MSP_codes.MSP_BOXNAMES, false, function() {
// drop previous table
$('div.tab-servos table.fields tr:not(:first)').remove();
process_directions('YAW', 5, 0); switch (CONFIG.multiType) {
case 1: // TRI
// looking ok so far
model.html('TRI');
process_servos('Yaw Servo', '', 5, false); process_directions('YAW', 5, 0);
break;
case 4: // BI
// looking ok so far
model.html('BI');
process_directions('L YAW', 4, 1); process_servos('Yaw Servo', '', 5, false);
process_directions('R YAW', 5, 1); break;
process_directions('L NICK', 4, 0); case 4: // BI
process_directions('R NICK', 5, 0); // looking ok so far
model.html('BI');
process_servos('Left Servo', '', 4, false); process_directions('L YAW', 4, 1);
process_servos('Right Servo', '', 5, false); process_directions('R YAW', 5, 1);
break; process_directions('L NICK', 4, 0);
case 5: // Gimbal process_directions('R NICK', 5, 0);
// needs to be verified
model.html('Gimbal');
// rate process_servos('Left Servo', '', 4, false);
process_servos('Pitch Servo', '', 0, 2); process_servos('Right Servo', '', 5, false);
process_servos('Roll Servo', '', 1, 2); break;
break; case 5: // Gimbal
case 8: // Flying Wing
// looking ok so far
model.html('Flying Wing');
process_directions('L ROLL', 3, 1);
process_directions('R ROLL', 4, 1);
process_directions('L NICK', 3, 0);
process_directions('R NICK', 4, 0);
process_servos('Left Wing', '', 3, false);
process_servos('Right Wing', '', 4, false);
break;
case 14: // Airplane
model.html('Airplane');
// rate
process_servos('Wing 1', '', 3, 2);
process_servos('Wing 2', '', 4, 2);
process_servos('Rudd', '', 5, 2);
process_servos('Elev', '', 6, 2);
break;
case 20: // Dualcopter
// looking ok so far
model.html('Dualcopter');
process_directions('PITCH', 4, 0);
process_directions('ROLL', 5, 0);
process_servos('Roll', '', 5, false);
process_servos('Nick', '', 4, false);
break;
case 21: // Singlecopter
// looking ok so far
model.html('Singlecopter');
process_servos('Right', 'R YAW', 3, true);
process_servos('Left', 'L YAW', 4, true);
process_servos('Front', 'F YAW', 5, true);
process_servos('Rear', 'YAW', 6, true);
break;
default:
model.html('Doesn\'t support servos');
// implementation of feature servo_tilt
if (AUX_CONFIG.indexOf('CAMSTAB') > -1 || AUX_CONFIG.indexOf('CAMTRIG') > -1) {
// Gimbal on
// needs to be verified // needs to be verified
model.html('Gimbal / Tilt Servos'); model.html('Gimbal');
// rate // rate
process_servos('Pitch Servo', '', 0, 2); process_servos('Pitch Servo', '', 0, 2);
process_servos('Roll Servo', '', 1, 2); process_servos('Roll Servo', '', 1, 2);
} break;
} case 8: // Flying Wing
// looking ok so far
model.html('Flying Wing');
// UI hooks for dynamically generated elements process_directions('L ROLL', 3, 1);
$('table.directions select, table.directions input, table.fields select, table.fields input').change(function() { process_directions('R ROLL', 4, 1);
if ($('div.live input').is(':checked')) { process_directions('L NICK', 3, 0);
// apply small delay as there seems to be some funky update business going wrong process_directions('R NICK', 4, 0);
GUI.timeout_add('servos_update', servos_update, 10);
process_servos('Left Wing', '', 3, false);
process_servos('Right Wing', '', 4, false);
break;
case 14: // Airplane
model.html('Airplane');
// rate
process_servos('Wing 1', '', 3, 2);
process_servos('Wing 2', '', 4, 2);
process_servos('Rudd', '', 5, 2);
process_servos('Elev', '', 6, 2);
break;
case 20: // Dualcopter
// looking ok so far
model.html('Dualcopter');
process_directions('PITCH', 4, 0);
process_directions('ROLL', 5, 0);
process_servos('Roll', '', 5, false);
process_servos('Nick', '', 4, false);
break;
case 21: // Singlecopter
// looking ok so far
model.html('Singlecopter');
process_servos('Right', 'R YAW', 3, true);
process_servos('Left', 'L YAW', 4, true);
process_servos('Front', 'F YAW', 5, true);
process_servos('Rear', 'YAW', 6, true);
break;
default:
model.html('Doesn\'t support servos');
// implementation of feature servo_tilt
if (AUX_CONFIG.indexOf('CAMSTAB') > -1 || AUX_CONFIG.indexOf('CAMTRIG') > -1) {
// Gimbal on
// needs to be verified
model.html('Gimbal / Tilt Servos');
// rate
process_servos('Pitch Servo', '', 0, 2);
process_servos('Roll Servo', '', 1, 2);
}
} }
// UI hooks for dynamically generated elements
$('table.directions select, table.directions input, table.fields select, table.fields input').change(function() {
if ($('div.live input').is(':checked')) {
// apply small delay as there seems to be some funky update business going wrong
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);
} }
}); });
// enable data pulling // enable data pulling
GUI.interval_add('servos_data_poll', function() { GUI.interval_add('servos_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);
});
} }
function servos_update(save_to_eeprom) { function servos_update(save_to_eeprom) {