-
-
Notifications
You must be signed in to change notification settings - Fork 551
Expand file tree
/
Copy pathgeneralsettings.h
More file actions
516 lines (453 loc) · 14.3 KB
/
Copy pathgeneralsettings.h
File metadata and controls
516 lines (453 loc) · 14.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#pragma once
#include "boards.h"
#include "constants.h"
#include "customfunctiondata.h"
#include "rawsource.h"
#include "datahelpers.h"
#include "customisation_data.h"
#include <QtCore>
class Firmware;
class ModelData;
class GeneralSettings;
class RadioDataConversionState;
class AbstractStaticItemModel;
// identiying names of static abstract item models
constexpr char AIM_GS_ANTENNAMODE[] {"gs.antennamode"};
constexpr char AIM_GS_BLUETOOTHMODE[] {"gs.bluetoothmode"};
constexpr char AIM_GS_SERIALMODE[] {"gs.serialmode"};
constexpr char AIM_GS_INTMODULEBAUDRATE[] {"gs.intmodulebaudrate"};
constexpr char AIM_GS_STICKDEADZONE[] {"gs.stickdeadzone"};
constexpr char AIM_GS_UARTSAMPLEMODE[] {"gs.uartsamplemode"};
constexpr char AIM_GS_HATSMODE[] {"gs.hatsmode"};
constexpr char AIM_GS_STICKMODE[] {"gs.stickmode"};
constexpr char AIM_GS_TEMPLATESETUP[] {"gs.templatesetup"};
constexpr char AIM_GS_BACKLIGHTMODE[] {"gs.backlightmode"};
constexpr char AIM_GS_QUICKMENU[] {"gs.quickmenu"};
constexpr char AIM_TRAINERMIX_MODE[] {"trainermix.mode"};
constexpr char AIM_TRAINERMIX_SRC[] {"trainermix.src"};
constexpr int MAX_KEYSHORTCUTS {6};
constexpr int MAX_QMFAVOURITES {12};
static const QStringList moduleBaudratesList({"115K", "400K", "921K", "1.87M",
"3.75M", "5.25M"});
enum UartModes {
UART_MODE_NONE,
UART_MODE_TELEMETRY_MIRROR,
UART_MODE_TELEMETRY,
UART_MODE_SBUS_TRAINER,
UART_MODE_DEBUG
};
class RGBLedColor {
public:
RGBLedColor() { clear(); }
int r;
int g;
int b;
void clear() { memset(reinterpret_cast<void *>(this), 0, sizeof(RGBLedColor)); }
void setColor(int red, int green, int blue) { r = red; g = green; b = blue; }
QColor getQColor() { return QColor(r, g, b); }
};
class TrainerMix {
Q_DECLARE_TR_FUNCTIONS(TrainerMix)
public:
enum TrainerMixModes {
TRN_MIX_MODE_OFF,
TRN_MIX_MODE_ADD,
TRN_MIX_MODE_SUBST,
TRN_MIX_MODE_COUNT
};
TrainerMix() { clear(); }
unsigned int src; // 0-7 = ch1-8
RawSwitch swtch;
int weight;
unsigned int mode; // off, add-mode, subst-mode
void clear() { memset(reinterpret_cast<void *>(this), 0, sizeof(TrainerMix)); }
QString modeToString() const;
QString srcToString() const;
static FieldRange getWeightRange();
static QString modeToString(int value);
static QString srcToString(int value);
static AbstractStaticItemModel * modeItemModel();
static AbstractStaticItemModel * srcItemModel();
};
class TrainerData {
public:
TrainerData() { clear(); }
int calib[4];
TrainerMix mix[4];
void clear() { memset(reinterpret_cast<void *>(this), 0, sizeof(TrainerData)); }
};
constexpr int CURR_MODEL_FILENAME_LEN {16};
constexpr int OWNER_NAME_LEN {10};
constexpr int BLUETOOTH_NAME_LEN {10};
constexpr int TTS_LANGUAGE_LEN {2};
constexpr int HARDWARE_NAME_LEN {3};
constexpr int REGISTRATION_ID_LEN {8};
constexpr int SELECTED_THEME_NAME_LEN {26};
constexpr int SWITCH_INPUTINDEX_NONE {-1};
class GeneralSettings {
Q_DECLARE_TR_FUNCTIONS(GeneralSettings)
public:
enum BeeperMode {
BEEPER_QUIET = -2,
BEEPER_ALARMS_ONLY = -1,
BEEPER_NOKEYS = 0,
BEEPER_ALL = 1
};
enum BluetoothMode {
BLUETOOTH_MODE_OFF,
BLUETOOTH_MODE_ENABLED,
BLUETOOTH_MODE_TELEMETRY = BLUETOOTH_MODE_ENABLED,
BLUETOOTH_MODE_TRAINER,
BLUETOOTH_MODE_COUNT
};
enum AntennaMode {
ANTENNA_MODE_INTERNAL = -2,
ANTENNA_MODE_FIRST = ANTENNA_MODE_INTERNAL,
ANTENNA_MODE_ASK,
ANTENNA_MODE_PER_MODEL,
ANTENNA_MODE_EXTERNAL,
ANTENNA_MODE_INTERNAL_EXTERNAL = ANTENNA_MODE_EXTERNAL,
ANTENNA_MODE_LAST = ANTENNA_MODE_INTERNAL_EXTERNAL
};
enum AuxSerialMode {
AUX_SERIAL_OFF,
AUX_SERIAL_TELE_MIRROR,
AUX_SERIAL_TELE_IN,
AUX_SERIAL_SBUS_TRAINER,
AUX_SERIAL_LUA,
AUX_SERIAL_CLI,
AUX_SERIAL_GPS,
AUX_SERIAL_DEBUG,
AUX_SERIAL_SPACEMOUSE,
AUX_SERIAL_EXT_MODULE,
AUX_SERIAL_COUNT
};
enum AuxSerialModeContext
{
AUX1Context = 0x01,
AUX2Context = 0x02,
VCPContext = 0x04,
AllAuxSerialModeContexts = AUX1Context | AUX2Context | VCPContext,
};
enum TelemetryBaudrate {
};
enum SerialPort {
SP_AUX1,
SP_AUX2,
SP_VCP,
SP_COUNT,
};
enum UartSampleMode {
UART_SAMPLE_MODE_NORMAL,
UART_SAMPLE_MODE_ONEBIT,
UART_SAMPLE_MODE_COUNT
};
enum HatsMode {
HATSMODE_TRIMS_ONLY,
HATSMODE_KEYS_ONLY,
HATSMODE_SWITCHABLE,
HATSMODE_GLOBAL,
HATSMODE_COUNT
};
enum PPMUnit {
PPM_PERCENT_PREC0,
PPM_PERCENT_PREC1,
PPM_US
};
enum StickMode {
STICK_MODE_1,
STICK_MODE_2,
STICK_MODE_3,
STICK_MODE_4,
STICK_MODE_COUNT,
};
enum RadioTypeContext {
RadioTypeContextAir = 1 << 1,
RadioTypeContextSurface = 1 << 2,
};
enum BacklightMode {
BACKLIGHT_MODE_OFF,
BACKLIGHT_MODE_KEYS,
BACKLIGHT_MODE_CTRL,
BACKLIGHT_MODE_KEYSCTRL,
BACKLIGHT_MODE_ON,
BACKLIGHT_MODE_COUNT,
};
// Match equivalent enum in radio/src/gui/colorlcd/setup_menus/quick_menu.h
enum QMPage {
QM_NONE = 0,
QM_OPEN_QUICK_MENU,
QM_MANAGE_MODELS,
// Model menu
QM_MODEL_SETUP,
QM_MODEL_FLIGHTMODES,
QM_MODEL_INPUTS,
QM_MODEL_MIXES,
QM_MODEL_OUTPUTS,
QM_MODEL_CURVES,
QM_MODEL_GVARS,
QM_MODEL_LS,
QM_MODEL_SF,
QM_MODEL_SCRIPTS,
QM_MODEL_TELEMETRY,
QM_MODEL_NOTES,
// Radio menu
QM_RADIO_SETUP,
QM_RADIO_GF,
QM_RADIO_TRAINER,
QM_RADIO_HARDWARE,
QM_RADIO_VERSION,
// UI menu
QM_UI_THEMES,
QM_UI_SETUP,
QM_UI_SCREEN1,
QM_UI_SCREEN2,
QM_UI_SCREEN3,
QM_UI_SCREEN4,
QM_UI_SCREEN5,
QM_UI_SCREEN6,
QM_UI_SCREEN7,
QM_UI_SCREEN8,
QM_UI_SCREEN9,
QM_UI_SCREEN10,
QM_UI_ADD_PG,
// Tools menu
QM_TOOLS_APPS,
QM_TOOLS_STORAGE,
QM_TOOLS_RESET,
QM_TOOLS_CHAN_MON,
QM_TOOLS_LS_MON,
QM_TOOLS_STATS,
QM_TOOLS_DEBUG,
// Lua stand alone script
QM_APP,
QM_COUNT,
};
GeneralSettings() { clear(); }
void clear();
void init();
void convert(RadioDataConversionState & cstate);
void setDefaultControlTypes(Board::Type board);
int getDefaultStick(unsigned int channel) const;
RawSource getDefaultSource(unsigned int channel) const;
int getDefaultChannel(unsigned int stick) const;
bool fix6POSCalibration();
void setDefaultFavorites();
void setDefaultKeyShortcuts();
bool manuallyEdited;
char semver[8 + 1];
unsigned int version;
unsigned int variant;
unsigned int currModelIndex;
char currModelFilename[CURR_MODEL_FILENAME_LEN + 1];
unsigned int contrast;
unsigned int vBatWarn;
int txVoltageCalibration;
int vBatMin;
int vBatMax;
int backlightMode;
unsigned int internalModule; // Introducted in EdgeTX 2.6 yaml only
TrainerData trainer;
unsigned int view; // main screen view // TODO enum
bool disableThrottleWarning;
bool fai;
bool disableMemoryWarning;
BeeperMode beeperMode;
bool disableAlarmWarning;
bool disableRssiPoweroffAlarm;
bool disableTrainerPoweroffAlarm;
unsigned int usbMode;
unsigned int hatsMode;
unsigned int stickDeadZone;
unsigned int jackMode;
bool sportPower;
BeeperMode hapticMode;
unsigned int stickMode; // TODO enum
int timezone;
int timezoneMinutes;
bool adjustRTC;
unsigned int inactivityTimer;
unsigned int internalModuleBaudrate;
bool minuteBeep;
bool preBeep;
bool alarmsFlash;
int splashMode;
bool dontPlayHello;
unsigned int backlightDelay;
unsigned int templateSetup; //RETA order according to chout_ar array
int PPM_Multiplier;
int hapticLength;
unsigned int reNavigation;
unsigned int speakerPitch;
int hapticStrength;
char ownerName[OWNER_NAME_LEN + 1];
int beeperLength;
unsigned int gpsFormat;
int speakerVolume;
unsigned int backlightBright;
unsigned int backlightOffBright;
int switchesDelay;
unsigned int mAhWarn;
unsigned int mAhUsed;
unsigned int globalTimer;
char bluetoothName[BLUETOOTH_NAME_LEN + 1];
unsigned int bluetoothBaudrate;
unsigned int bluetoothMode;
unsigned int sticksGain;
unsigned int rotarySteps;
unsigned int countryCode;
bool noJitterFilter;
bool rtcCheckDisable;
bool muteIfNoSound;
bool keysBacklight;
unsigned int rotEncMode;
unsigned int imperial;
unsigned int ppmunit;
char ttsLanguage[TTS_LANGUAGE_LEN + 1];
char uiLanguage[TTS_LANGUAGE_LEN + 1];
int beepVolume;
int wavVolume;
int varioVolume;
int varioPitch;
int varioRange;
int varioRepeat;
int backgroundVolume;
unsigned int mavbaud;
unsigned int serialPort[SP_COUNT];
bool serialPower[SP_COUNT];
int antennaMode;
unsigned int backlightColor;
bool modelQuickSelect;
CustomFunctionData customFn[CPN_MAX_SPECIAL_FUNCTIONS];
char registrationId[REGISTRATION_ID_LEN + 1];
int imuMax;
int imuOffset;
int uartSampleMode;
int pwrOnSpeed;
int pwrOffSpeed;
bool disablePwrOnOffHaptic;
char selectedTheme[SELECTED_THEME_NAME_LEN + 1];
RawSource backlightSrc;
RawSource volumeSrc;
// Radio level tabs control (global settings)
bool radioThemesDisabled;
bool radioGFDisabled;
bool radioTrainerDisabled;
// Model level tabs control (global setting)
bool modelHeliDisabled;
bool modelFMDisabled;
bool modelCurvesDisabled;
bool modelGVDisabled;
bool modelLSDisabled;
bool modelSFDisabled;
bool modelCustomScriptsDisabled;
bool modelTelemetryDisabled;
unsigned int pwrOffIfInactive;
int modelSelectLayout;
int labelSingleSelect;
int labelMultiMode;
int favMultiMode;
bool invertLCD;
// default values are retrieved from the radio json file
struct InputCalib {
int mid;
int spanNeg;
int spanPos;
};
struct InputConfig {
Board::AnalogInputType type;
char name[HARDWARE_NAME_LEN + 1];
Board::FlexType flexType;
bool inverted;
InputCalib calib;
};
InputConfig inputConfig[CPN_MAX_INPUTS];
struct SwitchConfig {
char name[HARDWARE_NAME_LEN + 1];
Board::SwitchType type;
bool inverted;
int inputIdx; // used if switch tag = FLn, value -1 = none selected
// CFS settings
unsigned int start;
unsigned int onColorLuaOverride;
unsigned int offColorLuaOverride;
RGBLedColor onColor;
RGBLedColor offColor;
SwitchConfig();
};
SwitchConfig switchConfig[CPN_MAX_SWITCHES];
unsigned int keyShortcuts[MAX_KEYSHORTCUTS];
char* keyShortcutTools[MAX_KEYSHORTCUTS];
unsigned int qmFavorites[MAX_QMFAVOURITES];
char* qmFavoritesTools[MAX_QMFAVOURITES];
bool oneLogPerDay;
bool keyLockEnabled;
void switchConfigClear();
bool switchPositionAllowed(int index) const;
bool switchSourceAllowed(int index) const;
bool isInputAvailable(int index) const;
bool isInputMultiPosPot(int index) const;
bool isInputPot(int index) const;
bool isInputSlider(int index) const;
bool isInputStick(int index) const;
bool isInputFlexSwitchAvailable(int index) const;
bool isSwitchAvailable(int index) const;
bool isSwitchFlex(int index) const;
bool isSwitchFunc(int index) const;
bool unassignedInputFlexSwitches() const;
static bool isBacklightModeAvailable(int index);
static bool isQuickMenuAvailable(int value, bool keys);
QString antennaModeToString() const;
QString bluetoothModeToString() const;
QString serialPortModeToString(int port_nr) const;
QString internalModuleBaudrateToString() const;
QString uartSampleModeToString() const;
QString hatsModeToString() const;
QString stickModeToString() const;
QString templateSetupToString() const;
QString backlightModeToString() const;
static QString antennaModeToString(int value);
static QString bluetoothModeToString(int value);
static QString serialModeToString(int value);
static QString moduleBaudrateToString(int value);
static FieldRange getPPM_MultiplierRange();
static FieldRange getTxCurrentCalibration();
static QString uartSampleModeToString(int value);
static QString hatsModeToString(int value);
static QString stickModeToString(int value);
static QString templateSetupToString(int value, bool isBoardAir);
static QString backlightModeToString(int value);
static QString quickMenuToString(int value, bool keys);
static AbstractStaticItemModel * antennaModeItemModel(bool model_setup = false);
static AbstractStaticItemModel * bluetoothModeItemModel();
static AbstractStaticItemModel * serialModeItemModel();
static AbstractStaticItemModel * internalModuleBaudrateItemModel();
static AbstractStaticItemModel * stickDeadZoneItemModel();
static AbstractStaticItemModel * uartSampleModeItemModel();
static AbstractStaticItemModel * hatsModeItemModel(bool radio_setup = true);
static AbstractStaticItemModel * stickModeItemModel();
static AbstractStaticItemModel * templateSetupItemModel();
static AbstractStaticItemModel * backlightModeItemModel();
static AbstractStaticItemModel * quickMenuItemModel(bool keys);
void validateFlexSwitches();
};