[companion] Adjust GVAR not possible in global functions (fix #5425)
[opentx.git] / companion / src / multiprotocols.h
blobea174cc286c1cb0d97aa1eafbef9de01c7c53d9a
1 /*
2 * Copyright (C) OpenTX
4 * Based on code named
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 OPENTX_MULTI_H
22 #define OPENTX_MULTI_H
24 #include <vector>
25 #include <QString>
26 #include <QVector>
27 #include <QStringList>
29 #define MM_RF_CUSTOM_SELECTED 0xff
31 class Multiprotocols
33 public:
35 struct radio_mm_definition {
36 int protocol;
37 unsigned int maxSubtype;
38 bool hasFailsafe;
39 QStringList protocols;
40 QString optionsstr;
43 struct MultiProtocolDefinition {
44 const int protocol;
45 const bool hasFailsafe;
46 const QStringList subTypeStrings;
47 const QString optionsstr;
49 unsigned int numSubytes() const
51 return (unsigned int) subTypeStrings.length();
54 int getOptionMin() const;
56 int getOptionMax() const;
58 MultiProtocolDefinition(const radio_mm_definition &rd) :
59 protocol(rd.protocol),
60 hasFailsafe(rd.hasFailsafe),
61 subTypeStrings(rd.protocols),
62 optionsstr(rd.optionsstr)
64 Q_ASSERT(rd.maxSubtype + 1 == (unsigned int) rd.protocols.length());
68 Multiprotocols(std::initializer_list<radio_mm_definition> l)
70 for (radio_mm_definition rd: l)
71 protocols.push_back(MultiProtocolDefinition(rd));
74 const MultiProtocolDefinition &getProtocol(int protocol) const;
76 private:
78 std::vector<MultiProtocolDefinition> protocols;
82 extern const Multiprotocols multiProtocols;
84 #endif //OPENTX_MULTI_H