Browse Source

RC_Channel: New method to detect if channel is in trim location

This is a new method which will return true if an RC_Channel has a PWM
value that is at its TRIM value plus or minus the allowed dead zone
around the TRIM.
master
Grant Morphett 10 years ago committed by Andrew Tridgell
parent
commit
7edf8c0e0a
  1. 8
      libraries/RC_Channel/RC_Channel.cpp
  2. 2
      libraries/RC_Channel/RC_Channel.h

8
libraries/RC_Channel/RC_Channel.cpp

@ -511,3 +511,11 @@ uint16_t RC_Channel::get_limit_pwm(LimitValue limit) const @@ -511,3 +511,11 @@ uint16_t RC_Channel::get_limit_pwm(LimitValue limit) const
// invalid limit value, return trim
return radio_trim;
}
/*
Return true if the channel is at trim and within the DZ
*/
bool RC_Channel::in_trim_dz()
{
return is_bounded(radio_in, radio_trim - _dead_zone, radio_trim + _dead_zone);
}

2
libraries/RC_Channel/RC_Channel.h

@ -135,6 +135,8 @@ public: @@ -135,6 +135,8 @@ public:
static RC_Channel *rc_channel(uint8_t i);
bool in_trim_dz();
private:
AP_Int8 _reverse;
AP_Int16 _dead_zone;

Loading…
Cancel
Save