@@ -258,8 +258,15 @@ ports.initialize = function (callback) {
258
258
selectElement = functionsElement . find ( selectElementSelector ) ;
259
259
selectElement . append ( `<option value="">${ disabledText } </option>` ) ;
260
260
}
261
- const isDisabled = FC . CONFIG . buildOptions . length && functionRule . dependsOn !== undefined && ! FC . CONFIG . buildOptions . includes ( functionRule . dependsOn ) ? "disabled" : "" ;
262
- selectElement . append ( `<option value="${ functionName } " ${ isDisabled } >${ functionRule . displayName } </option>` ) ;
261
+ const isDisabled =
262
+ FC . CONFIG . buildOptions . length &&
263
+ functionRule . dependsOn !== undefined &&
264
+ ! FC . CONFIG . buildOptions . includes ( functionRule . dependsOn )
265
+ ? "disabled"
266
+ : "" ;
267
+ selectElement . append (
268
+ `<option value="${ functionName } " ${ isDisabled } >${ functionRule . displayName } </option>` ,
269
+ ) ;
263
270
// sort telemetry, sensors, peripherals select elements. disabledText on top
264
271
selectElement . sortSelect ( disabledText ) ;
265
272
@@ -304,47 +311,44 @@ ports.initialize = function (callback) {
304
311
FC . VTX_CONFIG . vtx_table_channels === 0 ||
305
312
FC . VTX_CONFIG . vtx_table_powerlevels === 0 ) ;
306
313
307
- const pheripheralsSelectElement = $ ( 'select[name="function-peripherals"]' ) ;
308
- pheripheralsSelectElement . on ( "change" , function ( ) {
314
+ const peripheralsSelectElement = $ ( 'select[name="function-peripherals"]' ) ;
315
+
316
+ peripheralsSelectElement . on ( "change" , function ( ) {
309
317
let vtxControlSelected , mspControlSelected ;
310
318
311
- pheripheralsSelectElement . each ( function ( index , element ) {
312
- const value = $ ( element ) . val ( ) ;
319
+ // Handle each port's peripheral selection
320
+ peripheralsSelectElement . each ( function ( portIndex , element ) {
321
+ const selectedFunction = $ ( element ) . val ( ) ;
322
+ const mspCheckbox = $ ( `#functionCheckbox-${ portIndex } -0-0` ) ;
313
323
314
- if ( value === "TBS_SMARTAUDIO" || value === "IRC_TRAMP" ) {
315
- vtxControlSelected = value ;
324
+ // Handle VTX control protocols (SmartAudio/Tramp)
325
+ if ( selectedFunction === "TBS_SMARTAUDIO" || selectedFunction === "IRC_TRAMP" ) {
326
+ vtxControlSelected = selectedFunction ;
327
+ mspCheckbox . prop ( "checked" , false ) . trigger ( "change" ) ;
316
328
}
317
329
318
- if ( value . includes ( "MSP" ) ) {
319
- mspControlSelected = value ;
320
-
321
- // Enable MSP Configuration for MSP function
322
- $ ( ".tab-ports .portConfiguration" ) . each ( function ( port , portConfig ) {
323
- const peripheralFunction = $ ( portConfig ) . find ( "select[name=function-peripherals]" ) . val ( ) ;
324
-
325
- if ( peripheralFunction . includes ( "MSP" ) && index === port ) {
326
- $ ( `#functionCheckbox-${ port } -0-0` ) . prop ( "checked" , true ) . trigger ( "change" ) ;
327
- }
328
- } ) ;
330
+ // Handle MSP-based peripheral functions
331
+ if ( selectedFunction . includes ( "MSP" ) ) {
332
+ mspControlSelected = selectedFunction ;
333
+ mspCheckbox . prop ( "checked" , true ) . trigger ( "change" ) ;
329
334
}
330
335
} ) ;
331
336
337
+ // Update analytics and UI elements
332
338
if ( lastVtxControlSelected !== vtxControlSelected ) {
333
339
self . analyticsChanges [ "VtxControl" ] = vtxControlSelected ;
334
-
335
340
lastVtxControlSelected = vtxControlSelected ;
336
341
}
337
342
338
343
if ( lastMspSelected !== mspControlSelected ) {
339
344
self . analyticsChanges [ "MspControl" ] = mspControlSelected ;
340
-
341
345
lastMspSelected = mspControlSelected ;
342
346
}
343
347
344
348
$ ( ".vtxTableNotSet" ) . toggle ( vtxControlSelected && vtxTableNotConfigured ) ;
345
349
} ) ;
346
350
347
- pheripheralsSelectElement . trigger ( "change" ) ;
351
+ peripheralsSelectElement . trigger ( "change" ) ;
348
352
}
349
353
350
354
function on_tab_loaded_handler ( ) {
0 commit comments