Skip to content

Commit d606a4c

Browse files
committed
OSD: use LC configured mask instead of loading all Logic Conditions
The OSD tab only needs to know which Logic Conditions are enabled to populate dropdown selectors - it never inspects LC content. Replace the heavyweight loadLogicConditions() call (which fetches up to 64 individual LCs via MSP) with a single MSP2_INAV_LOGIC_CONDITIONS_CONFIGURED request that returns an 8-byte bitmask. This also fixes #2552 (LC dropdowns showing "Logic 0") by moving the mask fetch into the OSD.reload chain so data is available before createCustomElements() builds the UI.
1 parent 4756819 commit d606a4c

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

tabs/osd.js

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2435,10 +2435,12 @@ OSD.reload = function(callback) {
24352435
OSD.data.supported = true;
24362436
OSD.msp.decodePreferences(resp);
24372437

2438-
MSP.promise(MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENTS).then(() => {
2438+
MSP.promise(MSPCodes.MSP2_INAV_CUSTOM_OSD_ELEMENTS).then(() => {
24392439
mspHelper.loadOsdCustomElements(() => {
2440-
createCustomElements();
2441-
done();
2440+
MSP.send_message(MSPCodes.MSP2_INAV_LOGIC_CONDITIONS_CONFIGURED, false, false, function() {
2441+
createCustomElements();
2442+
done();
2443+
});
24422444
});
24432445
});
24442446
});
@@ -3558,10 +3560,6 @@ TABS.osd = {};
35583560
TABS.osd.initialize = function (callback) {
35593561

35603562
mspHelper.loadServoMixRules();
3561-
mspHelper.loadLogicConditions(function() {
3562-
// Refresh LC dropdowns now that conditions are loaded
3563-
$('select.lc, select.ico_lc').html(getLCoptions());
3564-
});
35653563

35663564
if (GUI.active_tab != 'osd') {
35673565
GUI.active_tab = 'osd';
@@ -4177,13 +4175,16 @@ function getGVoptions(){
41774175

41784176
function getLCoptions(){
41794177
var result = '';
4180-
// Return empty if conditions aren't fully loaded yet - callback will refresh
4181-
if (FC.LOGIC_CONDITIONS.getCount() < FC.LOGIC_CONDITIONS.getMaxLogicConditionCount()) {
4178+
var mask = FC.LOGIC_CONDITIONS_CONFIGURED_MASK;
4179+
if (!mask) {
41824180
return result;
41834181
}
4184-
for(var i = 0; i < FC.LOGIC_CONDITIONS.getMaxLogicConditionCount(); i++) {
4185-
if (FC.LOGIC_CONDITIONS.isEnabled(i)) {
4186-
result += `<option value="` + i + `">LC ` + i + `</option>`;
4182+
for (var i = 0; i < 64; i++) {
4183+
var isConfigured = (i < 32) ?
4184+
(mask.lower & (1 << i)) !== 0 :
4185+
(mask.upper & (1 << (i - 32))) !== 0;
4186+
if (isConfigured) {
4187+
result += '<option value="' + i + '">LC ' + i + '</option>';
41874188
}
41884189
}
41894190
return result;

0 commit comments

Comments
 (0)