@@ -47,6 +47,13 @@ TABS.pid_tuning.initialize = function (callback) {
4747 promise = MSP . promise ( MSPCodes . MSP_BF_CONFIG ) ;
4848 }
4949
50+ return promise ;
51+ } ) . then ( function ( ) {
52+ var promise = true ;
53+ if ( semver . gte ( CONFIG . apiVersion , "1.15.0" ) ) {
54+ promise = MSP . promise ( MSPCodes . MSP_RC_DEADBAND ) ;
55+ }
56+
5057 return promise ;
5158 } ) . then ( function ( ) {
5259 $ ( '#content' ) . load ( "./tabs/pid_tuning.html" , process_html ) ;
@@ -453,18 +460,18 @@ TABS.pid_tuning.initialize = function (callback) {
453460
454461 self . rateCurve = new RateCurve ( useLegacyCurve ) ;
455462
456- function printMaxAngularVel ( rate , rcRate , rcExpo , useSuperExpo , maxAngularVelElement ) {
457- var maxAngularVel = self . rateCurve . getMaxAngularVel ( rate , rcRate , rcExpo , useSuperExpo ) . toFixed ( 0 ) ;
463+ function printMaxAngularVel ( rate , rcRate , rcExpo , useSuperExpo , deadband , maxAngularVelElement ) {
464+ var maxAngularVel = self . rateCurve . getMaxAngularVel ( rate , rcRate , rcExpo , useSuperExpo , deadband ) . toFixed ( 0 ) ;
458465 maxAngularVelElement . text ( maxAngularVel ) ;
459466
460467 return maxAngularVel ;
461468 }
462469
463- function drawCurve ( rate , rcRate , rcExpo , useSuperExpo , maxAngularVel , colour , yOffset , context ) {
470+ function drawCurve ( rate , rcRate , rcExpo , useSuperExpo , maxAngularVel , deadband , colour , yOffset , context ) {
464471 context . save ( ) ;
465472 context . strokeStyle = colour ;
466473 context . translate ( 0 , yOffset ) ;
467- self . rateCurve . draw ( rate , rcRate , rcExpo , useSuperExpo , maxAngularVel , context ) ;
474+ self . rateCurve . draw ( rate , rcRate , rcExpo , useSuperExpo , maxAngularVel , deadband , context ) ;
468475 context . restore ( ) ;
469476 }
470477
@@ -485,7 +492,9 @@ TABS.pid_tuning.initialize = function (callback) {
485492 rc_rate_yaw : RC_tuning . rcYawRate ,
486493 rc_expo : RC_tuning . RC_EXPO ,
487494 rc_yaw_expo : RC_tuning . RC_YAW_EXPO ,
488- superexpo : BF_CONFIG . features . isEnabled ( 'SUPEREXPO_RATES' )
495+ superexpo : BF_CONFIG . features . isEnabled ( 'SUPEREXPO_RATES' ) ,
496+ deadband : RC_deadband . deadband ,
497+ yawDeadband : RC_deadband . yaw_deadband
489498 } ;
490499
491500 if ( semver . lt ( CONFIG . apiVersion , "1.7.0" ) ) {
@@ -717,22 +726,25 @@ TABS.pid_tuning.initialize = function (callback) {
717726 var curveHeight = rcCurveElement . height ;
718727 var curveWidth = rcCurveElement . width ;
719728
720- var maxAngularVel = Math . max (
721- printMaxAngularVel ( self . currentRates . roll_rate , self . currentRates . rc_rate , self . currentRates . rc_expo , self . currentRates . superexpo , maxAngularVelRollElement ) ,
722- printMaxAngularVel ( self . currentRates . pitch_rate , self . currentRates . rc_rate , self . currentRates . rc_expo , self . currentRates . superexpo , maxAngularVelPitchElement ) ,
723- printMaxAngularVel ( self . currentRates . yaw_rate , self . currentRates . rc_rate_yaw , self . currentRates . rc_yaw_expo , self . currentRates . superexpo , maxAngularVelYawElement ) ) ;
724-
725729 curveContext . clearRect ( 0 , 0 , curveWidth , curveHeight ) ;
726730
731+ var maxAngularVel ;
727732 if ( ! useLegacyCurve ) {
733+ maxAngularVel = Math . max (
734+ printMaxAngularVel ( self . currentRates . roll_rate , self . currentRates . rc_rate , self . currentRates . rc_expo , self . currentRates . superexpo , self . currentRates . deadband , maxAngularVelRollElement ) ,
735+ printMaxAngularVel ( self . currentRates . pitch_rate , self . currentRates . rc_rate , self . currentRates . rc_expo , self . currentRates . superexpo , self . currentRates . deadband , maxAngularVelPitchElement ) ,
736+ printMaxAngularVel ( self . currentRates . yaw_rate , self . currentRates . rc_rate_yaw , self . currentRates . rc_yaw_expo , self . currentRates . superexpo , self . currentRates . yawDeadband , maxAngularVelYawElement ) ) ;
737+
728738 drawAxes ( curveContext , curveWidth , curveHeight , ( curveHeight / 2 ) / maxAngularVel * 360 ) ;
739+ } else {
740+ maxAngularVel = 0 ;
729741 }
730742
731743 curveContext . lineWidth = 4 ;
732744
733- drawCurve ( self . currentRates . roll_rate , self . currentRates . rc_rate , self . currentRates . rc_expo , self . currentRates . superexpo , maxAngularVel , '#ff0000' , 0 , curveContext ) ;
734- drawCurve ( self . currentRates . pitch_rate , self . currentRates . rc_rate , self . currentRates . rc_expo , self . currentRates . superexpo , maxAngularVel , '#00ff00' , - 4 , curveContext ) ;
735- drawCurve ( self . currentRates . yaw_rate , self . currentRates . rc_rate_yaw , self . currentRates . rc_yaw_expo , self . currentRates . superexpo , maxAngularVel , '#0000ff' , 4 , curveContext ) ;
745+ drawCurve ( self . currentRates . roll_rate , self . currentRates . rc_rate , self . currentRates . rc_expo , self . currentRates . superexpo , self . currentRates . deadband , maxAngularVel , '#ff0000' , 0 , curveContext ) ;
746+ drawCurve ( self . currentRates . pitch_rate , self . currentRates . rc_rate , self . currentRates . rc_expo , self . currentRates . superexpo , self . currentRates . deadband , maxAngularVel , '#00ff00' , - 4 , curveContext ) ;
747+ drawCurve ( self . currentRates . yaw_rate , self . currentRates . rc_rate_yaw , self . currentRates . rc_yaw_expo , self . currentRates . superexpo , self . currentRates . yawDeadband , maxAngularVel , '#0000ff' , 4 , curveContext ) ;
736748
737749 updateNeeded = false ;
738750 }
@@ -904,9 +916,9 @@ TABS.pid_tuning.renderModel = function () {
904916 if ( RC . channels [ 0 ] && RC . channels [ 1 ] && RC . channels [ 2 ] ) {
905917 var delta = this . clock . getDelta ( ) ;
906918
907- var roll = delta * this . rateCurve . rcCommandRawToDegreesPerSecond ( RC . channels [ 0 ] , this . currentRates . roll_rate , this . currentRates . rc_rate , this . currentRates . rc_expo , this . currentRates . superexpo ) ,
908- pitch = delta * this . rateCurve . rcCommandRawToDegreesPerSecond ( RC . channels [ 1 ] , this . currentRates . pitch_rate , this . currentRates . rc_rate , this . currentRates . rc_expo , this . currentRates . superexpo ) ,
909- yaw = delta * this . rateCurve . rcCommandRawToDegreesPerSecond ( RC . channels [ 2 ] , this . currentRates . yaw_rate , this . currentRates . rc_rate_yaw , this . currentRates . rc_yaw_expo , this . currentRates . superexpo ) ;
919+ var roll = delta * this . rateCurve . rcCommandRawToDegreesPerSecond ( RC . channels [ 0 ] , this . currentRates . roll_rate , this . currentRates . rc_rate , this . currentRates . rc_expo , this . currentRates . superexpo , this . currentRates . deadband ) ,
920+ pitch = delta * this . rateCurve . rcCommandRawToDegreesPerSecond ( RC . channels [ 1 ] , this . currentRates . pitch_rate , this . currentRates . rc_rate , this . currentRates . rc_expo , this . currentRates . superexpo , this . currentRates . deadband ) ,
921+ yaw = delta * this . rateCurve . rcCommandRawToDegreesPerSecond ( RC . channels [ 2 ] , this . currentRates . yaw_rate , this . currentRates . rc_rate_yaw , this . currentRates . rc_yaw_expo , this . currentRates . superexpo , this . currentRates . yawDeadband ) ;
910922
911923 this . model . rotateBy ( - degToRad ( pitch ) , - degToRad ( yaw ) , - degToRad ( roll ) ) ;
912924 }
0 commit comments