35 #ifndef TRANSMITTER_CONTROL_H
36 #define TRANSMITTER_CONTROL_H
39 #include "flightstatus.h"
40 #include "manualcontrolcommand.h"
41 #include "manualcontrolsettings.h"
42 #include "stabilizationdesired.h"
43 #include "stabilizationsettings.h"
49 #define assumptions1 ( \
50 ((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_DISABLED == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_DISABLED) && \
51 ((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_MANUAL == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_MANUAL) && \
52 ((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_RATE == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_RATE) && \
53 ((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_AXISLOCK == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK) && \
54 ((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_WEAKLEVELING == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING) && \
55 ((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_ATTITUDE == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE) &&\
56 ((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_LQG == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_LQG) &&\
57 ((int)MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_ATTITUDELQG == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDELQG) \
60 #define assumptions3 ( \
61 ((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_DISABLED == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_DISABLED) && \
62 ((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_MANUAL == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_MANUAL) && \
63 ((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_RATE == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_RATE) && \
64 ((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_AXISLOCK == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK) && \
65 ((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_WEAKLEVELING == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING) && \
66 ((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_ATTITUDE == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE) &&\
67 ((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_LQG == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_LQG) &&\
68 ((int)MANUALCONTROLSETTINGS_STABILIZATION2SETTINGS_ATTITUDELQG == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDELQG) \
71 #define assumptions5 ( \
72 ((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_DISABLED == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_DISABLED) && \
73 ((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_MANUAL == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_MANUAL) && \
74 ((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_RATE == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_RATE) && \
75 ((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_AXISLOCK == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_AXISLOCK) && \
76 ((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_WEAKLEVELING == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_WEAKLEVELING) && \
77 ((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_ATTITUDE == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDE) &&\
78 ((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_LQG == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_LQG) &&\
79 ((int)MANUALCONTROLSETTINGS_STABILIZATION3SETTINGS_ATTITUDELQG == (int)STABILIZATIONDESIRED_STABILIZATIONMODE_ATTITUDELQG) \
82 #define assumptions_flightmode ( \
83 ( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_MANUAL == (int) FLIGHTSTATUS_FLIGHTMODE_MANUAL) && \
84 ( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_ACRO == (int) FLIGHTSTATUS_FLIGHTMODE_ACRO) && \
85 ( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_LEVELING == (int) FLIGHTSTATUS_FLIGHTMODE_LEVELING) && \
86 ( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_HORIZON == (int) FLIGHTSTATUS_FLIGHTMODE_HORIZON) && \
87 ( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_AXISLOCK == (int) FLIGHTSTATUS_FLIGHTMODE_AXISLOCK) && \
88 ( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_VIRTUALBAR == (int) FLIGHTSTATUS_FLIGHTMODE_VIRTUALBAR) && \
89 ( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_STABILIZED1 == (int) FLIGHTSTATUS_FLIGHTMODE_STABILIZED1) && \
90 ( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_STABILIZED2 == (int) FLIGHTSTATUS_FLIGHTMODE_STABILIZED2) && \
91 ( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_STABILIZED3 == (int) FLIGHTSTATUS_FLIGHTMODE_STABILIZED3) && \
92 ( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_POSITIONHOLD == (int) FLIGHTSTATUS_FLIGHTMODE_POSITIONHOLD) && \
93 ( (int)MANUALCONTROLSETTINGS_FLIGHTMODEPOSITION_RETURNTOHOME == (int) FLIGHTSTATUS_FLIGHTMODE_RETURNTOHOME) \
96 #define assumptions_channelcount ( \
97 ( (int)MANUALCONTROLCOMMAND_CHANNEL_NUMELEM == (int)MANUALCONTROLSETTINGS_CHANNELGROUPS_NUMELEM ) && \
98 ( (int)MANUALCONTROLCOMMAND_CHANNEL_NUMELEM == (int)MANUALCONTROLSETTINGS_CHANNELNUMBER_NUMELEM ) && \
99 ( (int)MANUALCONTROLCOMMAND_CHANNEL_NUMELEM == (int)MANUALCONTROLSETTINGS_CHANNELMIN_NUMELEM ) && \
100 ( (int)MANUALCONTROLCOMMAND_CHANNEL_NUMELEM == (int)MANUALCONTROLSETTINGS_CHANNELMAX_NUMELEM ) && \
101 ( (int)MANUALCONTROLCOMMAND_CHANNEL_NUMELEM == (int)MANUALCONTROLSETTINGS_CHANNELNEUTRAL_NUMELEM ) )
109 #define NEQ(a,b) (((int) (a)) != ((int) (b)))
112 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_ROLL) ||
113 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_MANUALRATE_ROLL) ||
114 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_RATEEXPO_ROLL) ||
115 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_HORIZONEXPO_ROLL) ||
116 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_DEADBANDWIDTH_ROLL) ||
117 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_ROLL, STABILIZATIONSETTINGS_DEADBANDSLOPE_ROLL),
118 ROLLIndicesMismatch);
121 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_PITCH) ||
122 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_MANUALRATE_PITCH) ||
123 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_RATEEXPO_PITCH) ||
124 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_HORIZONEXPO_PITCH) ||
125 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_DEADBANDWIDTH_PITCH) ||
126 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_PITCH, STABILIZATIONSETTINGS_DEADBANDSLOPE_PITCH),
127 PITCHIndicesMismatch);
130 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, MANUALCONTROLSETTINGS_STABILIZATION1SETTINGS_YAW) ||
131 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_MANUALRATE_YAW) ||
132 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_RATEEXPO_YAW) ||
133 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_HORIZONEXPO_YAW) ||
134 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_DEADBANDWIDTH_YAW) ||
135 NEQ(STABILIZATIONDESIRED_STABILIZATIONMODE_YAW, STABILIZATIONSETTINGS_DEADBANDSLOPE_YAW),
#define assumptions_flightmode
int32_t transmitter_control_select(bool reset_controller)
Select and use transmitter control.
#define assumptions_channelcount
enum control_status transmitter_control_get_status()
Get any control events.
DONT_BUILD_IF(!(assumptions1), TransmitterControlAssumptions1)
int32_t transmitter_control_update()
Process inputs and arming.
int32_t transmitter_control_initialize()
Initialize the transmitter control mode.
uint8_t transmitter_control_get_flight_mode()
Query what the flight mode would be if this is selected.