Bsongis/x7d companion support (#4028)
[opentx.git] / companion / src / firmwares / opentx / opentxinterface.h
blobe4ed72b42445f3872459ff2178e0dd89c80f9752
1 /*
2 * Author - Bertrand Songis <bsongis@gmail.com>
4 * Based on th9x -> http://code.google.com/p/th9x/
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #ifndef opentx_interface_h
18 #define opentx_interface_h
20 #include "eeprominterface.h"
22 class RleFile;
24 class OpenTxEepromInterface : public EEPROMInterface
26 public:
28 OpenTxEepromInterface(BoardEnum board);
30 virtual ~OpenTxEepromInterface();
32 virtual const int getEEpromSize();
34 virtual const int getMaxModels();
36 virtual unsigned long load(RadioData &, const uint8_t *eeprom, int size);
38 virtual unsigned long loadBackup(RadioData &, uint8_t *eeprom, int esize, int index);
40 virtual unsigned long loadxml(RadioData &radioData, QDomDocument &doc);
42 virtual int save(uint8_t *eeprom, RadioData &radioData, uint32_t variant=0, uint8_t version=0);
44 virtual int getSize(const ModelData &);
46 virtual int getSize(const GeneralSettings &);
48 protected:
50 const char * getName();
52 EepromLoadErrors checkVersion(unsigned int version);
54 bool checkVariant(unsigned int version, unsigned int variant);
56 template <class T>
57 bool loadModel(ModelData &model, uint8_t *data, int index, unsigned int stickMode=0);
59 template <class T>
60 bool loadModelVariant(unsigned int index, ModelData &model, uint8_t *data, unsigned int version, unsigned int variant);
62 bool loadModel(uint8_t version, ModelData &model, uint8_t *data, int index, unsigned int variant, unsigned int stickMode=0);
64 template <class T>
65 bool saveModel(unsigned int index, ModelData &model, unsigned int version, unsigned int variant);
67 template <class T>
68 bool loadGeneral(GeneralSettings &settings, unsigned int version);
70 template <class T>
71 bool saveGeneral(GeneralSettings &settings, BoardEnum board, uint32_t version, uint32_t variant);
73 RleFile *efile;
77 class OpenTxFirmware: public Firmware {
78 public:
79 OpenTxFirmware(const QString & id, OpenTxFirmware * parent):
80 Firmware(parent, id, parent->getName(), parent->getBoard(), parent->eepromInterface)
84 OpenTxFirmware(const QString & id, const QString & name, const BoardEnum board):
85 Firmware(id, name, board, new OpenTxEepromInterface(board))
87 addLanguage("en");
88 addLanguage("cz");
89 addLanguage("de");
90 addLanguage("es");
91 addLanguage("fr");
92 addLanguage("it");
93 addLanguage("nl");
94 addLanguage("pl");
95 addLanguage("pt");
96 addLanguage("se");
98 addTTSLanguage("en");
99 addTTSLanguage("cz");
100 addTTSLanguage("de");
101 addTTSLanguage("es");
102 addTTSLanguage("fr");
103 addTTSLanguage("hu");
104 addTTSLanguage("it");
105 addTTSLanguage("nl");
106 addTTSLanguage("pl");
107 addTTSLanguage("pt");
108 addTTSLanguage("se");
109 addTTSLanguage("sk");
112 virtual Firmware * getFirmwareVariant(const QString & id);
114 virtual QString getStampUrl();
116 virtual QString getReleaseNotesUrl();
118 virtual QString getFirmwareUrl();
120 virtual int getCapability(Capability);
122 virtual Switch getSwitch(unsigned int index);
124 virtual QTime getMaxTimerStart();
126 virtual bool isTelemetrySourceAvailable(int source);
128 virtual int isAvailable(PulsesProtocol proto, int port=0);
130 protected:
132 QString getFirmwareBaseUrl();
136 void registerOpenTxFirmwares();
137 void unregisterOpenTxFirmwares();
139 #endif