28 #ifndef AUTOPILOT_RC_HELPERS_H
29 #define AUTOPILOT_RC_HELPERS_H
31 #include "generated/airframe.h"
34 #define AUTOPILOT_THROTTLE_THRESHOLD (MAX_PPRZ / 20)
35 #define AUTOPILOT_YAW_THRESHOLD (MAX_PPRZ * 19 / 20)
36 #ifndef AUTOPILOT_STICK_CENTER_THRESHOLD
37 #define AUTOPILOT_STICK_CENTER_THRESHOLD (MAX_PPRZ * 1 / 20)
40 #define THROTTLE_STICK_DOWN() \
41 (radio_control.values[RADIO_THROTTLE] < AUTOPILOT_THROTTLE_THRESHOLD)
42 #define YAW_STICK_PUSHED() \
43 (radio_control.values[RADIO_YAW] > AUTOPILOT_YAW_THRESHOLD || \
44 radio_control.values[RADIO_YAW] < -AUTOPILOT_YAW_THRESHOLD)
45 #define YAW_STICK_CENTERED() \
46 (radio_control.values[RADIO_YAW] < AUTOPILOT_STICK_CENTER_THRESHOLD && \
47 radio_control.values[RADIO_YAW] > -AUTOPILOT_STICK_CENTER_THRESHOLD)
48 #define PITCH_STICK_CENTERED() \
49 (radio_control.values[RADIO_PITCH] < AUTOPILOT_STICK_CENTER_THRESHOLD && \
50 radio_control.values[RADIO_PITCH] > -AUTOPILOT_STICK_CENTER_THRESHOLD)
51 #define ROLL_STICK_CENTERED() \
52 (radio_control.values[RADIO_ROLL] < AUTOPILOT_STICK_CENTER_THRESHOLD && \
53 radio_control.values[RADIO_ROLL] > -AUTOPILOT_STICK_CENTER_THRESHOLD)
66 if (pos >= max)
return false;
77 #define RCMode0() rc_mode_switch(RADIO_MODE, 0, 3)
78 #define RCMode1() rc_mode_switch(RADIO_MODE, 1, 3)
79 #define RCMode2() rc_mode_switch(RADIO_MODE, 2, 3)
87 #ifdef RADIO_KILL_SWITCH
108 }
else if (per > 100) {
#define YAW_STICK_CENTERED()
static bool rc_mode_switch(uint8_t chan, uint8_t pos, uint8_t max)
RC mode switch position helper switch positions threshold are evenly spaced.
static uint8_t percent_from_rc(int channel)
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
#define PITCH_STICK_CENTERED()
struct RadioControl radio_control
#define RADIO_KILL_SWITCH
#define ROLL_STICK_CENTERED()
static bool rc_attitude_sticks_centered(void)
Convenience macro for 3way switch.
static bool kill_switch_is_on(void)