mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-21 07:15:18 +03:00
servos tab bugfix
This commit is contained in:
parent
2579b7d394
commit
47ef16b575
2 changed files with 111 additions and 109 deletions
1
main.js
1
main.js
|
@ -71,7 +71,6 @@ $(document).ready(function() {
|
|||
break;
|
||||
case 'tab_servos':
|
||||
tab_initialize_servos();
|
||||
$('#content').load("./tabs/servos.html", tab_initialize_servos);
|
||||
break;
|
||||
case 'tab_gps':
|
||||
tab_initialize_gps();
|
||||
|
|
219
tabs/servos.js
219
tabs/servos.js
|
@ -7,125 +7,128 @@
|
|||
|
||||
function tab_initialize_servos() {
|
||||
ga_tracker.sendAppView('Servos');
|
||||
GUI.active_tab = 'servos';
|
||||
|
||||
var model = $('div.tab-servos strong.model');
|
||||
var supported_models = [1, 4, 5, 8, 14, 20, 21];
|
||||
|
||||
// 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
|
||||
$('div.tab-servos table.fields tr:not(:first)').remove();
|
||||
|
||||
switch (CONFIG.multiType) {
|
||||
case 1: // TRI
|
||||
// looking ok so far
|
||||
model.html('TRI');
|
||||
|
||||
process_directions('YAW', 5, 0);
|
||||
|
||||
process_servos('Yaw Servo', '', 5, false);
|
||||
break;
|
||||
case 4: // BI
|
||||
// looking ok so far
|
||||
model.html('BI');
|
||||
|
||||
process_directions('L YAW', 4, 1);
|
||||
process_directions('R YAW', 5, 1);
|
||||
process_directions('L NICK', 4, 0);
|
||||
process_directions('R NICK', 5, 0);
|
||||
|
||||
process_servos('Left Servo', '', 4, false);
|
||||
process_servos('Right Servo', '', 5, false);
|
||||
break;
|
||||
case 5: // Gimbal
|
||||
// needs to be verified
|
||||
model.html('Gimbal');
|
||||
|
||||
// rate
|
||||
process_servos('Pitch Servo', '', 0, 2);
|
||||
process_servos('Roll Servo', '', 1, 2);
|
||||
break;
|
||||
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
|
||||
$('#content').load("./tabs/servos.html", function() {
|
||||
GUI.active_tab = 'servos';
|
||||
|
||||
var model = $('div.tab-servos strong.model');
|
||||
var supported_models = [1, 4, 5, 8, 14, 20, 21];
|
||||
|
||||
// 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
|
||||
$('div.tab-servos table.fields tr:not(:first)').remove();
|
||||
|
||||
switch (CONFIG.multiType) {
|
||||
case 1: // TRI
|
||||
// looking ok so far
|
||||
model.html('TRI');
|
||||
|
||||
process_directions('YAW', 5, 0);
|
||||
|
||||
process_servos('Yaw Servo', '', 5, false);
|
||||
break;
|
||||
case 4: // BI
|
||||
// looking ok so far
|
||||
model.html('BI');
|
||||
|
||||
process_directions('L YAW', 4, 1);
|
||||
process_directions('R YAW', 5, 1);
|
||||
process_directions('L NICK', 4, 0);
|
||||
process_directions('R NICK', 5, 0);
|
||||
|
||||
process_servos('Left Servo', '', 4, false);
|
||||
process_servos('Right Servo', '', 5, false);
|
||||
break;
|
||||
case 5: // Gimbal
|
||||
// needs to be verified
|
||||
model.html('Gimbal / Tilt Servos');
|
||||
model.html('Gimbal');
|
||||
|
||||
// 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);
|
||||
break;
|
||||
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
|
||||
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() {
|
||||
// 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);
|
||||
}
|
||||
|
||||
function servos_update(save_to_eeprom) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue