28 #ifndef AUTOPILOT_RC_HELPERS_H
29 #define AUTOPILOT_RC_HELPERS_H
31 #include "generated/airframe.h"
33 #include "generated/modules.h"
35 #define AUTOPILOT_THROTTLE_THRESHOLD (MAX_PPRZ / 20)
36 #define AUTOPILOT_YAW_THRESHOLD (MAX_PPRZ * 19 / 20)
37 #ifndef AUTOPILOT_STICK_CENTER_THRESHOLD
38 #define AUTOPILOT_STICK_CENTER_THRESHOLD (MAX_PPRZ * 1 / 20)
41 #define THROTTLE_STICK_DOWN() \
42 (radio_control.values[RADIO_THROTTLE] < AUTOPILOT_THROTTLE_THRESHOLD)
43 #define YAW_STICK_PUSHED() \
44 (radio_control.values[RADIO_YAW] > AUTOPILOT_YAW_THRESHOLD || \
45 radio_control.values[RADIO_YAW] < -AUTOPILOT_YAW_THRESHOLD)
46 #define YAW_STICK_CENTERED() \
47 (radio_control.values[RADIO_YAW] < AUTOPILOT_STICK_CENTER_THRESHOLD && \
48 radio_control.values[RADIO_YAW] > -AUTOPILOT_STICK_CENTER_THRESHOLD)
49 #define PITCH_STICK_CENTERED() \
50 (radio_control.values[RADIO_PITCH] < AUTOPILOT_STICK_CENTER_THRESHOLD && \
51 radio_control.values[RADIO_PITCH] > -AUTOPILOT_STICK_CENTER_THRESHOLD)
52 #define ROLL_STICK_CENTERED() \
53 (radio_control.values[RADIO_ROLL] < AUTOPILOT_STICK_CENTER_THRESHOLD && \
54 radio_control.values[RADIO_ROLL] > -AUTOPILOT_STICK_CENTER_THRESHOLD)
67 if (pos >= max)
return false;
78 #define RCMode0() rc_mode_switch(RADIO_MODE, 0, 3)
79 #define RCMode1() rc_mode_switch(RADIO_MODE, 1, 3)
80 #define RCMode2() rc_mode_switch(RADIO_MODE, 2, 3)
88 #ifdef RADIO_KILL_SWITCH
109 }
else if (per > 100) {
struct RadioControl radio_control
Generic interface for radio control modules.
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
#define RADIO_KILL_SWITCH
#define ROLL_STICK_CENTERED()
#define PITCH_STICK_CENTERED()
static uint8_t percent_from_rc(int channel)
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.
#define YAW_STICK_CENTERED()
static bool kill_switch_is_on(void)
static bool rc_attitude_sticks_centered(void)
Convenience macro for 3way switch.
int int32_t
Typedef defining 32 bit int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.