35 #include "generated/airframe.h"
44 #define THRESHOLD_MANUAL_PPRZ (MIN_PPRZ / 2)
45 #define THRESHOLD1 THRESHOLD_MANUAL_PPRZ
46 #define THRESHOLD2 (MAX_PPRZ/2)
50 #define PPRZ_MODE_MANUAL 0
51 #define PPRZ_MODE_AUTO1 1
52 #define PPRZ_MODE_AUTO2 2
53 #define PPRZ_MODE_HOME 3
54 #define PPRZ_MODE_GPS_OUT_OF_ORDER 4
55 #define PPRZ_MODE_NB 5
57 #define PPRZ_MODE_OF_PULSE(pprz) \
58 (pprz > THRESHOLD2 ? PPRZ_MODE_AUTO2 : \
59 (pprz > THRESHOLD1 ? PPRZ_MODE_AUTO1 : PPRZ_MODE_MANUAL))
68 #define autopilot_ResetFlightTimeAndLaunch(_) { \
69 autopilot_flight_time = 0; launch = false; \
74 #define LATERAL_MODE_MANUAL 0
75 #define LATERAL_MODE_ROLL_RATE 1
76 #define LATERAL_MODE_ROLL 2
77 #define LATERAL_MODE_COURSE 3
78 #define LATERAL_MODE_NB 4
81 #define STICK_PUSHED(pprz) (pprz < THRESHOLD1 || pprz > THRESHOLD2)
82 #define FLOAT_OF_PPRZ(pprz, center, travel) ((float)pprz / (float)MAX_PPRZ * travel + center)
84 #define THROTTLE_THRESHOLD_TAKEOFF (pprz_t)(MAX_PPRZ * 0.9)
107 #define ModeUpdate(_mode, _value) ({ \
108 uint8_t new_mode = _value; \
109 (_mode != new_mode ? _mode = new_mode, TRUE : FALSE); \
120 #ifdef POWER_SWITCH_GPIO
122 #define autopilot_SetPowerSwitch(_x) { \
124 if (_x) { gpio_set(POWER_SWITCH_GPIO); } \
125 else { gpio_clear(POWER_SWITCH_GPIO); } \
127 #else // POWER_SWITCH_GPIO
128 #define autopilot_SetPowerSwitch(_x) { power_switch = _x; }
129 #endif // POWER_SWITCH_GPIO
135 #ifndef CONTROL_FREQUENCY
137 #define CONTROL_FREQUENCY CONTROL_RATE
138 #warning "CONTROL_RATE is deprecated. Please use CONTROL_FREQUENCY instead. Defaults to 60Hz if not defined."
140 #define CONTROL_FREQUENCY 60
141 #endif // CONTROL_RATE
142 #endif // CONTROL_FREQUENCY
144 #ifndef NAVIGATION_FREQUENCY
145 #define NAVIGATION_FREQUENCY 4
168 #include "pprzlink/pprzlink_transport.h"
uint16_t autopilot_flight_time
flight time in seconds.
static void autopilot_StoreSettings(float store)
Some architecture independent helper functions for GPIOs.
int32_t settings_store(void)
store settings marked as persistent to flash
void send_autopilot_version(struct transport_tx *trans, struct link_device *dev)
void autopilot_send_mode(void)
Send mode over telemetry.
int32_t settings_clear(void)
clear all persistent settings from flash
bool power_switch
Power switch control.
void autopilot_init(void)
Autopilot inititalization.
bool settings_store_flag
flag for setting feedback.
static const struct usb_device_descriptor dev
Persistent settings interface.
int32_t current
Supply current in milliAmpere.
float energy
Energy consumption (mAh) This is the ap copy of the measurement from fbw.
static void autopilot_ClearSettings(float clear)
uint16_t vsupply
Supply voltage in deciVolt.