From bff978570f1c2f9403e2bad8ed9b654ed7fe0bcb Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Thu, 30 Jan 2020 10:01:54 +0900 Subject: [PATCH] AP_MotorsMulticopter: fixup check_mot_pwm_params fix _pwm_max is positive check returns true if params are valid constify method --- libraries/AP_Motors/AP_MotorsMulticopter.cpp | 12 ++++++------ libraries/AP_Motors/AP_MotorsMulticopter.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/AP_Motors/AP_MotorsMulticopter.cpp b/libraries/AP_Motors/AP_MotorsMulticopter.cpp index 12bee1a434..c2facd4b24 100644 --- a/libraries/AP_Motors/AP_MotorsMulticopter.cpp +++ b/libraries/AP_Motors/AP_MotorsMulticopter.cpp @@ -483,14 +483,14 @@ int16_t AP_MotorsMulticopter::get_pwm_output_max() const return _throttle_radio_max; } -// parameter checks for MOT_PWM_MIN/MAX -bool AP_MotorsMulticopter::check_mot_pwm_params() +// parameter checks for MOT_PWM_MIN/MAX, returns true if parameters are valid +bool AP_MotorsMulticopter::check_mot_pwm_params() const { - if ((_pwm_min == 0 && _pwm_max !=0) || (_pwm_min != 0 && _pwm_max == 0) || - (_pwm_min < 0 || _pwm_min < 0) || (_pwm_min > _pwm_max)) { - return true; + if ((_pwm_min == 0 && _pwm_max != 0) || (_pwm_min != 0 && _pwm_max == 0) || + (_pwm_min < 0 || _pwm_max < 0) || (_pwm_min > _pwm_max)) { + return false; } - return false; + return true; } // set_throttle_range - sets the minimum throttle that will be sent to the engines when they're not off (i.e. to prevents issues with some motors spinning and some not at very low throttle) diff --git a/libraries/AP_Motors/AP_MotorsMulticopter.h b/libraries/AP_Motors/AP_MotorsMulticopter.h index 5d310561a9..27650fabfa 100644 --- a/libraries/AP_Motors/AP_MotorsMulticopter.h +++ b/libraries/AP_Motors/AP_MotorsMulticopter.h @@ -84,8 +84,8 @@ public: int16_t get_pwm_output_min() const; int16_t get_pwm_output_max() const; - // parameter check for MOT_PWM_MIN/MAX - bool check_mot_pwm_params(); + // parameter check for MOT_PWM_MIN/MAX, returns true if parameters are valid + bool check_mot_pwm_params() const; // set thrust compensation callback FUNCTOR_TYPEDEF(thrust_compensation_fn_t, void, float *, uint8_t);