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.
This commit is contained in:
Grant Morphett 2015-10-30 16:46:03 +11:00 committed by Andrew Tridgell
parent 2d1745ab6a
commit 7edf8c0e0a
2 changed files with 10 additions and 0 deletions

View File

@ -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);
}

View File

@ -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;