Skip to content

Commit 799c30b

Browse files
committed
Add support for IMU3+
1 parent 1809bb8 commit 799c30b

File tree

5 files changed

+576
-207
lines changed

5 files changed

+576
-207
lines changed

locales/en/messages.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,6 +1531,18 @@
15311531
"configurationSensorGyroToUseBoth": {
15321532
"message": "Both"
15331533
},
1534+
"configurationSensorGyroTitle": {
1535+
"message": "IMU Sensor "
1536+
},
1537+
"configurationSensorEnable": {
1538+
"message": "Enable Sensor"
1539+
},
1540+
"configurationSensorAlignment": {
1541+
"message": "Sensor Alignment"
1542+
},
1543+
"configurationGyroRequiredWarning": {
1544+
"message": "At least one gyro must remain enabled. If you disable all gyros, the flight controller will not work properly."
1545+
},
15341546
"configurationSensorAlignmentGyro1": {
15351547
"message": "First GYRO"
15361548
},

src/css/tabs/configuration.less

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,92 @@
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_title {
67+
font-weight: bold;
68+
font-size: 14px;
69+
margin-bottom: 12px;
70+
padding-bottom: 6px;
71+
border-bottom: 1px solid #eee;
72+
color: #333;
73+
}
74+
.gyro_row {
75+
display: flex;
76+
align-items: center;
77+
justify-content: space-between;
78+
margin-bottom: 10px;
79+
}
80+
.alignment-container {
81+
display: flex;
82+
align-items: center;
83+
flex: 3;
84+
}
85+
.alignment-container span {
86+
min-width: 100px;
87+
margin-right: 10px;
88+
}
89+
.alignment-container select {
90+
min-width: 120px;
91+
flex: 1;
92+
}
93+
.enable-checkbox {
94+
flex: 1;
95+
text-align: left;
96+
margin-right: 15px;
97+
padding-right: 0;
98+
}
99+
.custom_alignment {
100+
margin-top: 10px;
101+
padding: 10px;
102+
}
103+
.alignment_inputs_row {
104+
display: flex;
105+
justify-content: space-between;
106+
margin-bottom: 8px;
107+
}
108+
.alignment_input_cell {
109+
flex: 1;
110+
margin-right: 15px;
111+
text-align: center;
112+
}
113+
.alignment_input_cell:last-child {
114+
margin-right: 0;
115+
}
116+
.alignment_label {
117+
display: flex;
118+
align-items: center;
119+
justify-content: center;
120+
margin-bottom: 8px;
121+
white-space: nowrap;
122+
}
123+
.alignment_label span {
124+
font-size: 12px;
125+
color: #333;
126+
font-weight: 500;
127+
display: inline-block;
128+
vertical-align: middle;
129+
}
130+
.alignment_input_cell input {
131+
width: 80px;
132+
text-align: right;
133+
padding: 4px 8px;
134+
border: 1px solid #ddd;
135+
border-radius: 3px;
136+
}
137+
.alignment_input_cell input:focus {
138+
border-color: #999;
139+
outline: none;
140+
}
141+
56142
thead {
57143
display: none;
58144
}

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: 47 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -638,18 +638,35 @@ MspHelper.prototype.process_data = function (dataHandler) {
638638
FC.SENSOR_ALIGNMENT.align_acc = data.readU8();
639639
FC.SENSOR_ALIGNMENT.align_mag = data.readU8();
640640
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();
641+
644642
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;
643+
FC.SENSOR_ALIGNMENT.gyro_enable_mask = data.readU8(); // replacing gyro_to_use
644+
645+
// Initialize arrays for gyro alignment
646+
FC.SENSOR_ALIGNMENT.gyro_align = [];
647+
FC.SENSOR_ALIGNMENT.gyro_align_roll = [];
648+
FC.SENSOR_ALIGNMENT.gyro_align_pitch = [];
649+
FC.SENSOR_ALIGNMENT.gyro_align_yaw = [];
650+
651+
for (let i = 0; i < 8; i++) {
652+
FC.SENSOR_ALIGNMENT.gyro_align[i] = data.readU8();
653+
}
654+
655+
for (let i = 0; i < 8; i++) {
656+
FC.SENSOR_ALIGNMENT.gyro_align_roll[i] = data.read16() / 10;
657+
FC.SENSOR_ALIGNMENT.gyro_align_pitch[i] = data.read16() / 10;
658+
FC.SENSOR_ALIGNMENT.gyro_align_yaw[i] = data.read16() / 10;
659+
}
648660

649661
FC.SENSOR_ALIGNMENT.mag_align_roll = data.read16() / 10;
650662
FC.SENSOR_ALIGNMENT.mag_align_pitch = data.read16() / 10;
651663
FC.SENSOR_ALIGNMENT.mag_align_yaw = data.read16() / 10;
664+
} else {
665+
FC.SENSOR_ALIGNMENT.gyro_to_use = data.readU8();
666+
FC.SENSOR_ALIGNMENT.gyro_1_align = data.readU8();
667+
FC.SENSOR_ALIGNMENT.gyro_2_align = data.readU8();
652668
}
669+
653670
break;
654671
case MSPCodes.MSP_DISPLAYPORT:
655672
break;
@@ -2079,19 +2096,33 @@ MspHelper.prototype.crunch = function (code, modifierCode = undefined) {
20792096
buffer
20802097
.push8(FC.SENSOR_ALIGNMENT.align_gyro)
20812098
.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);
2099+
.push8(FC.SENSOR_ALIGNMENT.align_mag);
2100+
20862101
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);
2102+
buffer.push8(FC.SENSOR_ALIGNMENT.gyro_enable_mask); // replacing gyro_to_use
20902103

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);
2104+
for (let i = 0; i < 8; i++) {
2105+
buffer.push8(FC.SENSOR_ALIGNMENT.gyro_align[i]);
2106+
}
2107+
2108+
for (let i = 0; i < 8; i++) {
2109+
buffer
2110+
.push16(FC.SENSOR_ALIGNMENT.gyro_align_roll[i] * 10)
2111+
.push16(FC.SENSOR_ALIGNMENT.gyro_align_pitch[i] * 10)
2112+
.push16(FC.SENSOR_ALIGNMENT.gyro_align_yaw[i] * 10);
2113+
}
2114+
2115+
buffer
2116+
.push16(FC.SENSOR_ALIGNMENT.mag_align_roll * 10)
2117+
.push16(FC.SENSOR_ALIGNMENT.mag_align_pitch * 10)
2118+
.push16(FC.SENSOR_ALIGNMENT.mag_align_yaw * 10);
2119+
} else {
2120+
buffer
2121+
.push8(FC.SENSOR_ALIGNMENT.gyro_to_use)
2122+
.push8(FC.SENSOR_ALIGNMENT.gyro_1_align)
2123+
.push8(FC.SENSOR_ALIGNMENT.gyro_2_align);
20942124
}
2125+
20952126
break;
20962127
case MSPCodes.MSP_SET_ADVANCED_CONFIG:
20972128
buffer

0 commit comments

Comments
 (0)