APM:Libraries
libraries
AP_HAL_SITL
RCInput.cpp
Go to the documentation of this file.
1
#include <
AP_HAL/AP_HAL.h
>
2
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
3
4
#include "
RCInput.h
"
5
6
using namespace
HALSITL
;
7
8
extern
const
AP_HAL::HAL
&
hal
;
9
10
void
RCInput::init
()
11
{
12
clear_overrides
();
13
}
14
15
bool
RCInput::new_input
()
16
{
17
if
(
_sitlState
->
new_rc_input
) {
18
_sitlState
->
new_rc_input
=
false
;
19
return
true
;
20
}
21
return
false
;
22
}
23
24
uint16_t
RCInput::read
(uint8_t ch)
25
{
26
if
(ch >=
SITL_RC_INPUT_CHANNELS
) {
27
return
0;
28
}
29
if
(
_override
[ch]) {
30
return
_override
[ch];
31
}
32
return
_sitlState
->
pwm_input
[ch];
33
}
34
35
uint8_t
RCInput::read
(uint16_t* periods, uint8_t len)
36
{
37
if
(len >
SITL_RC_INPUT_CHANNELS
) {
38
len =
SITL_RC_INPUT_CHANNELS
;
39
}
40
for
(uint8_t i=0; i < len; i++) {
41
periods[i] =
read
(i);
42
}
43
return
len;
44
}
45
46
bool
RCInput::set_override
(uint8_t channel, int16_t
override
)
47
{
48
if
(
override
< 0) {
49
return
false
;
/* -1: no change. */
50
}
51
if
(channel <
SITL_RC_INPUT_CHANNELS
) {
52
_override
[channel] =
static_cast<
uint16_t
>
(
override
);
53
if
(
override
!= 0) {
54
return
true
;
55
}
56
}
57
return
false
;
58
}
59
60
void
RCInput::clear_overrides
()
61
{
62
memset(
_override
, 0,
sizeof
(
_override
));
63
}
64
#endif
HALSITL::RCInput::_override
uint16_t _override[SITL_RC_INPUT_CHANNELS]
Definition:
RCInput.h:28
RCInput.h
HALSITL::RCInput::read
uint16_t read(uint8_t ch) override
Definition:
RCInput.cpp:24
HALSITL::SITL_State::new_rc_input
bool new_rc_input
Definition:
SITL_State.h:50
AP_HAL.h
HALSITL::SITL_State::pwm_input
uint16_t pwm_input[SITL_RC_INPUT_CHANNELS]
Definition:
SITL_State.h:48
AP_HAL::HAL
Definition:
HAL.h:26
SITL_RC_INPUT_CHANNELS
#define SITL_RC_INPUT_CHANNELS
Definition:
RCInput.h:6
hal
const AP_HAL::HAL & hal
-*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
Definition:
RCInput.cpp:10
HALSITL::RCInput::set_override
bool set_override(uint8_t channel, int16_t override) override
Definition:
RCInput.cpp:46
HALSITL::RCInput::init
void init() override
Definition:
RCInput.cpp:10
HALSITL::RCInput::new_input
bool new_input() override
Definition:
RCInput.cpp:15
HALSITL
Definition:
AP_HAL_SITL_Namespace.h:3
HALSITL::RCInput::clear_overrides
void clear_overrides() override
Definition:
RCInput.cpp:60
HALSITL::RCInput::_sitlState
SITL_State * _sitlState
Definition:
RCInput.h:25
Generated on Sun Jun 17 2018 14:18:48 for APM:Libraries by
1.8.13