Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1039,6 +1039,24 @@
"configurationSensorAlignmentGyro": {
"message": "GYRO Alignment"
},
"configurationSensorGyroToUse": {
"message": "GYRO/ACCEL"
},
"configurationSensorGyroToUseDefaultOption": {
"message": "First"
},
"configurationSensorGyroToUseSecond": {
"message": "Second"
},
"configurationSensorGyroToUseBoth": {
"message": "Both"
},
"configurationSensorAlignmentGyro1": {
"message": "First GYRO"
},
"configurationSensorAlignmentGyro2": {
"message": "Second GYRO"
},
"configurationSensorAlignmentAcc": {
"message": "ACCEL Alignment"
},
Expand Down
48 changes: 32 additions & 16 deletions src/css/tabs/configuration.css
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,27 @@
border-bottom: 1px solid #ddd;
width: 100%;
float: left;
}

.tab-configuration .board_align_inputs,
.tab-configuration .gyro_alignment_inputs {
margin-bottom: 5px;
padding-bottom: 5px;
border-bottom: 1px solid #ddd;
width: 33.3%;
float: left;
white-space: nowrap;
}

.tab-configuration .board_align_inputs input {
width: 3.5em;
}

.tab-configuration .board_align_inputs label,
.tab-configuration .gyro_alignment_inputs label {
display: block;
overflow: hidden;
text-overflow: ellipsis;
}

.tab-configuration .selectProtocol
Expand Down Expand Up @@ -365,39 +386,37 @@
}

.tab-configuration .alignicon {
width: 20px;
height: 20px;
width: 15px;
height: 15px;
float: left;
margin-left: -5px;
margin-left: -1px;
margin-right: 3px;
}

.tab-configuration .pitch {
background-image: url(../../images/icons/cf_icon_pitch.svg);
background-repeat: no-repeat;
background-size: 20px;
background-position: center;
}

.tab-configuration .yaw {
background-image: url(../../images/icons/cf_icon_yaw.svg);
background-repeat: no-repeat;
background-size: 20px;
background-position: center;
}

.tab-configuration .roll {
background-image: url(../../images/icons/cf_icon_roll.svg);
background-repeat: no-repeat;
background-size: 20px;
background-position: center;
}

.tab-configuration .board select {
/*float: left;*/
width: 45%;
float: left;
width: fit-content;
max-width: 50%;
height: 20px;
margin: 0 0px 2px 0;
margin-right: 5px;
border: 1px solid silver;
border-radius:3px;
}
Expand Down Expand Up @@ -473,19 +492,16 @@
margin-top: 3px;
}

.tab-configuration .sensoralignment {
width: 50%;
float: left;
.tab-configuration .gyro_align_content {
width: 100%;
}

.tab-configuration .board_align_content {
width: 50%;
float: left;
width: 100%;
}

.tab-configuration .sensoralignment span {
width: 55%;
float: left;
width: 100%;
}

.tab-configuration .escprotocol {
Expand Down
4 changes: 4 additions & 0 deletions src/js/fc.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ var FC = {
align_gyro: 0,
align_acc: 0,
align_mag: 0,
use_multi_gyro: 0,
gyro_to_use: 0,
gyro_1_align: 0,
gyro_2_align: 0,
};

PID_ADVANCED_CONFIG = {
Expand Down
12 changes: 12 additions & 0 deletions src/js/msp/MSPHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,13 @@ MspHelper.prototype.process_data = function(dataHandler) {
SENSOR_ALIGNMENT.align_gyro = data.readU8();
SENSOR_ALIGNMENT.align_acc = data.readU8();
SENSOR_ALIGNMENT.align_mag = data.readU8();

if (semver.gte(CONFIG.apiVersion, '1.41.0')) {
SENSOR_ALIGNMENT.use_multi_gyro = data.readU8();
SENSOR_ALIGNMENT.gyro_to_use = data.readU8();
SENSOR_ALIGNMENT.gyro_1_align = data.readU8();
SENSOR_ALIGNMENT.gyro_2_align = data.readU8();
}
break;
case MSPCodes.MSP_DISPLAYPORT:
break;
Expand Down Expand Up @@ -1658,6 +1665,11 @@ MspHelper.prototype.crunch = function(code) {
buffer.push8(SENSOR_ALIGNMENT.align_gyro)
.push8(SENSOR_ALIGNMENT.align_acc)
.push8(SENSOR_ALIGNMENT.align_mag);
if (semver.gte(CONFIG.apiVersion, "1.41.0")) {
buffer.push8(SENSOR_ALIGNMENT.gyro_to_use)
.push8(SENSOR_ALIGNMENT.gyro_1_align)
.push8(SENSOR_ALIGNMENT.gyro_2_align);
}
break;
case MSPCodes.MSP_SET_ADVANCED_CONFIG:
buffer.push8(PID_ADVANCED_CONFIG.gyro_sync_denom)
Expand Down
40 changes: 40 additions & 0 deletions src/js/tabs/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,26 @@ 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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe is better to include it in the else of the next if, to let it clear when is hide or shown. But is only an opinion. To me is right in both ways.


// 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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not in accordance with what Betaflight 4.0.0-RC6 is sending for use_multi_gyro.

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°',
Expand All @@ -326,17 +346,32 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
var orientation_acc_e = $('select.accalign');
var orientation_mag_e = $('select.magalign');

var orientation_gyro_to_use_e = $('select.gyro_to_use');
var orientation_gyro_1_align_e = $('select.gyro_1_align');
var orientation_gyro_2_align_e = $('select.gyro_2_align');

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);

orientation_gyro_1_align_e.val(SENSOR_ALIGNMENT.gyro_1_align);
orientation_gyro_2_align_e.val(SENSOR_ALIGNMENT.gyro_2_align);
}

// ESC protocols
Expand Down Expand Up @@ -1023,6 +1058,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
SENSOR_ALIGNMENT.align_gyro = parseInt(orientation_gyro_e.val());
SENSOR_ALIGNMENT.align_acc = parseInt(orientation_acc_e.val());
SENSOR_ALIGNMENT.align_mag = parseInt(orientation_mag_e.val());
if (semver.gte(CONFIG.apiVersion, "1.41.0")) {
SENSOR_ALIGNMENT.gyro_to_use = parseInt(orientation_gyro_to_use_e.val());
SENSOR_ALIGNMENT.gyro_1_align = parseInt(orientation_gyro_1_align_e.val());
SENSOR_ALIGNMENT.gyro_2_align = parseInt(orientation_gyro_2_align_e.val());
}

PID_ADVANCED_CONFIG.fast_pwm_protocol = parseInt(esc_protocol_e.val()-1);
PID_ADVANCED_CONFIG.use_unsyncedPwm = $('input[id="unsyncedPWMSwitch"]').is(':checked') ? 1 : 0;
Expand Down
64 changes: 49 additions & 15 deletions src/tabs/configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,27 +247,61 @@
</div>
<div class="spacer_box">
<div class="board_align_content">
<div class="number">
<label> <input type="number" name="board_align_roll" step="1" min="-180" max="360" /> <span
i18n="configurationBoardAlignmentRoll"></span>
</label>
<div class="board_align_inputs">
<div class="alignicon roll"></div>
<label>
<input type="number" name="board_align_roll" step="1" min="-180" max="360" />
<span i18n="configurationBoardAlignmentRoll"></span>
</label>
</div>

<div class="board_align_inputs">
<div class="alignicon pitch"></div>
<label>
<input type="number" name="board_align_pitch" step="1" min="-180" max="360" />
<span i18n="configurationBoardAlignmentPitch"></span>
</label>
</div>

<div class="board_align_inputs">
<div class="alignicon yaw"></div>
<label>
<input type="number" name="board_align_yaw" step="1" min="-180" max="360" />
<span i18n="configurationBoardAlignmentYaw"></span>
</label>
</div>
</div>
<div class="gyro_align_content">
<div class="gyro_alignment_inputs">
<label>
<select class="gyro_to_use">
<option i18n="configurationSensorGyroToUseDefaultOption" value="0"></option>
<!-- list generated here -->
</select>
<span i18n="configurationSensorGyroToUse"></span>
</label>
</div>
<div class="number">
<label> <input type="number" name="board_align_pitch" step="1" min="-180" max="360" />
<span i18n="configurationBoardAlignmentPitch"></span>
<div class="gyro_alignment_inputs">
<label>
<select class="gyro_1_align">
<option i18n="configurationSensorAlignmentDefaultOption" value="0"></option>
<!-- list generated here -->
</select>
<span i18n="configurationSensorAlignmentGyro1"></span>
</label>
<div class="alignicon pitch"></div>
</div>
<div class="number">
<label> <input type="number" name="board_align_yaw" step="1" min="-180" max="360" /> <span
i18n="configurationBoardAlignmentYaw"></span>
<div class="gyro_alignment_inputs">
<label>
<select class="gyro_2_align">
<option i18n="configurationSensorAlignmentDefaultOption" value="0"></option>
<!-- list generated here -->
</select>
<span i18n="configurationSensorAlignmentGyro2"></span>
</label>
<div class="alignicon yaw"></div>
</div>
</div>
<div class="sensoralignment">
<div class="select">
<div class="sensor_align_content">
<div class="legacy_gyro_alignment select">
<label>
<span i18n="configurationSensorAlignmentGyro"></span>
<select class="gyroalign">
Expand All @@ -276,7 +310,7 @@
</select>
</label>
</div>
<div class="select">
<div class="legacy_accel_alignment select">
<label>
<span i18n="configurationSensorAlignmentAcc"></span>
<select class="accalign">
Expand Down