1- /*global fc*/
1+ /*global fc,mspHelper,TABS */
22'use strict' ;
33
44TABS . servos = { } ;
@@ -12,6 +12,7 @@ TABS.servos.initialize = function (callback) {
1212 let loadChainer = new MSPChainerClass ( ) ;
1313
1414 loadChainer . setChain ( [
15+ mspHelper . loadServoMixRules ,
1516 mspHelper . loadServoConfiguration ,
1617 mspHelper . loadRcData ,
1718 mspHelper . loadBfConfig ,
@@ -52,6 +53,9 @@ TABS.servos.initialize = function (callback) {
5253 servoHeader = '' ;
5354
5455 if ( semver . lt ( CONFIG . flightControllerVersion , "2.0.0" ) ) {
56+
57+ $ ( '.requires-v2_0' ) . hide ( ) ;
58+
5559 for ( i = 0 ; i < RC . active_channels - 4 ; i ++ ) {
5660 servoHeader = servoHeader + '<th class="short">CH' + ( i + 5 ) + '</th>' ;
5761 }
@@ -88,29 +92,36 @@ TABS.servos.initialize = function (callback) {
8892 </tr> \
8993 ' ) ;
9094
95+ let $currentRow = $servoConfigTable . find ( 'tr:last' ) ;
96+
9197 //This routine is pre 2.0 only
9298 if ( SERVO_CONFIG [ obj ] . indexOfChannelToForward >= 0 ) {
93- $servoConfigTable . find ( 'tr:last td.channel input' ) . eq ( SERVO_CONFIG [ obj ] . indexOfChannelToForward ) . prop ( 'checked' , true ) ;
99+ $currentRow . find ( 'td.channel input' ) . eq ( SERVO_CONFIG [ obj ] . indexOfChannelToForward ) . prop ( 'checked' , true ) ;
94100 }
95101
96102 // adding select box and generating options
97- $servoConfigTable . find ( 'tr:last td.rate' ) . append (
103+ $currentRow . find ( 'td.rate' ) . append (
98104 '<input class="rate-input" type="number" min="' + FC . MIN_SERVO_RATE + '" max="' + FC . MAX_SERVO_RATE + '" value="' + Math . abs ( SERVO_CONFIG [ obj ] . rate ) + '" />'
99105 ) ;
100106
101- $servoConfigTable . find ( 'tr:last td.reverse' ) . append (
107+ $currentRow . find ( 'td.reverse' ) . append (
102108 '<input type="checkbox" class="reverse-input togglemedium" ' + ( SERVO_CONFIG [ obj ] . rate < 0 ? ' checked ' : '' ) + '/>'
103109 ) ;
104110
105- $servoConfigTable . find ( 'tr:last' ) . data ( 'info' , { 'obj' : obj } ) ;
111+ $currentRow . data ( 'info' , { 'obj' : obj } ) ;
106112
107113 if ( semver . lt ( CONFIG . flightControllerVersion , "2.0.0" ) ) {
108114 // only one checkbox for indicating a channel to forward can be selected at a time, perhaps a radio group would be best here.
109- $servoConfigTable . find ( 'tr:last td.channel input' ) . click ( function ( ) {
115+ $currentRow . find ( 'td.channel input' ) . click ( function ( ) {
110116 if ( $ ( this ) . is ( ':checked' ) ) {
111117 $ ( this ) . parent ( ) . parent ( ) . find ( '.channel input' ) . not ( $ ( this ) ) . prop ( 'checked' , false ) ;
112118 }
113119 } ) ;
120+ } else {
121+ //For 2.0 and above hide a row when servo is not configured
122+ if ( ! SERVO_RULES . isServoConfigured ( obj ) ) {
123+ $servoConfigTable . find ( 'tr:last' ) . hide ( ) ;
124+ }
114125 }
115126 }
116127
0 commit comments