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 #ifndef _OPENTXINTERFACE_H_
22 #define _OPENTXINTERFACE_H_
24 #include "eeprominterface.h"
31 class OpenTxEepromInterface
: public EEPROMInterface
33 Q_DECLARE_TR_FUNCTIONS(OpenTxEepromInterface
)
37 OpenTxEepromInterface(OpenTxFirmware
* firmware
);
39 virtual ~OpenTxEepromInterface();
41 virtual unsigned long load(RadioData
&, const uint8_t * eeprom
, int size
);
43 bool loadModelFromBackup(ModelData
& model
, const uint8_t * data
, unsigned int size
, uint8_t version
, uint32_t variant
);
45 virtual unsigned long loadBackup(RadioData
&, const uint8_t * eeprom
, int esize
, int index
);
47 virtual int save(uint8_t * eeprom
, const RadioData
& radioData
, uint8_t version
=0, uint32_t variant
=0);
49 virtual int getSize(const ModelData
&);
51 virtual int getSize(const GeneralSettings
&);
55 const char * getName();
57 EepromLoadErrors
checkVersion(unsigned int version
);
59 bool checkVariant(unsigned int version
, unsigned int variant
);
61 template <class T
, class M
>
62 bool loadFromByteArray(T
& dest
, const QByteArray
& data
, uint8_t version
, uint32_t variant
=0);
65 template <class T
, class M
>
66 bool loadFromByteArray(T
& dest
, const QByteArray
& data
);
68 template <class T
, class M
>
69 bool saveToByteArray(const T
& src
, QByteArray
& data
, uint8_t version
=0);
71 bool loadRadioSettingsFromRLE(GeneralSettings
& settings
, RleFile
* rleFile
, uint8_t version
);
73 bool loadModelFromRLE(ModelData
& model
, RleFile
* rleFile
, unsigned int index
, uint8_t version
, uint32_t variant
);
75 void showErrors(const QString
& title
, const QStringList
& errors
);
77 uint8_t getLastDataVersion(Board::Type board
);
81 OpenTxFirmware
* firmware
;
85 class OpenTxFirmware
: public Firmware
87 Q_DECLARE_TR_FUNCTIONS(OpenTxFirmware
)
90 OpenTxFirmware(const QString
& id
, OpenTxFirmware
* parent
):
91 Firmware(parent
, id
, parent
->getName(), parent
->getBoard())
93 setEEpromInterface(parent
->getEEpromInterface());
96 OpenTxFirmware(const QString
& id
, const QString
& name
, const Board::Type board
):
97 Firmware(id
, name
, board
)
110 addTTSLanguage("en");
111 addTTSLanguage("cz");
112 addTTSLanguage("de");
113 addTTSLanguage("es");
114 addTTSLanguage("fr");
115 addTTSLanguage("hu");
116 addTTSLanguage("it");
117 addTTSLanguage("nl");
118 addTTSLanguage("pl");
119 addTTSLanguage("pt");
120 addTTSLanguage("se");
121 addTTSLanguage("sk");
124 virtual Firmware
* getFirmwareVariant(const QString
& id
);
126 virtual QString
getStampUrl();
128 virtual QString
getReleaseNotesUrl();
130 virtual QString
getFirmwareUrl();
132 virtual int getCapability(Capability
);
134 virtual QString
getAnalogInputName(unsigned int index
);
136 virtual QTime
getMaxTimerStart();
138 virtual int isAvailable(PulsesProtocol proto
, int port
=0);
142 QString
getFirmwareBaseUrl();
146 void registerOpenTxFirmwares();
147 void unregisterOpenTxFirmwares();
149 extern QList
<OpenTxEepromInterface
*> opentxEEpromInterfaces
;
151 OpenTxEepromInterface
* loadModelFromByteArray(ModelData
& model
, const QByteArray
& data
);
152 OpenTxEepromInterface
* loadRadioSettingsFromByteArray(GeneralSettings
& settings
, const QByteArray
& data
);
154 bool writeModelToByteArray(const ModelData
& model
, QByteArray
& data
);
155 bool writeRadioSettingsToByteArray(const GeneralSettings
& settings
, QByteArray
& data
);
157 #endif // _OPENTXINTERFACE_H_