@@ -321,21 +321,21 @@ TuningSliders.legacyCalculateNewPids = function() {
321321 // only used for 4.1 where calculation is not done in firmware
322322 if ( this . dMinFeatureEnabled ) {
323323 //dmin
324- FC . ADVANCED_TUNING . dMinRoll = Math . floor ( this . PID_DEFAULT [ 3 ] * this . sliderPDGain * this . sliderPDRatio ) ;
325- FC . ADVANCED_TUNING . dMinPitch = Math . floor ( this . PID_DEFAULT [ 8 ] * this . sliderPDGain * this . sliderPDRatio ) ;
324+ FC . ADVANCED_TUNING . dMinRoll = Math . round ( this . PID_DEFAULT [ 3 ] * this . sliderPDGain * this . sliderPDRatio ) ;
325+ FC . ADVANCED_TUNING . dMinPitch = Math . round ( this . PID_DEFAULT [ 8 ] * this . sliderPDGain * this . sliderPDRatio ) ;
326326 // dmax
327- FC . PIDS [ 0 ] [ 2 ] = Math . floor ( this . PID_DEFAULT [ 2 ] * this . sliderPDGain * this . sliderPDRatio ) ;
328- FC . PIDS [ 1 ] [ 2 ] = Math . floor ( this . PID_DEFAULT [ 7 ] * this . sliderPDGain * this . sliderPDRatio ) ;
327+ FC . PIDS [ 0 ] [ 2 ] = Math . round ( this . PID_DEFAULT [ 2 ] * this . sliderPDGain * this . sliderPDRatio ) ;
328+ FC . PIDS [ 1 ] [ 2 ] = Math . round ( this . PID_DEFAULT [ 7 ] * this . sliderPDGain * this . sliderPDRatio ) ;
329329 } else {
330330 FC . ADVANCED_TUNING . dMinRoll = 0 ;
331331 FC . ADVANCED_TUNING . dMinPitch = 0 ;
332- FC . PIDS [ 0 ] [ 2 ] = Math . floor ( ( this . PID_DEFAULT [ 2 ] * D_MIN_RATIO ) * this . sliderPDGain * this . sliderPDRatio ) ;
333- FC . PIDS [ 1 ] [ 2 ] = Math . floor ( ( this . PID_DEFAULT [ 7 ] * D_MIN_RATIO ) * this . sliderPDGain * this . sliderPDRatio ) ;
332+ FC . PIDS [ 0 ] [ 2 ] = Math . round ( ( this . PID_DEFAULT [ 2 ] * D_MIN_RATIO ) * this . sliderPDGain * this . sliderPDRatio ) ;
333+ FC . PIDS [ 1 ] [ 2 ] = Math . round ( ( this . PID_DEFAULT [ 7 ] * D_MIN_RATIO ) * this . sliderPDGain * this . sliderPDRatio ) ;
334334 }
335335
336- FC . PIDS [ 0 ] [ 0 ] = Math . floor ( this . PID_DEFAULT [ 0 ] * this . sliderPDGain ) ;
337- FC . PIDS [ 1 ] [ 0 ] = Math . floor ( this . PID_DEFAULT [ 5 ] * this . sliderPDGain ) ;
338- FC . PIDS [ 2 ] [ 0 ] = Math . floor ( this . PID_DEFAULT [ 10 ] * this . sliderPDGain ) ;
336+ FC . PIDS [ 0 ] [ 0 ] = Math . round ( this . PID_DEFAULT [ 0 ] * this . sliderPDGain ) ;
337+ FC . PIDS [ 1 ] [ 0 ] = Math . round ( this . PID_DEFAULT [ 5 ] * this . sliderPDGain ) ;
338+ FC . PIDS [ 2 ] [ 0 ] = Math . round ( this . PID_DEFAULT [ 10 ] * this . sliderPDGain ) ;
339339 // ff
340340 FC . ADVANCED_TUNING . feedforwardRoll = Math . round ( this . PID_DEFAULT [ 4 ] * this . sliderFFGain ) ;
341341 FC . ADVANCED_TUNING . feedforwardPitch = Math . round ( this . PID_DEFAULT [ 9 ] * this . sliderFFGain ) ;
@@ -361,19 +361,18 @@ TuningSliders.legacyCalculateNewPids = function() {
361361 FC . ADVANCED_TUNING . feedforwardYaw = Math . min ( Math . round ( FC . ADVANCED_TUNING . feedforwardYaw * this . sliderMasterMultiplier ) , MAX_FF_GAIN ) ;
362362
363363 if ( this . dMinFeatureEnabled ) {
364- FC . ADVANCED_TUNING . dMinRoll = Math . min ( Math . floor ( FC . ADVANCED_TUNING . dMinRoll * this . sliderMasterMultiplier ) , MAX_DMIN_GAIN ) ;
365- FC . ADVANCED_TUNING . dMinPitch = Math . min ( Math . floor ( FC . ADVANCED_TUNING . dMinPitch * this . sliderMasterMultiplier ) , MAX_DMIN_GAIN ) ;
366- FC . ADVANCED_TUNING . dMinYaw = Math . min ( Math . floor ( FC . ADVANCED_TUNING . dMinYaw * this . sliderMasterMultiplier ) , MAX_DMIN_GAIN ) ;
364+ FC . ADVANCED_TUNING . dMinRoll = Math . min ( Math . round ( FC . ADVANCED_TUNING . dMinRoll * this . sliderMasterMultiplier ) , MAX_DMIN_GAIN ) ;
365+ FC . ADVANCED_TUNING . dMinPitch = Math . min ( Math . round ( FC . ADVANCED_TUNING . dMinPitch * this . sliderMasterMultiplier ) , MAX_DMIN_GAIN ) ;
366+ FC . ADVANCED_TUNING . dMinYaw = Math . min ( Math . round ( FC . ADVANCED_TUNING . dMinYaw * this . sliderMasterMultiplier ) , MAX_DMIN_GAIN ) ;
367367 }
368368
369- this . updateFormPids ( ) ;
370-
371369 $ ( '.pid_tuning input[name="dMinRoll"]' ) . val ( FC . ADVANCED_TUNING . dMinRoll ) ;
372370 $ ( '.pid_tuning input[name="dMinPitch"]' ) . val ( FC . ADVANCED_TUNING . dMinPitch ) ;
373371 $ ( '.pid_tuning input[name="dMinYaw"]' ) . val ( FC . ADVANCED_TUNING . dMinYaw ) ;
374372 $ ( '.pid_tuning .ROLL input[name="f"]' ) . val ( FC . ADVANCED_TUNING . feedforwardRoll ) ;
375373 $ ( '.pid_tuning .PITCH input[name="f"]' ) . val ( FC . ADVANCED_TUNING . feedforwardPitch ) ;
376374 $ ( '.pid_tuning .YAW input[name="f"]' ) . val ( FC . ADVANCED_TUNING . feedforwardYaw ) ;
375+ this . updateFormPids ( ) ;
377376} ;
378377
379378TuningSliders . calculateNewPids = function ( ) {
@@ -409,19 +408,18 @@ TuningSliders.calculateNewPids = function() {
409408
410409 Promise . resolve ( true )
411410 . then ( ( ) => { return MSP . promise ( MSPCodes . MSP_SET_TUNING_SLIDERS , mspHelper . crunch ( MSPCodes . MSP_SET_TUNING_SLIDERS ) ) ; } )
412- . then ( ( ) => { return MSP . send_message ( MSPCodes . MSP_SET_PID ) ; } )
413- . then ( ( ) => { return MSP . send_message ( MSPCodes . MSP_SET_PID_ADVANCED ) ; } ) ;
411+ . then ( ( ) => { return MSP . send_message ( MSPCodes . MSP_PID ) ; } )
412+ . then ( ( ) => { return MSP . send_message ( MSPCodes . MSP_PID_ADVANCED ) ; } ) ;
414413 }
415414
416- this . updateFormPids ( ) ;
417-
418415 $ ( '.pid_tuning input[name="dMinRoll"]' ) . val ( FC . ADVANCED_TUNING . dMinRoll ) ;
419416 $ ( '.pid_tuning input[name="dMinPitch"]' ) . val ( FC . ADVANCED_TUNING . dMinPitch ) ;
420417 $ ( '.pid_tuning input[name="dMinYaw"]' ) . val ( FC . ADVANCED_TUNING . dMinYaw ) ;
421418 $ ( '.pid_tuning .ROLL input[name="f"]' ) . val ( FC . ADVANCED_TUNING . feedforwardRoll ) ;
422419 $ ( '.pid_tuning .PITCH input[name="f"]' ) . val ( FC . ADVANCED_TUNING . feedforwardPitch ) ;
423420 $ ( '.pid_tuning .YAW input[name="f"]' ) . val ( FC . ADVANCED_TUNING . feedforwardYaw ) ;
424421
422+ this . updateFormPids ( ) ;
425423 TABS . pid_tuning . updatePIDColors ( ) ;
426424} ;
427425
0 commit comments