./src/utils/ trim trailing whitestpaces (#14082)
[betaflight.git] / src / main / cli / settings.h
blobb67664a0e8cb339d76ee7af00464e3aeb2a592cc
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
21 #pragma once
23 #include <stdint.h>
24 #include <stdbool.h>
25 #include "pg/pg.h"
27 typedef enum {
28 TABLE_OFF_ON = 0,
29 TABLE_UNIT,
30 TABLE_ALIGNMENT,
31 #ifdef USE_GPS
32 TABLE_GPS_PROVIDER,
33 TABLE_GPS_SBAS_MODE,
34 TABLE_GPS_UBLOX_MODELS,
35 TABLE_GPS_UBLOX_UTC_STANDARD,
36 #endif
37 #ifdef USE_GPS_RESCUE
38 TABLE_GPS_RESCUE_SANITY_CHECK,
39 TABLE_GPS_RESCUE_ALT_MODE,
40 #endif
41 #ifdef USE_BLACKBOX
42 TABLE_BLACKBOX_DEVICE,
43 TABLE_BLACKBOX_MODE,
44 TABLE_BLACKBOX_SAMPLE_RATE,
45 #endif
46 TABLE_CURRENT_METER,
47 TABLE_VOLTAGE_METER,
48 #ifdef USE_SERVOS
49 TABLE_GIMBAL_MODE,
50 #endif
51 #ifdef USE_SERIALRX
52 TABLE_SERIAL_RX,
53 #endif
54 #ifdef USE_RX_SPI
55 TABLE_RX_SPI,
56 #endif
57 TABLE_GYRO_HARDWARE_LPF,
58 TABLE_ACC_HARDWARE,
59 #ifdef USE_BARO
60 TABLE_BARO_HARDWARE,
61 #endif
62 #ifdef USE_MAG
63 TABLE_MAG_HARDWARE,
64 #endif
65 TABLE_DEBUG,
66 TABLE_MOTOR_PWM_PROTOCOL,
67 TABLE_GYRO_LPF_TYPE,
68 TABLE_DTERM_LPF_TYPE,
69 TABLE_FAILSAFE,
70 TABLE_FAILSAFE_SWITCH_MODE,
71 TABLE_CRASH_RECOVERY,
72 #ifdef USE_CAMERA_CONTROL
73 TABLE_CAMERA_CONTROL_MODE,
74 #endif
75 TABLE_BUS_TYPE,
76 #ifdef USE_MAX7456
77 TABLE_MAX7456_CLOCK,
78 #endif
79 #ifdef USE_RX_FRSKY_SPI
80 TABLE_RX_FRSKY_SPI_A1_SOURCE,
81 #endif
82 #ifdef USE_RANGEFINDER
83 TABLE_RANGEFINDER_HARDWARE,
84 #endif
85 #ifdef USE_GYRO_OVERFLOW_CHECK
86 TABLE_GYRO_OVERFLOW_CHECK,
87 #endif
88 TABLE_RATES_TYPE,
89 #ifdef USE_OVERCLOCK
90 TABLE_OVERCLOCK,
91 #endif
92 #ifdef USE_LED_STRIP
93 TABLE_RGB_GRB,
94 #endif
95 #ifdef USE_MULTI_GYRO
96 TABLE_GYRO,
97 #endif
98 TABLE_THROTTLE_LIMIT_TYPE,
99 #if defined(USE_VIDEO_SYSTEM)
100 TABLE_VIDEO_SYSTEM,
101 #endif
102 #if defined(USE_ITERM_RELAX)
103 TABLE_ITERM_RELAX,
104 TABLE_ITERM_RELAX_TYPE,
105 #endif
106 #ifdef USE_ACRO_TRAINER
107 TABLE_ACRO_TRAINER_DEBUG,
108 #endif // USE_ACRO_TRAINER
109 #ifdef USE_RC_SMOOTHING_FILTER
110 TABLE_RC_SMOOTHING_DEBUG,
111 #endif // USE_RC_SMOOTHING_FILTER
112 #ifdef USE_VTX_COMMON
113 TABLE_VTX_LOW_POWER_DISARM,
114 #endif
115 TABLE_GYRO_HARDWARE,
116 #ifdef USE_SDCARD
117 TABLE_SDCARD_MODE,
118 #endif
119 #ifdef USE_LAUNCH_CONTROL
120 TABLE_LAUNCH_CONTROL_MODE,
121 #endif
122 TABLE_TPA_MODE,
123 TABLE_SPA_MODE,
124 #ifdef USE_LED_STRIP
125 TABLE_LED_PROFILE,
126 TABLE_LEDSTRIP_COLOR,
127 #endif
128 TABLE_GYRO_FILTER_DEBUG,
129 TABLE_POSITION_ALT_SOURCE,
130 TABLE_OFF_ON_AUTO,
131 TABLE_FEEDFORWARD_AVERAGING,
132 TABLE_DSHOT_BITBANGED_TIMER,
133 TABLE_OSD_DISPLAYPORT_DEVICE,
134 #ifdef USE_OSD
135 TABLE_OSD_LOGO_ON_ARMING,
136 #endif
137 TABLE_MIXER_TYPE,
138 TABLE_SIMPLIFIED_TUNING_PIDS_MODE,
139 #ifdef USE_OSD
140 TABLE_CMS_BACKGROUND,
141 #endif
142 #ifdef USE_RX_EXPRESSLRS
143 TABLE_FREQ_DOMAIN,
144 #endif
145 #ifdef USE_ADVANCED_TPA
146 TABLE_TPA_CURVE_TYPE,
147 #endif
148 #ifdef USE_WING
149 TABLE_TPA_SPEED_TYPE,
150 TABLE_YAW_TYPE,
151 #endif // USE_WING
152 LOOKUP_TABLE_COUNT
153 } lookupTableIndex_e;
155 typedef struct lookupTableEntry_s {
156 const char * const *values;
157 const uint8_t valueCount;
158 } lookupTableEntry_t;
160 #define VALUE_TYPE_OFFSET 0
161 #define VALUE_SECTION_OFFSET 3
162 #define VALUE_MODE_OFFSET 5
164 typedef enum {
165 // value type, bits 0-2
166 VAR_UINT8 = (0 << VALUE_TYPE_OFFSET),
167 VAR_INT8 = (1 << VALUE_TYPE_OFFSET),
168 VAR_UINT16 = (2 << VALUE_TYPE_OFFSET),
169 VAR_INT16 = (3 << VALUE_TYPE_OFFSET),
170 VAR_UINT32 = (4 << VALUE_TYPE_OFFSET),
171 VAR_INT32 = (5 << VALUE_TYPE_OFFSET),
173 // value section, bits 3-4
174 MASTER_VALUE = (0 << VALUE_SECTION_OFFSET),
175 PROFILE_VALUE = (1 << VALUE_SECTION_OFFSET),
176 PROFILE_RATE_VALUE = (2 << VALUE_SECTION_OFFSET),
177 HARDWARE_VALUE = (3 << VALUE_SECTION_OFFSET), // Part of the master section, but used for the hardware definition
179 // value mode, bits 5-7
180 MODE_DIRECT = (0 << VALUE_MODE_OFFSET),
181 MODE_LOOKUP = (1 << VALUE_MODE_OFFSET),
182 MODE_ARRAY = (2 << VALUE_MODE_OFFSET),
183 MODE_BITSET = (3 << VALUE_MODE_OFFSET),
184 MODE_STRING = (4 << VALUE_MODE_OFFSET),
185 } cliValueFlag_e;
187 #define VALUE_TYPE_MASK (0x07)
188 #define VALUE_SECTION_MASK (0x18)
189 #define VALUE_MODE_MASK (0xE0)
191 typedef struct cliMinMaxConfig_s {
192 const int16_t min;
193 const int16_t max;
194 } cliMinMaxConfig_t;
196 typedef struct cliMinMaxUnsignedConfig_s {
197 const uint16_t min;
198 const uint16_t max;
199 } cliMinMaxUnsignedConfig_t;
201 typedef struct cliLookupTableConfig_s {
202 const lookupTableIndex_e tableIndex;
203 } cliLookupTableConfig_t;
205 typedef struct cliArrayLengthConfig_s {
206 const uint8_t length;
207 } cliArrayLengthConfig_t;
209 typedef struct cliStringLengthConfig_s {
210 const uint8_t minlength;
211 const uint8_t maxlength;
212 const uint8_t flags;
213 } cliStringLengthConfig_t;
215 #define STRING_FLAGS_NONE (0)
216 #define STRING_FLAGS_WRITEONCE (1 << 0)
218 typedef union {
219 cliLookupTableConfig_t lookup; // used for MODE_LOOKUP excl. VAR_UINT32
220 cliMinMaxConfig_t minmax; // used for MODE_DIRECT with signed parameters
221 cliMinMaxUnsignedConfig_t minmaxUnsigned; // used for MODE_DIRECT with unsigned parameters
222 cliArrayLengthConfig_t array; // used for MODE_ARRAY
223 cliStringLengthConfig_t string; // used for MODE_STRING
224 uint8_t bitpos; // used for MODE_BITSET
225 uint32_t u32Max; // used for MODE_DIRECT with VAR_UINT32
226 int32_t d32Max; // used for MODE_DIRECT with VAR_INT32
227 } cliValueConfig_t;
229 #ifdef __APPLE__
230 #define PTR_PACKING
231 #else
232 #define PTR_PACKING __attribute__((packed))
233 #endif
235 typedef struct clivalue_s {
236 const char *name;
237 const uint8_t type; // see cliValueFlag_e
238 const cliValueConfig_t config;
240 pgn_t pgn;
241 uint16_t offset;
242 } PTR_PACKING clivalue_t;
244 extern const lookupTableEntry_t lookupTables[];
245 extern const uint16_t valueTableEntryCount;
247 extern const clivalue_t valueTable[];
248 //extern const uint8_t lookupTablesEntryCount;
250 extern const char * const lookupTableGyroHardware[];
252 extern const char * const lookupTableAccHardware[];
253 //extern const uint8_t lookupTableAccHardwareEntryCount;
255 extern const char * const lookupTableBaroHardware[];
256 //extern const uint8_t lookupTableBaroHardwareEntryCount;
258 extern const char * const lookupTableMagHardware[];
259 //extern const uint8_t lookupTableMagHardwareEntryCount;
261 extern const char * const lookupTableRangefinderHardware[];
263 extern const char * const lookupTableLedstripColors[];
265 extern const char * const lookupTableRescueAltitudeMode[];
267 extern const char * const lookupTableItermRelax[];
269 extern const char * const lookupTableItermRelaxType[];
271 extern const char * const lookupTableOsdDisplayPortDevice[];
273 extern const char * const lookupTableFeedforwardAveraging[];
275 extern const char * const lookupTableOffOn[];
277 extern const char * const lookupTableSimplifiedTuningPidsMode[];
279 extern const char * const lookupTableMixerType[];
281 extern const char * const lookupTableCMSMenuBackgroundType[];
283 extern const char * const lookupTableThrottleLimitType[];