5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 // All temporary and permanent global variables are defined here to make
22 // initialization and storage safe and visible.
23 // Do not access variables in QSettings directly, it is not type safe!
29 #include <QStringList>
33 #define COMPANY "OpenTX"
34 #define PRODUCT "Companion 2.2"
36 #define MAX_PROFILES 15
37 #define MAX_JOYSTICKS 8
42 void clear (const QString tag1
="", const QString tag2
="", const QString tag3
="");
43 void store(const QByteArray newArray
, QByteArray
&array
, const QString tag
, const QString group1
="", const QString group2
="" );
44 void store(const QStringList newSList
, QStringList
&stringList
, const QString tag
, const QString group1
="", const QString group2
="" );
45 void store(const QString newString
, QString
&string
, const QString tag
, const QString group1
="", const QString group2
="" );
46 void store(const bool newTruth
, bool &truth
, const QString tag
, const QString group1
="", const QString group2
="" );
47 void store(const int newNumber
, int &number
, const QString tag
, const QString group1
="", const QString group2
="" );
49 // Retrieval functions
50 void retrieve( QByteArray
&array
, const QString tag
, const QString def
, const QString group1
="", const QString group2
="" );
51 void retrieve( QStringList
&stringList
, const QString tag
, const QString def
, const QString group1
="", const QString group2
="" );
52 void retrieve( QString
&string
, const QString tag
, const QString def
, const QString group1
="", const QString group2
="" );
53 void retrieve( bool &truth
, const QString tag
, const bool def
, const QString group1
="", const QString group2
="" );
54 void retrieve( int &number
, const QString tag
, const int def
, const QString group1
="", const QString group2
="" );
56 // Retrieve and Store functions
57 void getset( QByteArray
&array
, const QString tag
, const QString def
, const QString group1
="", const QString group2
="" );
58 void getset( QStringList
&stringList
, const QString tag
, const QString def
, const QString group1
="", const QString group2
="" );
59 void getset( QString
&string
, const QString tag
, const QString def
, const QString group1
="", const QString group2
="" );
60 void getset( bool &truth
, const QString tag
, const bool def
, const QString group1
="", const QString group2
="" );
61 void getset( int &number
, const QString tag
, const int def
, const QString group1
="", const QString group2
="" );
64 class FwRevision
: protected CompStoreObj
67 int get( const QString
);
68 void set( const QString
, const int );
69 void remove( const QString
);
72 class JStickData
: protected CompStoreObj
84 // All the get definitions
91 // All the set definitions
92 void stick_axe(const int);
93 void stick_min(const int);
94 void stick_med(const int);
95 void stick_max(const int);
96 void stick_inv(const int);
101 void init(int index
);
105 class Profile
: protected CompStoreObj
108 // Class Internal Variable
111 // Application Variables
125 // Simulator variables
126 QByteArray _simuWinGeo
;
128 // Firmware Variables
130 QString _countryCode
;
134 QString _stickPotCalib
;
136 QString _trainerCalib
;
137 QString _controlTypes
;
138 QString _controlNames
;
139 int _txCurrentCalibration
;
142 int _txVoltageCalibration
;
148 // All the get definitions
149 QString
fwName() const;
150 QString
fwType() const;
151 QString
name() const;
152 QString
sdPath() const;
153 int volumeGain() const;
154 QString
pBackupDir() const;
155 QString
splashFile() const;
156 bool burnFirmware() const;
157 bool renameFwFiles() const;
158 bool penableBackup() const;
159 int channelOrder() const;
160 int defaultMode() const;
162 QByteArray
simuWinGeo() const;
164 QString
beeper() const;
165 QString
countryCode() const;
166 QString
display() const;
167 QString
haptic() const;
168 QString
speaker() const;
169 QString
stickPotCalib() const;
170 QString
timeStamp() const;
171 QString
trainerCalib() const;
172 QString
controlTypes() const;
173 QString
controlNames() const;
174 int txCurrentCalibration() const;
175 int gsStickMode() const;
176 int ppmMultiplier() const;
177 int txVoltageCalibration() const;
178 int vBatWarn() const;
182 // All the set definitions
183 void name (const QString
);
184 void fwName (const QString
);
185 void fwType (const QString
);
186 void volumeGain (const int);
187 void sdPath (const QString
);
188 void pBackupDir (const QString
);
189 void splashFile (const QString
);
190 void burnFirmware (const bool);
191 void renameFwFiles (const bool);
192 void penableBackup (const bool);
193 void channelOrder (const int);
194 void defaultMode (const int);
196 void simuWinGeo (const QByteArray
);
198 void beeper (const QString
);
199 void countryCode (const QString
);
200 void display (const QString
);
201 void haptic (const QString
);
202 void speaker (const QString
);
203 void stickPotCalib (const QString
);
204 void timeStamp (const QString
);
205 void trainerCalib (const QString
);
206 void controlTypes (const QString
);
207 void controlNames (const QString
);
208 void txCurrentCalibration (const int);
209 void gsStickMode (const int);
210 void ppmMultiplier (const int);
211 void txVoltageCalibration (const int);
212 void vBatWarn (const int);
213 void vBatMin (const int);
214 void vBatMax (const int);
217 Profile
& operator=(const Profile
&);
220 void init(int newIndex
);
221 void initFwVariables();
225 #define BOOL_PROPERTY(name, dflt) \
227 inline bool name() { return _ ## name; } \
228 void name(const bool val) { store(val, _ ## name, # name); } \
232 class AppData
: protected CompStoreObj
234 BOOL_PROPERTY(enableBackup
, false)
235 BOOL_PROPERTY(outputDisplayDetails
, false)
236 BOOL_PROPERTY(backupOnFlash
, true)
237 BOOL_PROPERTY(checkHardwareCompatibility
, true)
238 BOOL_PROPERTY(useCompanionNightlyBuilds
, false)
239 BOOL_PROPERTY(useFirmwareNightlyBuilds
, false)
241 // All the global variables
243 Profile profile
[MAX_PROFILES
];
244 JStickData joystick
[MAX_JOYSTICKS
];
248 QStringList _recentFiles
;
249 QByteArray _mainWinGeo
;
250 QByteArray _mainWinState
;
251 QByteArray _modelEditGeo
;
254 QString _avrArguments
;
256 QString _avrdudeLocation
;
257 QString _dfuArguments
;
258 QString _dfuLocation
;
262 QString _sambaLocation
;
264 QString _lastSimulator
;
265 QString _simuLastEepe
;
274 QString _snapshotDir
;
299 // All the get definitions
300 QStringList
recentFiles();
301 QByteArray
mainWinGeo();
302 QByteArray
mainWinState();
303 QByteArray
modelEditGeo();
306 QString
avrArguments();
308 QString
avrdudeLocation();
309 QString
dfuArguments();
310 QString
dfuLocation();
314 QString
programmer();
315 QString
sambaLocation();
317 QString
lastSimulator();
318 QString
simuLastEepe();
327 QString
snapshotDir();
328 QString
updatesDir();
342 int generalEditTab();
349 int simuLastProfId();
351 // All the set definitions
352 void recentFiles (const QStringList x
);
353 void mainWinGeo (const QByteArray
);
354 void mainWinState (const QByteArray
);
355 void modelEditGeo (const QByteArray
);
357 void armMcu (const QString
);
358 void avrArguments (const QString
);
359 void avrPort (const QString
);
360 void avrdudeLocation (const QString
);
361 void dfuArguments (const QString
);
362 void dfuLocation (const QString
);
363 void lastFw (const QString
);
364 void locale (const QString
);
365 void mcu (const QString
);
366 void programmer (const QString
);
367 void sambaLocation (const QString
);
368 void sambaPort (const QString
);
369 void lastSimulator (const QString
);
370 void simuLastEepe (const QString
);
372 void backupDir (const QString
);
373 void gePath (const QString
);
374 void eepromDir (const QString
);
375 void flashDir (const QString
);
376 void imagesDir (const QString
);
377 void logDir (const QString
);
378 void libDir (const QString
);
379 void snapshotDir (const QString
);
380 void updatesDir (const QString
);
382 void maximized (const bool);
383 void jsSupport (const bool);
384 void showSplash (const bool);
385 void snapToClpbrd (const bool);
386 void autoCheckApp (const bool);
387 void autoCheckFw (const bool);
388 void simuSW (const bool);
389 void useWizard (const bool);
391 void backLight (const int);
392 void embedSplashes (const int);
393 void fwServerFails (const int);
394 void generalEditTab (const int);
395 void iconSize (const int);
396 void historySize (const int);
397 void jsCtrl (const int);
398 void modelEditTab (const int);
400 void theme (const int);
401 void warningId (const int);
402 void simuLastProfId (const int);
408 QMap
<int, QString
> getActiveProfiles();
413 #endif // _APPDATA_H_