Skip to content

Commit 4995078

Browse files
authored
Fix gyro enable box (#4611)
1 parent 02ce6eb commit 4995078

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed

locales/en/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,9 @@
15011501
"configurationGyroActiveIMU": {
15021502
"message": "Active IMU"
15031503
},
1504+
"configurationGyroActiveIMUHelp": {
1505+
"message": "Select which gyro to use as the primary gyro. The primary gyro is used for stabilization and control. If you have only one gyro, it will be selected automatically.<br><br>It is not always possible to enable multiple gyros, when they are of different types or brands."
1506+
},
15041507
"configurationGyroAlignmentRoll": {
15051508
"message": "$t(configurationBoardAlignmentRoll.message)",
15061509
"description": "Don't translate!!!"

src/js/tabs/configuration.js

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,8 @@ configuration.initialize = function (callback) {
240240

241241
// Multi gyro handling for newer firmware
242242
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_47)) {
243-
// Hide unused legacy elements
244-
$(".gyro_alignment_inputs_selection").hide();
245-
$(".gyro_alignment_inputs_first").hide();
246-
$(".gyro_alignment_inputs_second").hide();
243+
// Hide deprecated gyro_box
244+
$(".tab-configuration .gyro_box").parent().hide();
247245

248246
// Define gyro detection flags
249247
const GYRO_DETECTION_FLAGS = { DETECTED_DUAL_GYROS: 1 << 7 };
@@ -264,23 +262,10 @@ configuration.initialize = function (callback) {
264262
FC.SENSOR_ALIGNMENT.gyro_enable_mask = 1;
265263
}
266264

267-
// Use the specific gyro container (not the general sensor_align_content)
268-
const gyroContainer = $(".sensor_align_content .gyro_align_box");
269-
// Clear any existing content in the gyro container
270-
gyroContainer.empty();
271-
272265
if (gyroCount > 1) {
273266
// Track which gyros are detected
274267
const detected_gyros = [];
275268

276-
$(".tab-configuration .gyro_box .spacer_box_title")
277-
.attr("i18n", "configurationGyroActiveIMU")
278-
.removeClass("i18n-replaced");
279-
i18n.localizePage(); // Update the title text
280-
281-
// Make the gyro container visible
282-
gyroContainer.show();
283-
284269
function createGyroBox(gyroIndex, container) {
285270
// Create a new gyro alignment div
286271
const gyroBox = $(`<div id="gyro_box_${gyroIndex + 1}"></div>`);
@@ -340,17 +325,20 @@ configuration.initialize = function (callback) {
340325

341326
// If gyro is detected, create UI for it
342327
if (detected_gyros[i]) {
343-
createGyroBox(i, gyroContainer);
328+
createGyroBox(i, $(".tab-configuration .gyro_enable_configuration"));
344329
}
345330
}
346331

347332
// Only show not found message if no gyros are detected
348-
$(".gyro_alignment_inputs_notfound").toggle(!detected_gyros.some((detected) => detected));
333+
$(".gyro_notfound").toggle(!detected_gyros.some((detected) => detected));
349334
} else {
350335
// Hide the gyro container if not needed
351-
$(".tab-configuration .gyro_box").parent().hide();
336+
$(".tab-configuration .gyro_enable_box").parent().hide();
352337
}
353338
} else {
339+
// Hide the gyro enable box introduced in 1.47
340+
$(".tab-configuration .gyro_enable_box").parent().hide();
341+
354342
// Original code for older firmware versions remains unchanged
355343
const orientation_gyro_to_use_e = $("select.gyro_to_use");
356344
const orientation_gyro_1_align_e = $("select.gyro_1_align");

src/tabs/configuration.html

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@
185185
</div>
186186
</div>
187187
<!-- END BOARD ALIGNMENT -->
188-
<!-- GYRO ALIGNMENT -->
188+
189+
<!-- GYRO ALIGNMENT - DEPRECATED -->
189190
<div class="gui_box grey">
190191
<div class="gui_box_titlebar gyro_box">
191192
<div class="spacer_box_title" i18n="configurationGyroAlignment"></div>
@@ -229,6 +230,26 @@
229230
</div>
230231
</div>
231232
<!-- END GYRO ALIGNMENT -->
233+
234+
<!-- GYRO ENABLE INTRODUCED 1.47 -->
235+
<div class="gui_box grey">
236+
<div class="gui_box_titlebar gyro_enable_box">
237+
<div class="spacer_box_title" i18n="configurationGyroActiveIMU"></div>
238+
<div class="helpicon cf_tip" i18n_title="configurationGyroActiveIMUHelp"></div>
239+
</div>
240+
<div class="spacer_box">
241+
<table>
242+
<tbody class="gyro_enable_configuration" id="noline">
243+
<!-- table generated here -->
244+
</tbody>
245+
</table>
246+
</div>
247+
<div class="gyro_notfound">
248+
<span class="message-negative" i18n="configurationSensorGyroToUseNotFound"></span>
249+
</div>
250+
</div>
251+
<!-- END GYRO ENABLE -->
252+
232253
<!-- MAGNETOMETER ALIGNMENT -->
233254
<div class="gui_box grey mag_align_box">
234255
<div class="gui_box_titlebar">

0 commit comments

Comments
 (0)