From 77d4b3a2ae1031f68f87426045e123457cd933dd Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Sat, 21 Feb 2015 15:45:56 +0900 Subject: [PATCH] Motors: add loop_rate to constructor --- libraries/AP_Motors/AP_Motors_Class.cpp | 3 ++- libraries/AP_Motors/AP_Motors_Class.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/AP_Motors/AP_Motors_Class.cpp b/libraries/AP_Motors/AP_Motors_Class.cpp index 47ce3b1d4a..10b664339f 100644 --- a/libraries/AP_Motors/AP_Motors_Class.cpp +++ b/libraries/AP_Motors/AP_Motors_Class.cpp @@ -126,11 +126,12 @@ const AP_Param::GroupInfo AP_Motors::var_info[] PROGMEM = { }; // Constructor -AP_Motors::AP_Motors( RC_Channel& rc_roll, RC_Channel& rc_pitch, RC_Channel& rc_throttle, RC_Channel& rc_yaw, uint16_t speed_hz ) : +AP_Motors::AP_Motors(RC_Channel& rc_roll, RC_Channel& rc_pitch, RC_Channel& rc_throttle, RC_Channel& rc_yaw, uint16_t loop_rate, uint16_t speed_hz) : _rc_roll(rc_roll), _rc_pitch(rc_pitch), _rc_throttle(rc_throttle), _rc_yaw(rc_yaw), + _loop_rate(loop_rate), _speed_hz(speed_hz), _min_throttle(AP_MOTORS_DEFAULT_MIN_THROTTLE), _max_throttle(AP_MOTORS_DEFAULT_MAX_THROTTLE), diff --git a/libraries/AP_Motors/AP_Motors_Class.h b/libraries/AP_Motors/AP_Motors_Class.h index 85455b1950..b66e7d9d93 100644 --- a/libraries/AP_Motors/AP_Motors_Class.h +++ b/libraries/AP_Motors/AP_Motors_Class.h @@ -85,7 +85,7 @@ class AP_Motors { public: // Constructor - AP_Motors( RC_Channel& rc_roll, RC_Channel& rc_pitch, RC_Channel& rc_throttle, RC_Channel& rc_yaw, uint16_t speed_hz = AP_MOTORS_SPEED_DEFAULT); + AP_Motors(RC_Channel& rc_roll, RC_Channel& rc_pitch, RC_Channel& rc_throttle, RC_Channel& rc_yaw, uint16_t loop_rate, uint16_t speed_hz = AP_MOTORS_SPEED_DEFAULT); // init virtual void Init(); @@ -211,6 +211,7 @@ protected: RC_Channel& _rc_pitch; // pitch input in from users is held in servo_out RC_Channel& _rc_throttle; // throttle input in from users is held in servo_out RC_Channel& _rc_yaw; // yaw input in from users is held in servo_out + uint16_t _loop_rate; // rate at which output() function is called (normally 400hz) uint16_t _speed_hz; // speed in hz to send updates to motors int16_t _min_throttle; // the minimum throttle to be sent to the motors when they're on (prevents motors stalling while flying) int16_t _max_throttle; // the maximum throttle to be sent to the motors (sometimes limited by slow start)