@@ -25,8 +25,29 @@ function MspHelper () {
2525 } ;
2626}
2727
28+ MspHelper . prototype . reorderPwmProtocols = function ( protocol ) {
29+ var result = protocol ;
30+ if ( semver . lt ( CONFIG . apiVersion , "1.26.0" ) ) {
31+ switch ( protocol ) {
32+ case 5 :
33+ result = 7 ;
34+
35+ break ;
36+ case 7 :
37+ result = 5 ;
38+
39+ break ;
40+ default :
41+ break ;
42+ }
43+ }
44+
45+ return result ;
46+ }
47+
2848MspHelper . prototype . process_data = function ( dataHandler ) {
2949 var self = this ;
50+
3051 var data = dataHandler . dataView ; // DataView (allowing us to view arrayBuffer as struct/union)
3152 var code = dataHandler . code ;
3253 if ( ! dataHandler . unsupported ) switch ( code ) {
@@ -615,7 +636,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
615636 PID_ADVANCED_CONFIG . gyro_sync_denom = data . readU8 ( ) ;
616637 PID_ADVANCED_CONFIG . pid_process_denom = data . readU8 ( ) ;
617638 PID_ADVANCED_CONFIG . use_unsyncedPwm = data . readU8 ( ) ;
618- PID_ADVANCED_CONFIG . fast_pwm_protocol = data . readU8 ( ) ;
639+ PID_ADVANCED_CONFIG . fast_pwm_protocol = self . reorderPwmProtocols ( data . readU8 ( ) ) ;
619640 PID_ADVANCED_CONFIG . motor_pwm_rate = data . readU16 ( ) ;
620641 if ( semver . gte ( CONFIG . apiVersion , "1.24.0" ) ) {
621642 PID_ADVANCED_CONFIG . digitalIdlePercent = data . readU16 ( ) / 100 ;
@@ -1134,12 +1155,12 @@ MspHelper.prototype.crunch = function(code) {
11341155 buffer . push8 ( SENSOR_ALIGNMENT . align_gyro )
11351156 . push8 ( SENSOR_ALIGNMENT . align_acc )
11361157 . push8 ( SENSOR_ALIGNMENT . align_mag ) ;
1137- break
1158+ break ;
11381159 case MSPCodes . MSP_SET_ADVANCED_CONFIG :
11391160 buffer . push8 ( PID_ADVANCED_CONFIG . gyro_sync_denom )
11401161 . push8 ( PID_ADVANCED_CONFIG . pid_process_denom )
11411162 . push8 ( PID_ADVANCED_CONFIG . use_unsyncedPwm )
1142- . push8 ( PID_ADVANCED_CONFIG . fast_pwm_protocol )
1163+ . push8 ( self . reorderPwmProtocols ( PID_ADVANCED_CONFIG . fast_pwm_protocol ) )
11431164 . push16 ( PID_ADVANCED_CONFIG . motor_pwm_rate ) ;
11441165 if ( semver . gte ( CONFIG . apiVersion , "1.24.0" ) ) {
11451166 buffer . push16 ( PID_ADVANCED_CONFIG . digitalIdlePercent * 100 ) ;
0 commit comments