mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-23 16:25:22 +03:00
Remove legacy servo configuration which originated from the overloaded
use of the servo 'rate'. All servos are free to be configured regardless of whether the mixer actually uses those servos.
This commit is contained in:
parent
1cb64130cc
commit
687c0f1a84
7 changed files with 76 additions and 224 deletions
|
@ -805,15 +805,13 @@
|
|||
},
|
||||
|
||||
|
||||
"servosModel": {
|
||||
"message": "Model:"
|
||||
"servosFirmwareUpgradeRequired": {
|
||||
"message": "Servos requires firmware >= 1.10.0."
|
||||
},
|
||||
|
||||
"servosChangeDirection": {
|
||||
"message": "Change Direction in TX To Match"
|
||||
},
|
||||
"servosGyroAccelDirection": {
|
||||
"message": "Gyroscope / Accelerometer Direction"
|
||||
},
|
||||
"servosName": {
|
||||
"message": "Name"
|
||||
},
|
||||
|
@ -826,8 +824,8 @@
|
|||
"servosMax": {
|
||||
"message": "MAX"
|
||||
},
|
||||
"servosDirection": {
|
||||
"message": "Direction"
|
||||
"servosDirectionAndRate": {
|
||||
"message": "Direction and rate"
|
||||
},
|
||||
"servosLiveMode": {
|
||||
"message": "Enable Live mode:"
|
||||
|
@ -835,9 +833,6 @@
|
|||
"servosButtonSave": {
|
||||
"message": "Save"
|
||||
},
|
||||
"servosModelNoSupport": {
|
||||
"message": "This model doesn't support servos"
|
||||
},
|
||||
"servosNormal": {
|
||||
"message": "Normal"
|
||||
},
|
||||
|
|
|
@ -448,11 +448,18 @@ function configuration_restore(callback) {
|
|||
configuration.profiles[profileIndex].ServoConfig.pop();
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < configuration.profiles[profileIndex].ServoConfig.length; i++) {
|
||||
var servoConfig = profiles[profileIndex].ServoConfig;
|
||||
|
||||
servoConfig[i].angleAtMin = 90;
|
||||
servoConfig[i].angleAtMax = 90;
|
||||
servoConfig[i].reversedInputSources = 0;
|
||||
|
||||
// set the rate to 0 if an invalid value is detected.
|
||||
if (servoConfig[i].rate < -100 || servoConfig[i].rate > 100) {
|
||||
servoConfig[i].rate = 0;
|
||||
}
|
||||
}
|
||||
|
||||
configuration.profiles[profileIndex].ServoRules = [];
|
||||
|
|
|
@ -477,7 +477,11 @@ var MSP = {
|
|||
'min': data.getInt16(i + 0, 1),
|
||||
'max': data.getInt16(i + 2, 1),
|
||||
'middle': data.getInt16(i + 4, 1),
|
||||
'rate': data.getInt8(i + 6)
|
||||
'rate': data.getInt8(i + 6),
|
||||
'angleAtMin': 90,
|
||||
'angleAtMax': 90,
|
||||
'indexOfChannelToForward': undefined,
|
||||
'reversedInputSources': 0
|
||||
};
|
||||
|
||||
SERVO_CONFIG.push(arr);
|
||||
|
|
|
@ -71,13 +71,13 @@
|
|||
border: 1px dashed silver;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.require-support {
|
||||
.tab-ports .require-support {
|
||||
display:none;
|
||||
}
|
||||
.tab-ports.supported .require-support {
|
||||
display:block;
|
||||
}
|
||||
.require-upgrade {
|
||||
.tab-ports .require-upgrade {
|
||||
display:block;
|
||||
}
|
||||
.tab-ports.supported .require-upgrade {
|
||||
|
|
|
@ -3,10 +3,6 @@
|
|||
.tab-servos input[type="number"]::-webkit-inner-spin-button {
|
||||
border: 0;
|
||||
}
|
||||
.tab-servos .supported_wrapper,
|
||||
.tab-servos .direction_wrapper {
|
||||
display: none;
|
||||
}
|
||||
.tab-servos .title {
|
||||
margin-top: 10px;
|
||||
|
||||
|
@ -130,3 +126,16 @@
|
|||
.tab-servos .update:hover {
|
||||
background-color: #dedcdc;
|
||||
}
|
||||
|
||||
.tab-servos .require-support {
|
||||
display:none;
|
||||
}
|
||||
.tab-servos.supported .require-support {
|
||||
display:block;
|
||||
}
|
||||
.tab-servos .require-upgrade {
|
||||
display:block;
|
||||
}
|
||||
.tab-servos.supported .require-upgrade {
|
||||
display:none;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<div class="tab-servos">
|
||||
<span i18n="servosModel"></span> <strong class="model"></strong>
|
||||
<div class="supported_wrapper">
|
||||
<div class="require-support">
|
||||
<div class="title" i18n="servosChangeDirection"></div>
|
||||
<table class="fields">
|
||||
<tr class="main">
|
||||
|
@ -14,15 +13,6 @@
|
|||
<th style="width: 40px">CH4</th>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="direction_wrapper">
|
||||
<div class="title" style="width: 258px" i18n="servosGyroAccelDirection"></div>
|
||||
<table class="directions" style="width: 260px">
|
||||
<tr class="main">
|
||||
<th style="width: 200px" i18n="servosName"></th>
|
||||
<th i18n="servosDirection"></th>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="live">
|
||||
<span i18n="servosLiveMode"></span> <input type="checkbox" />
|
||||
</div>
|
||||
|
@ -30,4 +20,7 @@
|
|||
<a class="update" href="#" i18n="servosButtonSave"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="note require-upgrade" i18n="servosFirmwareUpgradeRequired">
|
||||
</div>
|
||||
</div>
|
200
tabs/servos.js
200
tabs/servos.js
|
@ -1,9 +1,3 @@
|
|||
/* Please don't take code in this file very seriously !!!
|
||||
|
||||
I was "kinda" forced to write this implementation "this way" because the Servo code implementation
|
||||
from multiwii is so horrible, obstructive and non dynamic, not to mention it doesn't make any sense
|
||||
that there was just no other way around this then hardcoding/implementing each model separately.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
TABS.servos = {};
|
||||
|
@ -47,7 +41,15 @@ TABS.servos.initialize = function (callback) {
|
|||
|
||||
MSP.send_message(MSP_codes.MSP_IDENT, false, false, get_servo_configurations);
|
||||
|
||||
function process_html() {
|
||||
function update_ui() {
|
||||
|
||||
if (semver.lt(CONFIG.apiVersion, "1.12.0")) {
|
||||
|
||||
$(".tab-servos").removeClass("supported");
|
||||
return;
|
||||
}
|
||||
|
||||
$(".tab-servos").addClass("supported");
|
||||
|
||||
var servoCheckbox = '';
|
||||
var servoHeader = '';
|
||||
|
@ -56,7 +58,7 @@ TABS.servos.initialize = function (callback) {
|
|||
<th >A' + (i+1) + '</th>\
|
||||
';
|
||||
}
|
||||
servoHeader = servoHeader + '<th style="width: 200px" i18n="servosDirection"></th>';
|
||||
servoHeader = servoHeader + '<th style="width: 200px" i18n="servosDirectionAndRate"></th>';
|
||||
|
||||
for (var i = 0; i < RC.active_channels; i++) {
|
||||
servoCheckbox = servoCheckbox + '\
|
||||
|
@ -64,40 +66,12 @@ TABS.servos.initialize = function (callback) {
|
|||
';
|
||||
}
|
||||
|
||||
|
||||
|
||||
$('div.tab-servos table.fields tr.main').append(servoHeader);
|
||||
|
||||
function process_directions(name, obj, bitpos) {
|
||||
$('div.direction_wrapper').show();
|
||||
|
||||
var val;
|
||||
|
||||
$('div.tab-servos table.directions').append('\
|
||||
<tr>\
|
||||
<td class="name" style="text-align: center">' + name + '</td>\
|
||||
<td class="direction" style="text-align: right">\
|
||||
<select name="direction">\
|
||||
<option value="0">' + chrome.i18n.getMessage('servosNormal') + '</option>\
|
||||
<option value="1">' + chrome.i18n.getMessage('servosReverse') + '</option>\
|
||||
</select>\
|
||||
</td>\
|
||||
</tr>\
|
||||
');
|
||||
|
||||
if (bit_check(SERVO_CONFIG[obj].rate, bitpos)) val = 1;
|
||||
else val = 0;
|
||||
|
||||
$('div.tab-servos table.directions tr:last select').val(val);
|
||||
$('div.tab-servos table.directions tr:last select').data('info', {'obj': obj, 'bitpos': bitpos});
|
||||
}
|
||||
|
||||
function process_servos(name, alternate, obj, directions) {
|
||||
function process_servos(name, alternate, obj) {
|
||||
|
||||
$('div.supported_wrapper').show();
|
||||
|
||||
|
||||
|
||||
$('div.tab-servos table.fields').append('\
|
||||
<tr> \
|
||||
<td style="text-align: center">' + name + '</td>\
|
||||
|
@ -106,28 +80,14 @@ TABS.servos.initialize = function (callback) {
|
|||
<td class="max"><input type="number" min="1000" max="2000" value="' + SERVO_CONFIG[obj].max +'" /></td>\
|
||||
' + servoCheckbox + '\
|
||||
<td class="direction">\
|
||||
<input class="first" type="checkbox"/><span class="name">' + name + '</span>\
|
||||
<input class="second" type="checkbox"/><span class="alternate">' + alternate + '</span>\
|
||||
</td>\
|
||||
</tr> \
|
||||
');
|
||||
|
||||
|
||||
|
||||
// translate to user-selected language
|
||||
localize();
|
||||
|
||||
if (SERVO_CONFIG[obj].indexOfChannelToForward >= 0) {
|
||||
$('div.tab-servos table.fields tr:last td.channel input').eq(SERVO_CONFIG[obj].indexOfChannelToForward).prop('checked', true);
|
||||
}
|
||||
|
||||
if (directions == true) {
|
||||
$('div.tab-servos table.fields tr:last td.direction input:first').prop('checked', bit_check(SERVO_CONFIG[obj].rate, 0));
|
||||
$('div.tab-servos table.fields tr:last td.direction input:last').prop('checked', bit_check(SERVO_CONFIG[obj].rate, 1));
|
||||
} else if (directions == 2) {
|
||||
// removing checkboxes
|
||||
$('div.tab-servos table.fields tr:last td.direction').html('');
|
||||
|
||||
// adding select box and generating options
|
||||
$('div.tab-servos table.fields tr:last td.direction').append('\
|
||||
<select class="rate" name="rate"></select>\
|
||||
|
@ -141,10 +101,6 @@ TABS.servos.initialize = function (callback) {
|
|||
|
||||
// select current rate
|
||||
select.val(SERVO_CONFIG[obj].rate);
|
||||
} else {
|
||||
// removing checkboxes
|
||||
$('div.tab-servos table.fields tr:last td.direction').html('');
|
||||
}
|
||||
|
||||
$('div.tab-servos table.fields tr:last').data('info', {'obj': obj});
|
||||
|
||||
|
@ -159,17 +115,6 @@ TABS.servos.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function servos_update(save_configuration_to_eeprom) {
|
||||
// update bitfields
|
||||
$('div.tab-servos table.directions tr:not(".main")').each(function () {
|
||||
var info = $('select', this).data('info');
|
||||
var val = parseInt($('select', this).val());
|
||||
|
||||
// in this stage we need to know which bitfield and which bitposition needs to be flipped
|
||||
if (val) SERVO_CONFIG[info.obj].rate = bit_set(SERVO_CONFIG[info.obj].rate, info.bitpos);
|
||||
else SERVO_CONFIG[info.obj].rate = bit_clear(SERVO_CONFIG[info.obj].rate, info.bitpos);
|
||||
});
|
||||
|
||||
// update the rest
|
||||
$('div.tab-servos table.fields tr:not(".main")').each(function () {
|
||||
var info = $(this).data('info');
|
||||
|
||||
|
@ -187,17 +132,8 @@ TABS.servos.initialize = function (callback) {
|
|||
SERVO_CONFIG[info.obj].min = parseInt($('.min input', this).val());
|
||||
SERVO_CONFIG[info.obj].max = parseInt($('.max input', this).val());
|
||||
|
||||
// update rate if direction fields exist
|
||||
if ($('.direction input', this).length) {
|
||||
if ($('.direction input:first', this).is(':checked')) SERVO_CONFIG[info.obj].rate = bit_set(SERVO_CONFIG[info.obj].rate, 0);
|
||||
else SERVO_CONFIG[info.obj].rate = bit_clear(SERVO_CONFIG[info.obj].rate, 0);
|
||||
|
||||
if ($('.direction input:last', this).is(':checked')) SERVO_CONFIG[info.obj].rate = bit_set(SERVO_CONFIG[info.obj].rate, 1);
|
||||
else SERVO_CONFIG[info.obj].rate = bit_clear(SERVO_CONFIG[info.obj].rate, 1);
|
||||
} else if ($('.direction select', this).length) {
|
||||
var val = parseInt($('.direction select', this).val());
|
||||
SERVO_CONFIG[info.obj].rate = val;
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
|
@ -217,111 +153,13 @@ TABS.servos.initialize = function (callback) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
MSP.send_message(MSP_codes.MSP_SET_CHANNEL_FORWARDING, MSP.crunch(MSP_codes.MSP_SET_CHANNEL_FORWARDING), false, function () {
|
||||
MSP.send_message(MSP_codes.MSP_SET_SERVO_CONF, MSP.crunch(MSP_codes.MSP_SET_SERVO_CONF), false, function () {
|
||||
if (save_configuration_to_eeprom) {
|
||||
// Save changes to EEPROM
|
||||
MSP.send_message(MSP_codes.MSP_EEPROM_WRITE, false, false, function () {
|
||||
GUI.log(chrome.i18n.getMessage('servosEepromSave'));
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
// drop previous table
|
||||
$('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, 24, 25];
|
||||
|
||||
switch (CONFIG.multiType) {
|
||||
case 1: // TRI
|
||||
case 25: // CUSTOM_TRI
|
||||
// looking ok so far
|
||||
model.text('TRI');
|
||||
|
||||
process_directions('YAW', 5, 0);
|
||||
|
||||
process_servos('Yaw Servo', '', 5, false);
|
||||
break;
|
||||
case 4: // BI
|
||||
// looking ok so far
|
||||
model.text('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.text('Gimbal');
|
||||
|
||||
// rate
|
||||
process_servos('Pitch Servo', '', 0, 2);
|
||||
process_servos('Roll Servo', '', 1, 2);
|
||||
break;
|
||||
case 8: // Flying Wing
|
||||
// looking ok so far
|
||||
model.text('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
|
||||
case 24: // Custom_Airplane
|
||||
model.text('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.text('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.text('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.text(chrome.i18n.getMessage('servosModelNoSupport'));
|
||||
}
|
||||
|
||||
// implementation of feature servo_tilt
|
||||
if (AUX_CONFIG.indexOf('CAMSTAB') > -1 || AUX_CONFIG.indexOf('CAMTRIG') > -1) {
|
||||
// Gimbal on
|
||||
// needs to be verified
|
||||
|
||||
// rate
|
||||
process_servos('Pitch Servo', '', 0, 2);
|
||||
process_servos('Roll Servo', '', 1, 2);
|
||||
for (var servoIndex = 0; servoIndex < 8; servoIndex++) {
|
||||
process_servos('Servo ' + servoIndex, '', servoIndex, false);
|
||||
}
|
||||
|
||||
// UI hooks for dynamically generated elements
|
||||
|
@ -333,12 +171,18 @@ TABS.servos.initialize = function (callback) {
|
|||
});
|
||||
|
||||
$('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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function process_html() {
|
||||
|
||||
update_ui();
|
||||
|
||||
// translate to user-selected language
|
||||
localize();
|
||||
|
||||
// status data pulled via separate timer with static speed
|
||||
GUI.interval_add('status_pull', function () {
|
||||
MSP.send_message(MSP_codes.MSP_STATUS);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue