ardupilot/libraries/AP_HAL_Linux/RCInput.cpp

76 lines
1.3 KiB
C++
Raw Normal View History

2013-12-30 19:00:04 -04:00
#include <AP_HAL.h>
2014-07-06 23:03:26 -03:00
#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX
2013-09-22 03:01:24 -03:00
#include "RCInput.h"
using namespace Linux;
LinuxRCInput::LinuxRCInput() :
new_rc_input(false)
2013-09-22 03:01:24 -03:00
{}
void LinuxRCInput::init(void* machtnichts)
{}
bool LinuxRCInput::new_input()
{
return new_rc_input;
}
uint8_t LinuxRCInput::num_channels()
{
return 8;
2013-09-22 03:01:24 -03:00
}
uint16_t LinuxRCInput::read(uint8_t ch)
{
new_rc_input = false;
if (_override[ch]) {
return _override[ch];
}
if (ch == 2) {
// force low throttle for now
return 900;
}
return 1500;
2013-09-22 03:01:24 -03:00
}
uint8_t LinuxRCInput::read(uint16_t* periods, uint8_t len)
{
for (uint8_t i=0; i<len; i++) {
periods[i] = read(i);
2013-09-22 03:01:24 -03:00
}
return 8;
2013-09-22 03:01:24 -03:00
}
bool LinuxRCInput::set_overrides(int16_t *overrides, uint8_t len)
{
bool res = false;
for (uint8_t i = 0; i < len; i++) {
res |= set_override(i, overrides[i]);
}
return res;
2013-09-22 03:01:24 -03:00
}
bool LinuxRCInput::set_override(uint8_t channel, int16_t override)
{
if (override < 0) return false; /* -1: no change. */
if (channel < 8) {
_override[channel] = override;
if (override != 0) {
new_rc_input = true;
return true;
}
}
return false;
2013-09-22 03:01:24 -03:00
}
void LinuxRCInput::clear_overrides()
{
for (uint8_t i = 0; i < 8; i++) {
_override[i] = 0;
}
}
2013-09-22 03:01:24 -03:00
2013-12-30 19:00:04 -04:00
#endif // CONFIG_HAL_BOARD