mirror of
https://github.com/ArduPilot/ardupilot.git
synced 2026-10-08 02:57:16 +08:00
RC_Channel: added get_pwm() function for Lua
This commit is contained in:
committed by
WickedShell
parent
d332773689
commit
dfd7b022fd
@@ -201,6 +201,25 @@ void RC_Channels::read_mode_switch()
|
||||
c->read_mode_switch();
|
||||
}
|
||||
|
||||
/*
|
||||
get the RC input PWM value given a channel number. Note that
|
||||
channel numbers start at 1, as this API is designed for use in
|
||||
LUA
|
||||
*/
|
||||
bool RC_Channels::get_pwm(uint8_t c, uint16_t &pwm) const
|
||||
{
|
||||
if (c < 1 || c > NUM_RC_CHANNELS) {
|
||||
return false;
|
||||
}
|
||||
RC_Channel *chan = rc_channel(c-1);
|
||||
int16_t pwm_signed = chan->get_radio_in();
|
||||
if (pwm_signed < 0) {
|
||||
return false;
|
||||
}
|
||||
pwm = (uint16_t)pwm_signed;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// singleton instance
|
||||
RC_Channels *RC_Channels::_singleton;
|
||||
|
||||
Reference in New Issue
Block a user