Skip to content

Commit 772b995

Browse files
committed
Add support for IMU3+
1 parent 1809bb8 commit 772b995

File tree

5 files changed

+584
-209
lines changed

5 files changed

+584
-209
lines changed

locales/en/messages.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,16 @@
15311531
"configurationSensorGyroToUseBoth": {
15321532
"message": "Both"
15331533
},
1534+
"configurationSensorGyroEnable": {
1535+
"message": "$t(sensorStatusGyroShort.message)",
1536+
"description": "Don't translate!!!"
1537+
},
1538+
"configurationSensorAlignment": {
1539+
"message": "Sensor Alignment"
1540+
},
1541+
"configurationGyroRequiredWarning": {
1542+
"message": "At least one gyro must remain enabled. If you disable all gyros, the flight controller will not work properly."
1543+
},
15341544
"configurationSensorAlignmentGyro1": {
15351545
"message": "First GYRO"
15361546
},
@@ -3142,7 +3152,8 @@
31423152
"message": "Reset overtime maximum"
31433153
},
31443154
"motorsSensorGyroSelect":{
3145-
"message": "gyro"
3155+
"message": "$t(sensorStatusGyroShort.message)",
3156+
"description": "Don't translate!!!"
31463157
},
31473158
"motorsSensorAccelSelect":{
31483159
"message": "accel"
@@ -4738,7 +4749,8 @@
47384749
"description": "Iterm Relax Type selection"
47394750
},
47404751
"pidTuningItermRelaxTypeOptionGyro": {
4741-
"message": "Gyro"
4752+
"message": "$t(sensorStatusGyroShort.message)",
4753+
"description": "Don't translate!!!"
47424754
},
47434755
"pidTuningItermRelaxTypeOptionSetpoint": {
47444756
"message": "Setpoint"

src/css/tabs/configuration.less

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,84 @@
5353
}
5454
}
5555
}
56+
57+
.gyro_box {
58+
padding: 12px;
59+
margin-bottom: 15px;
60+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
61+
}
62+
.gyro_box:hover {
63+
border-color: #bbb;
64+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
65+
}
66+
.gyro_row {
67+
display: flex;
68+
align-items: center;
69+
justify-content: space-between;
70+
margin-bottom: 10px;
71+
}
72+
.alignment-container {
73+
display: flex;
74+
align-items: center;
75+
flex: 3;
76+
}
77+
.alignment-container span {
78+
min-width: 100px;
79+
margin-right: 10px;
80+
}
81+
.alignment-container select {
82+
min-width: 120px;
83+
flex: 1;
84+
}
85+
.enable-checkbox {
86+
flex: 1;
87+
text-align: left;
88+
margin-right: 15px;
89+
padding-right: 0;
90+
}
91+
.custom_alignment {
92+
margin-top: 10px;
93+
padding: 10px;
94+
}
95+
.alignment_inputs_row {
96+
display: flex;
97+
justify-content: space-between;
98+
margin-bottom: 8px;
99+
}
100+
.alignment_input_cell {
101+
flex: 1;
102+
margin-right: 15px;
103+
text-align: center;
104+
}
105+
.alignment_input_cell:last-child {
106+
margin-right: 0;
107+
}
108+
.alignment_label {
109+
display: flex;
110+
align-items: center;
111+
justify-content: center;
112+
margin-bottom: 8px;
113+
white-space: nowrap;
114+
}
115+
.alignment_label span {
116+
font-size: 12px;
117+
color: #333;
118+
font-weight: 500;
119+
display: inline-block;
120+
vertical-align: middle;
121+
}
122+
.alignment_input_cell input {
123+
width: 80px;
124+
text-align: right;
125+
padding: 4px 8px;
126+
border: 1px solid #ddd;
127+
border-radius: 3px;
128+
}
129+
.alignment_input_cell input:focus {
130+
border-color: #999;
131+
outline: none;
132+
}
133+
56134
thead {
57135
display: none;
58136
}

src/js/fc.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,10 @@ const FC = {
478478
gyro_to_use: 0,
479479
gyro_1_align: 0,
480480
gyro_2_align: 0,
481-
gyro_align_roll: 0,
482-
gyro_align_pitch: 0,
483-
gyro_align_yaw: 0,
481+
gyro_align: [],
482+
gyro_align_roll: [],
483+
gyro_align_pitch: [],
484+
gyro_align_yaw: [],
484485
mag_align_roll: 0,
485486
mag_align_pitch: 0,
486487
mag_align_yaw: 0,

src/js/msp/MSPHelper.js

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const ledDirectionLetters = ["n", "e", "s", "w", "u", "d"]; // in LSB bit order
2323
const ledBaseFunctionLetters = ["c", "f", "a", "l", "s", "g", "r", "p", "e", "u"]; // in LSB bit
2424
let ledOverlayLetters = ["t", "y", "o", "b", "v", "i", "w"]; // in LSB bit
2525

26+
const MAX_GYROS = 8; // maximum number of gyros supported by Betaflight
27+
2628
function MspHelper() {
2729
const self = this;
2830

@@ -638,18 +640,35 @@ MspHelper.prototype.process_data = function (dataHandler) {
638640
FC.SENSOR_ALIGNMENT.align_acc = data.readU8();
639641
FC.SENSOR_ALIGNMENT.align_mag = data.readU8();
640642
FC.SENSOR_ALIGNMENT.gyro_detection_flags = data.readU8();
641-
FC.SENSOR_ALIGNMENT.gyro_to_use = data.readU8();
642-
FC.SENSOR_ALIGNMENT.gyro_1_align = data.readU8();
643-
FC.SENSOR_ALIGNMENT.gyro_2_align = data.readU8();
643+
644644
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
645-
FC.SENSOR_ALIGNMENT.gyro_align_roll = data.read16() / 10;
646-
FC.SENSOR_ALIGNMENT.gyro_align_pitch = data.read16() / 10;
647-
FC.SENSOR_ALIGNMENT.gyro_align_yaw = data.read16() / 10;
645+
FC.SENSOR_ALIGNMENT.gyro_enable_mask = data.readU8(); // replacing gyro_to_use
646+
647+
// Initialize arrays for gyro alignment
648+
FC.SENSOR_ALIGNMENT.gyro_align = [];
649+
FC.SENSOR_ALIGNMENT.gyro_align_roll = [];
650+
FC.SENSOR_ALIGNMENT.gyro_align_pitch = [];
651+
FC.SENSOR_ALIGNMENT.gyro_align_yaw = [];
652+
653+
for (let i = 0; i < MAX_GYROS; i++) {
654+
FC.SENSOR_ALIGNMENT.gyro_align[i] = data.readU8();
655+
}
656+
657+
for (let i = 0; i < MAX_GYROS; i++) {
658+
FC.SENSOR_ALIGNMENT.gyro_align_roll[i] = data.read16() / 10;
659+
FC.SENSOR_ALIGNMENT.gyro_align_pitch[i] = data.read16() / 10;
660+
FC.SENSOR_ALIGNMENT.gyro_align_yaw[i] = data.read16() / 10;
661+
}
648662

649663
FC.SENSOR_ALIGNMENT.mag_align_roll = data.read16() / 10;
650664
FC.SENSOR_ALIGNMENT.mag_align_pitch = data.read16() / 10;
651665
FC.SENSOR_ALIGNMENT.mag_align_yaw = data.read16() / 10;
666+
} else {
667+
FC.SENSOR_ALIGNMENT.gyro_to_use = data.readU8();
668+
FC.SENSOR_ALIGNMENT.gyro_1_align = data.readU8();
669+
FC.SENSOR_ALIGNMENT.gyro_2_align = data.readU8();
652670
}
671+
653672
break;
654673
case MSPCodes.MSP_DISPLAYPORT:
655674
break;
@@ -2079,19 +2098,33 @@ MspHelper.prototype.crunch = function (code, modifierCode = undefined) {
20792098
buffer
20802099
.push8(FC.SENSOR_ALIGNMENT.align_gyro)
20812100
.push8(FC.SENSOR_ALIGNMENT.align_acc)
2082-
.push8(FC.SENSOR_ALIGNMENT.align_mag)
2083-
.push8(FC.SENSOR_ALIGNMENT.gyro_to_use)
2084-
.push8(FC.SENSOR_ALIGNMENT.gyro_1_align)
2085-
.push8(FC.SENSOR_ALIGNMENT.gyro_2_align);
2101+
.push8(FC.SENSOR_ALIGNMENT.align_mag);
2102+
20862103
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
2087-
buffer.push16(FC.SENSOR_ALIGNMENT.gyro_align_roll * 10);
2088-
buffer.push16(FC.SENSOR_ALIGNMENT.gyro_align_pitch * 10);
2089-
buffer.push16(FC.SENSOR_ALIGNMENT.gyro_align_yaw * 10);
2104+
buffer.push8(FC.SENSOR_ALIGNMENT.gyro_enable_mask); // replacing gyro_to_use
2105+
2106+
for (let i = 0; i < MAX_GYROS; i++) {
2107+
buffer.push8(FC.SENSOR_ALIGNMENT.gyro_align[i]);
2108+
}
2109+
2110+
for (let i = 0; i < MAX_GYROS; i++) {
2111+
buffer
2112+
.push16(FC.SENSOR_ALIGNMENT.gyro_align_roll[i] * 10)
2113+
.push16(FC.SENSOR_ALIGNMENT.gyro_align_pitch[i] * 10)
2114+
.push16(FC.SENSOR_ALIGNMENT.gyro_align_yaw[i] * 10);
2115+
}
20902116

2091-
buffer.push16(FC.SENSOR_ALIGNMENT.mag_align_roll * 10);
2092-
buffer.push16(FC.SENSOR_ALIGNMENT.mag_align_pitch * 10);
2093-
buffer.push16(FC.SENSOR_ALIGNMENT.mag_align_yaw * 10);
2117+
buffer
2118+
.push16(FC.SENSOR_ALIGNMENT.mag_align_roll * 10)
2119+
.push16(FC.SENSOR_ALIGNMENT.mag_align_pitch * 10)
2120+
.push16(FC.SENSOR_ALIGNMENT.mag_align_yaw * 10);
2121+
} else {
2122+
buffer
2123+
.push8(FC.SENSOR_ALIGNMENT.gyro_to_use)
2124+
.push8(FC.SENSOR_ALIGNMENT.gyro_1_align)
2125+
.push8(FC.SENSOR_ALIGNMENT.gyro_2_align);
20942126
}
2127+
20952128
break;
20962129
case MSPCodes.MSP_SET_ADVANCED_CONFIG:
20972130
buffer

0 commit comments

Comments
 (0)