mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-17 21:35:33 +03:00
Show/Hide gyro elements by detection
This commit is contained in:
parent
53b18b67e7
commit
14167c6c72
6 changed files with 70 additions and 47 deletions
|
@ -1042,7 +1042,10 @@
|
|||
"configurationSensorGyroToUse": {
|
||||
"message": "GYRO/ACCEL"
|
||||
},
|
||||
"configurationSensorGyroToUseDefaultOption": {
|
||||
"configurationSensorGyroToUseNotFound": {
|
||||
"message": "Warning: No Gyro/Acc found"
|
||||
},
|
||||
"configurationSensorGyroToUseFirst": {
|
||||
"message": "First"
|
||||
},
|
||||
"configurationSensorGyroToUseSecond": {
|
||||
|
|
|
@ -216,7 +216,6 @@
|
|||
.tab-configuration .gyro_alignment_inputs {
|
||||
margin-bottom: 5px;
|
||||
padding-bottom: 5px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
width: 33.3%;
|
||||
float: left;
|
||||
white-space: nowrap;
|
||||
|
@ -492,12 +491,11 @@
|
|||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.tab-configuration .board_align_content,
|
||||
.tab-configuration .gyro_align_content {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.tab-configuration .board_align_content {
|
||||
width: 100%;
|
||||
border-bottom: 1px solid #ddd;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.tab-configuration .sensoralignment span {
|
||||
|
|
|
@ -336,7 +336,7 @@ var FC = {
|
|||
align_gyro: 0,
|
||||
align_acc: 0,
|
||||
align_mag: 0,
|
||||
use_multi_gyro: 0,
|
||||
gyro_detection_flags: 0,
|
||||
gyro_to_use: 0,
|
||||
gyro_1_align: 0,
|
||||
gyro_2_align: 0,
|
||||
|
|
|
@ -538,7 +538,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
SENSOR_ALIGNMENT.align_mag = data.readU8();
|
||||
|
||||
if (semver.gte(CONFIG.apiVersion, '1.41.0')) {
|
||||
SENSOR_ALIGNMENT.use_multi_gyro = data.readU8();
|
||||
SENSOR_ALIGNMENT.gyro_detection_flags = data.readU8();
|
||||
SENSOR_ALIGNMENT.gyro_to_use = data.readU8();
|
||||
SENSOR_ALIGNMENT.gyro_1_align = data.readU8();
|
||||
SENSOR_ALIGNMENT.gyro_2_align = data.readU8();
|
||||
|
|
|
@ -311,26 +311,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
// translate to user-selected language
|
||||
i18n.localizePage();
|
||||
|
||||
var gyro_align_content_e = $('.tab-configuration .gyro_align_content');
|
||||
var legacy_gyro_alignment_e = $('.tab-configuration .legacy_gyro_alignment');
|
||||
var legacy_accel_alignment_e = $('.tab-configuration .legacy_accel_alignment');
|
||||
|
||||
// Hide the new multi gyro element by default
|
||||
gyro_align_content_e.hide();
|
||||
|
||||
// If we are sent USE_MULTI_GYRO flag from the target, show the new element, while hiding the old ones.
|
||||
if (SENSOR_ALIGNMENT.use_multi_gyro == 1) {
|
||||
gyro_align_content_e.show();
|
||||
legacy_gyro_alignment_e.hide();
|
||||
legacy_accel_alignment_e.hide();
|
||||
}
|
||||
|
||||
// As the gyro_to_use does not have a 'DEFAULT' 0th element enum like alingments, the 0th element 'First' is excluded from here.
|
||||
var gyros = [
|
||||
i18n.getMessage('configurationSensorGyroToUseSecond'),
|
||||
i18n.getMessage('configurationSensorGyroToUseBoth')
|
||||
];
|
||||
|
||||
var alignments = [
|
||||
'CW 0°',
|
||||
'CW 90°',
|
||||
|
@ -342,6 +322,10 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
'CW 270° flip'
|
||||
];
|
||||
|
||||
var gyro_align_content_e = $('.tab-configuration .gyro_align_content');
|
||||
var legacy_gyro_alignment_e = $('.tab-configuration .legacy_gyro_alignment');
|
||||
var legacy_accel_alignment_e = $('.tab-configuration .legacy_accel_alignment');
|
||||
|
||||
var orientation_gyro_e = $('select.gyroalign');
|
||||
var orientation_acc_e = $('select.accalign');
|
||||
var orientation_mag_e = $('select.magalign');
|
||||
|
@ -350,28 +334,62 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
var orientation_gyro_1_align_e = $('select.gyro_1_align');
|
||||
var orientation_gyro_2_align_e = $('select.gyro_2_align');
|
||||
|
||||
gyro_align_content_e.hide(); // default value
|
||||
if (semver.lt(CONFIG.apiVersion, "1.15.0")) {
|
||||
$('.tab-configuration .sensoralignment').hide();
|
||||
} else {
|
||||
for (var i = 0; i< gyros.length; i++) {
|
||||
orientation_gyro_to_use_e.append('<option value="' + (i+1) + '">'+ gyros[i] + '</option>');
|
||||
}
|
||||
|
||||
for (var i = 0; i < alignments.length; i++) {
|
||||
orientation_gyro_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
||||
orientation_acc_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
||||
orientation_mag_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
||||
|
||||
orientation_gyro_1_align_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
||||
orientation_gyro_2_align_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
||||
}
|
||||
|
||||
orientation_gyro_e.val(SENSOR_ALIGNMENT.align_gyro);
|
||||
orientation_acc_e.val(SENSOR_ALIGNMENT.align_acc);
|
||||
orientation_mag_e.val(SENSOR_ALIGNMENT.align_mag);
|
||||
|
||||
orientation_gyro_to_use_e.val(SENSOR_ALIGNMENT.gyro_to_use);
|
||||
// Multi gyro config
|
||||
if (semver.gte(CONFIG.apiVersion, "1.41.0")) {
|
||||
|
||||
gyro_align_content_e.show();
|
||||
legacy_gyro_alignment_e.hide();
|
||||
legacy_accel_alignment_e.hide();
|
||||
|
||||
const GYRO_DETECTION_FLAGS = {
|
||||
DETECTED_GYRO_1: (1 << 0),
|
||||
DETECTED_GYRO_2: (1 << 1),
|
||||
DETECTED_DUAL_GYROS: (1 << 7)
|
||||
};
|
||||
|
||||
var detected_gyro_1 = (SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_GYRO_1) != 0;
|
||||
var detected_gyro_2 = (SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_GYRO_2) != 0;
|
||||
var detected_dual_gyros = (SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_DUAL_GYROS) != 0;
|
||||
|
||||
if (detected_gyro_1) {
|
||||
orientation_gyro_to_use_e.append('<option value="0">'+ i18n.getMessage('configurationSensorGyroToUseFirst') + '</option>');
|
||||
}
|
||||
if (detected_gyro_2) {
|
||||
orientation_gyro_to_use_e.append('<option value="1">'+ i18n.getMessage('configurationSensorGyroToUseSecond') + '</option>');
|
||||
}
|
||||
if (detected_dual_gyros) {
|
||||
orientation_gyro_to_use_e.append('<option value="2">'+ i18n.getMessage('configurationSensorGyroToUseBoth') + '</option>');
|
||||
}
|
||||
|
||||
for (var i = 0; i < alignments.length; i++) {
|
||||
orientation_gyro_1_align_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
||||
orientation_gyro_2_align_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
||||
}
|
||||
|
||||
orientation_gyro_to_use_e.val(SENSOR_ALIGNMENT.gyro_to_use);
|
||||
orientation_gyro_1_align_e.val(SENSOR_ALIGNMENT.gyro_1_align);
|
||||
orientation_gyro_2_align_e.val(SENSOR_ALIGNMENT.gyro_2_align);
|
||||
|
||||
$('.gyro_alignment_inputs_first').toggle(detected_gyro_1);
|
||||
$('.gyro_alignment_inputs_second').toggle(detected_gyro_2);
|
||||
$('.gyro_alignment_inputs_selection').toggle(detected_gyro_1 || detected_gyro_2);
|
||||
$('.gyro_alignment_inputs_notfound').toggle(!detected_gyro_1 && !detected_gyro_2);
|
||||
}
|
||||
}
|
||||
|
||||
// ESC protocols
|
||||
|
|
|
@ -272,25 +272,26 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="gyro_align_content">
|
||||
<div class="gyro_alignment_inputs">
|
||||
<div class="gyro_alignment_inputs gyro_alignment_inputs_selection">
|
||||
<label>
|
||||
<select class="gyro_to_use">
|
||||
<option i18n="configurationSensorGyroToUseDefaultOption" value="0"></option>
|
||||
<!-- list generated here -->
|
||||
</select>
|
||||
<span i18n="configurationSensorGyroToUse"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="gyro_alignment_inputs">
|
||||
<div class="gyro_alignment_inputs gyro_alignment_inputs_first">
|
||||
<label>
|
||||
<span>
|
||||
<select class="gyro_1_align">
|
||||
<option i18n="configurationSensorAlignmentDefaultOption" value="0"></option>
|
||||
<!-- list generated here -->
|
||||
</select>
|
||||
<span i18n="configurationSensorAlignmentGyro1"></span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="gyro_alignment_inputs">
|
||||
<div class="gyro_alignment_inputs gyro_alignment_inputs_second">
|
||||
<label>
|
||||
<select class="gyro_2_align">
|
||||
<option i18n="configurationSensorAlignmentDefaultOption" value="0"></option>
|
||||
|
@ -299,6 +300,9 @@
|
|||
<span i18n="configurationSensorAlignmentGyro2"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="gyro_alignment_inputs gyro_alignment_inputs_notfound">
|
||||
<span class="message-negative" i18n="configurationSensorGyroToUseNotFound"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sensor_align_content">
|
||||
<div class="legacy_gyro_alignment select">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue