|
|
|
@ -8,6 +8,7 @@
@@ -8,6 +8,7 @@
|
|
|
|
|
|
|
|
|
|
#include <stdint.h> |
|
|
|
|
#include <FastSerial.h> |
|
|
|
|
#include <APM_RC.h> |
|
|
|
|
|
|
|
|
|
/// @class AP_RcChannel
|
|
|
|
|
/// @brief Object managing one RC channel
|
|
|
|
@ -18,30 +19,31 @@ public:
@@ -18,30 +19,31 @@ public:
|
|
|
|
|
|
|
|
|
|
/// Constructor
|
|
|
|
|
///
|
|
|
|
|
AP_RcChannel(const float & scale, const uint16_t & pwmMin, const uint16_t & pwmNeutral, |
|
|
|
|
AP_RcChannel(const APM_RC_Class & rc, const uint16_t & ch, |
|
|
|
|
const float & scale, const uint16_t & pwmMin, const uint16_t & pwmNeutral, |
|
|
|
|
const uint16_t & pwmMax, const uint16_t & pwmDeadZone, |
|
|
|
|
const bool & filter, const bool & reverse) : |
|
|
|
|
_rc(rc), |
|
|
|
|
_ch(ch), |
|
|
|
|
_scale(scale), |
|
|
|
|
_pwmMin(pwmMin), |
|
|
|
|
_pwmMax(pwmMax), |
|
|
|
|
_pwmNeutral(pwmNeutral), |
|
|
|
|
_pwmDeadZone(pwmDeadZone), |
|
|
|
|
_pwm(0), |
|
|
|
|
_pwmRadio(0), |
|
|
|
|
_filter(filter), |
|
|
|
|
_reverse(reverse) |
|
|
|
|
{ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// set servo state
|
|
|
|
|
void readRadio(uint16_t pwmRadio); |
|
|
|
|
void readRadio(); |
|
|
|
|
void setPwm(uint16_t pwm); |
|
|
|
|
void setPosition(float position); |
|
|
|
|
void mixRadio(uint16_t infStart); |
|
|
|
|
|
|
|
|
|
// get servo state
|
|
|
|
|
uint16_t getPwm() { return _pwm; } |
|
|
|
|
uint16_t getPwmRadio() { return _pwmRadio; } |
|
|
|
|
float getPosition() { return _pwmToPosition(_pwm); } |
|
|
|
|
float getNormalized() { return getPosition()/_scale; } |
|
|
|
|
|
|
|
|
@ -51,6 +53,8 @@ public:
@@ -51,6 +53,8 @@ public:
|
|
|
|
|
private: |
|
|
|
|
|
|
|
|
|
// configuration
|
|
|
|
|
const APM_RC_Class & _rc; |
|
|
|
|
const uint16_t _ch; |
|
|
|
|
const float & _scale; |
|
|
|
|
const uint16_t & _pwmMin; |
|
|
|
|
const uint16_t & _pwmNeutral; |
|
|
|
@ -60,8 +64,7 @@ private:
@@ -60,8 +64,7 @@ private:
|
|
|
|
|
const bool & _reverse; |
|
|
|
|
|
|
|
|
|
// internal states
|
|
|
|
|
uint16_t _pwm; // this is the internal state, positino is just created when needed
|
|
|
|
|
uint16_t _pwmRadio; // radio pwm input
|
|
|
|
|
uint16_t _pwm; // this is the internal state, position is just created when needed
|
|
|
|
|
|
|
|
|
|
// private methods
|
|
|
|
|
uint16_t _positionToPwm(const float & position); |
|
|
|
|