@@ -1307,11 +1307,12 @@ TABS.osd.initialize = function (callback) {
13071307
13081308 // display fields on/off and position
13091309 var $displayFields = $ ( '#element-fields' ) . empty ( ) ;
1310+ var enabledCount = 0 ;
13101311 for ( let field of OSD . data . display_items ) {
13111312 // versioning related, if the field doesn't exist at the current flight controller version, just skip it
13121313 if ( ! field . name ) { continue ; }
1314+ if ( field . isVisible ) { enabledCount ++ ; }
13131315
1314- var checked = field . isVisible ? 'checked' : '' ;
13151316 var $field = $ ( '<div class="switchable-field field-' + field . index + '"/>' ) ;
13161317 var desc = null ;
13171318 if ( field . desc && field . desc . length ) {
@@ -1359,6 +1360,10 @@ TABS.osd.initialize = function (callback) {
13591360 }
13601361 $displayFields . append ( $field ) ;
13611362 }
1363+ //Set Switch all checkbox defaults based on the majority of the switches
1364+ var checked = enabledCount >= ( OSD . data . display_items . length / 2 ) ;
1365+ $ ( 'input#switch-all' ) . prop ( 'checked' , checked ) . change ( ) ;
1366+
13621367 GUI . switchery ( ) ;
13631368 // buffer the preview
13641369 OSD . data . preview = [ ] ;
@@ -1533,7 +1538,10 @@ TABS.osd.initialize = function (callback) {
15331538 } ) ;
15341539
15351540 //Switch all elements
1536- $ ( 'input#switch-all' ) . change ( function ( ) {
1541+ $ ( 'input#switch-all' ) . change ( function ( event ) {
1542+ //if we just change value based on the majority of the switches
1543+ if ( event . isTrigger ) return ;
1544+
15371545 var new_state = $ ( this ) . is ( ':checked' ) ;
15381546
15391547 var updateList = [ ] ;
0 commit comments