Merge pull request #11198 from SteveCEvans/sce_rc2
[betaflight.git] / src / main / cli / settings.h
blob3bf0e292a83dad6b085de2179bd2460d107a742f
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"
28 typedef enum {
29 TABLE_OFF_ON = 0,
30 TABLE_UNIT,
31 TABLE_ALIGNMENT,
32 #ifdef USE_GPS
33 TABLE_GPS_PROVIDER,
34 TABLE_GPS_SBAS_MODE,
35 TABLE_GPS_UBLOX_MODE,
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_SERIAL_RX
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_ANTI_GRAVITY_MODE,
70 TABLE_FAILSAFE,
71 TABLE_FAILSAFE_SWITCH_MODE,
72 TABLE_CRASH_RECOVERY,
73 #ifdef USE_CAMERA_CONTROL
74 TABLE_CAMERA_CONTROL_MODE,
75 #endif
76 TABLE_BUS_TYPE,
77 #ifdef USE_MAX7456
78 TABLE_MAX7456_CLOCK,
79 #endif
80 #ifdef USE_RX_FRSKY_SPI
81 TABLE_RX_FRSKY_SPI_A1_SOURCE,
82 #endif
83 #ifdef USE_RANGEFINDER
84 TABLE_RANGEFINDER_HARDWARE,
85 #endif
86 #ifdef USE_GYRO_OVERFLOW_CHECK
87 TABLE_GYRO_OVERFLOW_CHECK,
88 #endif
89 TABLE_RATES_TYPE,
90 #ifdef USE_OVERCLOCK
91 TABLE_OVERCLOCK,
92 #endif
93 #ifdef USE_LED_STRIP
94 TABLE_RGB_GRB,
95 #endif
96 #ifdef USE_MULTI_GYRO
97 TABLE_GYRO,
98 #endif
99 TABLE_THROTTLE_LIMIT_TYPE,
100 #if defined(USE_MAX7456) || defined(USE_FRSKYOSD)
101 TABLE_VIDEO_SYSTEM,
102 #endif
103 #if defined(USE_ITERM_RELAX)
104 TABLE_ITERM_RELAX,
105 TABLE_ITERM_RELAX_TYPE,
106 #endif
107 #ifdef USE_ACRO_TRAINER
108 TABLE_ACRO_TRAINER_DEBUG,
109 #endif // USE_ACRO_TRAINER
110 #ifdef USE_RC_SMOOTHING_FILTER
111 TABLE_RC_SMOOTHING_DEBUG,
112 #endif // USE_RC_SMOOTHING_FILTER
113 #ifdef USE_VTX_COMMON
114 TABLE_VTX_LOW_POWER_DISARM,
115 #endif
116 TABLE_GYRO_HARDWARE,
117 #ifdef USE_SDCARD
118 TABLE_SDCARD_MODE,
119 #endif
120 #ifdef USE_LAUNCH_CONTROL
121 TABLE_LAUNCH_CONTROL_MODE,
122 #endif
123 #ifdef USE_TPA_MODE
124 TABLE_TPA_MODE,
125 #endif
126 #ifdef USE_LED_STRIP
127 TABLE_LED_PROFILE,
128 TABLE_LEDSTRIP_COLOR,
129 #endif
130 TABLE_GYRO_FILTER_DEBUG,
131 TABLE_POSITION_ALT_SOURCE,
132 TABLE_OFF_ON_AUTO,
133 TABLE_FEEDFORWARD_AVERAGING,
134 TABLE_DSHOT_BITBANGED_TIMER,
135 TABLE_OSD_DISPLAYPORT_DEVICE,
136 #ifdef USE_OSD
137 TABLE_OSD_LOGO_ON_ARMING,
138 #endif
139 TABLE_MIXER_TYPE,
140 TABLE_SIMPLIFIED_TUNING_PIDS_MODE,
141 #ifdef USE_OSD
142 TABLE_CMS_BACKGROUND,
143 #endif
144 #ifdef USE_RX_EXPRESSLRS
145 TABLE_FREQ_DOMAIN,
146 TABLE_SWITCH_MODE,
147 #endif
148 LOOKUP_TABLE_COUNT
149 } lookupTableIndex_e;
151 typedef struct lookupTableEntry_s {
152 const char * const *values;
153 const uint8_t valueCount;
154 } lookupTableEntry_t;
157 #define VALUE_TYPE_OFFSET 0
158 #define VALUE_SECTION_OFFSET 3
159 #define VALUE_MODE_OFFSET 5
161 typedef enum {
162 // value type, bits 0-2
163 VAR_UINT8 = (0 << VALUE_TYPE_OFFSET),
164 VAR_INT8 = (1 << VALUE_TYPE_OFFSET),
165 VAR_UINT16 = (2 << VALUE_TYPE_OFFSET),
166 VAR_INT16 = (3 << VALUE_TYPE_OFFSET),
167 VAR_UINT32 = (4 << VALUE_TYPE_OFFSET),
169 // value section, bits 3-4
170 MASTER_VALUE = (0 << VALUE_SECTION_OFFSET),
171 PROFILE_VALUE = (1 << VALUE_SECTION_OFFSET),
172 PROFILE_RATE_VALUE = (2 << VALUE_SECTION_OFFSET),
173 HARDWARE_VALUE = (3 << VALUE_SECTION_OFFSET), // Part of the master section, but used for the hardware definition
175 // value mode, bits 5-7
176 MODE_DIRECT = (0 << VALUE_MODE_OFFSET),
177 MODE_LOOKUP = (1 << VALUE_MODE_OFFSET),
178 MODE_ARRAY = (2 << VALUE_MODE_OFFSET),
179 MODE_BITSET = (3 << VALUE_MODE_OFFSET),
180 MODE_STRING = (4 << VALUE_MODE_OFFSET),
181 } cliValueFlag_e;
184 #define VALUE_TYPE_MASK (0x07)
185 #define VALUE_SECTION_MASK (0x18)
186 #define VALUE_MODE_MASK (0xE0)
188 typedef struct cliMinMaxConfig_s {
189 const int16_t min;
190 const int16_t max;
191 } cliMinMaxConfig_t;
193 typedef struct cliMinMaxUnsignedConfig_s {
194 const uint16_t min;
195 const uint16_t max;
196 } cliMinMaxUnsignedConfig_t;
198 typedef struct cliLookupTableConfig_s {
199 const lookupTableIndex_e tableIndex;
200 } cliLookupTableConfig_t;
202 typedef struct cliArrayLengthConfig_s {
203 const uint8_t length;
204 } cliArrayLengthConfig_t;
206 typedef struct cliStringLengthConfig_s {
207 const uint8_t minlength;
208 const uint8_t maxlength;
209 const uint8_t flags;
210 } cliStringLengthConfig_t;
212 #define STRING_FLAGS_NONE (0)
213 #define STRING_FLAGS_WRITEONCE (1 << 0)
215 typedef union {
216 cliLookupTableConfig_t lookup; // used for MODE_LOOKUP excl. VAR_UINT32
217 cliMinMaxConfig_t minmax; // used for MODE_DIRECT with signed parameters
218 cliMinMaxUnsignedConfig_t minmaxUnsigned; // used for MODE_DIRECT with unsigned parameters
219 cliArrayLengthConfig_t array; // used for MODE_ARRAY
220 cliStringLengthConfig_t string; // used for MODE_STRING
221 uint8_t bitpos; // used for MODE_BITSET
222 uint32_t u32Max; // used for MODE_DIRECT with VAR_UINT32
223 } cliValueConfig_t;
225 typedef struct clivalue_s {
226 const char *name;
227 const uint8_t type; // see cliValueFlag_e
228 const cliValueConfig_t config;
230 pgn_t pgn;
231 uint16_t offset;
232 } __attribute__((packed)) clivalue_t;
235 extern const lookupTableEntry_t lookupTables[];
236 extern const uint16_t valueTableEntryCount;
238 extern const clivalue_t valueTable[];
239 //extern const uint8_t lookupTablesEntryCount;
241 extern const char * const lookupTableGyroHardware[];
243 extern const char * const lookupTableAccHardware[];
244 //extern const uint8_t lookupTableAccHardwareEntryCount;
246 extern const char * const lookupTableBaroHardware[];
247 //extern const uint8_t lookupTableBaroHardwareEntryCount;
249 extern const char * const lookupTableMagHardware[];
250 //extern const uint8_t lookupTableMagHardwareEntryCount;
252 extern const char * const lookupTableRangefinderHardware[];
254 extern const char * const lookupTableLedstripColors[];
256 extern const char * const lookupTableRescueAltitudeMode[];
258 extern const char * const lookupTableItermRelax[];
260 extern const char * const lookupTableItermRelaxType[];
262 extern const char * const lookupTableOsdDisplayPortDevice[];
264 extern const char * const lookupTableFeedforwardAveraging[];
266 extern const char * const lookupTableOffOn[];
268 extern const char * const lookupTableSimplifiedTuningPidsMode[];
270 extern const char * const lookupTableCMSMenuBackgroundType[];