Make TX volatge for simu more flexible (#7124)
[opentx.git] / companion / src / firmwares / boards.h
blobc3cd3ff59e5a5fc00dc5f129b0e50dfe72d65816
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 _BOARDS_H_
22 #define _BOARDS_H_
24 #include <QtCore>
25 #include <QObject>
26 #include <QString>
28 // TODO create a Board class with all these functions
30 namespace Board {
32 enum Type
34 BOARD_UNKNOWN = -1,
35 BOARD_9X_M64 = 0,
36 BOARD_9X_M128,
37 BOARD_MEGA2560,
38 BOARD_GRUVIN9X,
39 BOARD_SKY9X,
40 BOARD_9XRPRO,
41 BOARD_AR9X,
42 BOARD_TARANIS_X7,
43 BOARD_TARANIS_X9D,
44 BOARD_TARANIS_X9DP,
45 BOARD_TARANIS_X9DP_2019,
46 BOARD_TARANIS_X9E,
47 BOARD_HORUS_X12S,
48 BOARD_X10,
49 BOARD_X10_EXPRESS,
50 BOARD_TARANIS_XLITE,
51 BOARD_TARANIS_XLITES,
52 BOARD_TARANIS_X9LITE,
53 BOARD_TARANIS_X9LITES,
54 BOARD_JUMPER_T12,
55 BOARD_JUMPER_T16,
58 constexpr int BOARD_TYPE_MAX = BOARD_JUMPER_T16 ;
60 enum PotType
62 POT_NONE,
63 POT_WITH_DETENT,
64 POT_MULTIPOS_SWITCH,
65 POT_WITHOUT_DETENT
68 enum SliderType
70 SLIDER_NONE,
71 SLIDER_WITH_DETENT
74 enum SwitchType
76 SWITCH_NOT_AVAILABLE,
77 SWITCH_TOGGLE,
78 SWITCH_2POS,
79 SWITCH_3POS
82 enum StickAxes {
83 STICK_AXIS_LH = 0,
84 STICK_AXIS_LV,
85 STICK_AXIS_RV,
86 STICK_AXIS_RH,
87 STICK_AXIS_COUNT
90 enum TrimAxes {
91 TRIM_AXIS_LH = 0,
92 TRIM_AXIS_LV,
93 TRIM_AXIS_RV,
94 TRIM_AXIS_RH,
95 TRIM_AXIS_T5,
96 TRIM_AXIS_T6,
97 TRIM_AXIS_COUNT
100 enum TrimSwitches
102 TRIM_SW_LH_DEC,
103 TRIM_SW_LH_INC,
104 TRIM_SW_LV_DEC,
105 TRIM_SW_LV_INC,
106 TRIM_SW_RV_DEC,
107 TRIM_SW_RV_INC,
108 TRIM_SW_RH_DEC,
109 TRIM_SW_RH_INC,
110 TRIM_SW_T5_DEC,
111 TRIM_SW_T5_INC,
112 TRIM_SW_T6_DEC,
113 TRIM_SW_T6_INC,
114 TRIM_SW_COUNT
117 enum Capability {
118 Sticks,
119 Pots,
120 FactoryInstalledPots,
121 Sliders,
122 MouseAnalogs,
123 GyroAnalogs,
124 MaxAnalogs,
125 MultiposPots,
126 MultiposPotsPositions,
127 Switches,
128 SwitchPositions,
129 FactoryInstalledSwitches,
130 NumTrims,
131 NumTrimSwitches
134 struct SwitchInfo
136 SwitchType config;
137 QString name;
140 struct SwitchPosition {
141 SwitchPosition(unsigned int index, unsigned int position):
142 index(index),
143 position(position)
146 unsigned int index;
147 unsigned int position;
152 class Boards
154 Q_DECLARE_TR_FUNCTIONS(Boards)
156 public:
158 Boards(Board::Type board)
160 setBoardType(board);
163 void setBoardType(const Board::Type & board);
164 Board::Type getBoardType() const { return m_boardType; }
166 const uint32_t getFourCC() const { return getFourCC(m_boardType); }
167 const int getEEpromSize() const { return getEEpromSize(m_boardType); }
168 const int getFlashSize() const { return getFlashSize(m_boardType); }
169 const Board::SwitchInfo getSwitchInfo(int index) const { return getSwitchInfo(m_boardType, index); }
170 const int getCapability(Board::Capability capability) const { return getCapability(m_boardType, capability); }
171 const QString getAnalogInputName(int index) const { return getAnalogInputName(m_boardType, index); }
172 const bool isBoardCompatible(Board::Type board2) const { return isBoardCompatible(m_boardType, board2); }
174 static uint32_t getFourCC(Board::Type board);
175 static int getEEpromSize(Board::Type board);
176 static int getFlashSize(Board::Type board);
177 static Board::SwitchInfo getSwitchInfo(Board::Type board, int index);
178 static int getCapability(Board::Type board, Board::Capability capability);
179 static QString getAxisName(int index);
180 static QString getAnalogInputName(Board::Type board, int index);
181 static bool isBoardCompatible(Board::Type board1, Board::Type board2);
182 static QString getBoardName(Board::Type board);
184 protected:
186 Board::Type m_boardType;
189 // temporary aliases for transition period, use Boards class instead.
190 #define getBoardCapability(b__, c__) Boards::getCapability(b__, c__)
192 inline bool IS_9X(Board::Type board)
194 return board == Board::BOARD_9X_M64 || board == Board::BOARD_9X_M128;
197 inline bool IS_STOCK(Board::Type board)
199 return board == Board::BOARD_9X_M64;
202 inline bool IS_M128(Board::Type board)
204 return board == Board::BOARD_9X_M128;
207 inline bool IS_2560(Board::Type board)
209 return board == Board::BOARD_GRUVIN9X || board == Board::BOARD_MEGA2560;
212 inline bool IS_SKY9X(Board::Type board)
214 return board == Board::BOARD_SKY9X || board == Board::BOARD_9XRPRO || board == Board::BOARD_AR9X;
217 inline bool IS_9XRPRO(Board::Type board)
219 return board == Board::BOARD_9XRPRO;
222 inline bool IS_JUMPER_T12(Board::Type board)
224 return board == Board::BOARD_JUMPER_T12;
227 inline bool IS_JUMPER_T16(Board::Type board)
229 return board == Board::BOARD_JUMPER_T16;
232 inline bool IS_TARANIS_XLITE(Board::Type board)
234 return board == Board::BOARD_TARANIS_XLITE || board == Board::BOARD_TARANIS_XLITES;
237 inline bool IS_TARANIS_XLITES(Board::Type board)
239 return board == Board::BOARD_TARANIS_XLITES;
242 inline bool IS_TARANIS_X7(Board::Type board)
244 return board == Board::BOARD_TARANIS_X7;
247 inline bool IS_TARANIS_X9LITE(Board::Type board)
249 return board == Board::BOARD_TARANIS_X9LITE || board == Board::BOARD_TARANIS_X9LITES;
252 inline bool IS_TARANIS_X9(Board::Type board)
254 return board==Board::BOARD_TARANIS_X9D || board==Board::BOARD_TARANIS_X9DP || board==Board::BOARD_TARANIS_X9DP_2019 || board==Board::BOARD_TARANIS_X9E;
257 inline bool IS_TARANIS_X9D(Board::Type board)
259 return board == Board::BOARD_TARANIS_X9D || board == Board::BOARD_TARANIS_X9DP || board == Board::BOARD_TARANIS_X9DP_2019;
262 inline bool IS_TARANIS_PLUS(Board::Type board)
264 return board == Board::BOARD_TARANIS_X9DP || board == Board::BOARD_TARANIS_X9E;
267 inline bool IS_TARANIS_X9E(Board::Type board)
269 return board == Board::BOARD_TARANIS_X9E;
272 inline bool IS_TARANIS(Board::Type board)
274 return IS_TARANIS_X9(board) || IS_TARANIS_X7(board) || IS_TARANIS_X9LITE(board) || IS_TARANIS_XLITE(board) || IS_JUMPER_T12(board);
277 inline bool IS_TARANIS_SMALL(Board::Type board)
279 return IS_TARANIS_X7(board) || IS_TARANIS_XLITE(board) || IS_TARANIS_X9LITE(board) || IS_JUMPER_T12(board);
282 inline bool IS_HORUS_X10(Board::Type board)
284 return board == Board::BOARD_X10 || board == Board::BOARD_X10_EXPRESS;
287 inline bool IS_HORUS_X12S(Board::Type board)
289 return board == Board::BOARD_HORUS_X12S;
292 inline bool IS_HORUS(Board::Type board)
294 return IS_HORUS_X12S(board) || IS_HORUS_X10(board) || IS_JUMPER_T16(board);
297 inline bool IS_HORUS_OR_TARANIS(Board::Type board)
299 return IS_HORUS(board) || IS_TARANIS(board);
302 inline bool IS_STM32(Board::Type board)
304 return IS_TARANIS(board) || IS_HORUS(board);
307 inline bool IS_ARM(Board::Type board)
309 return IS_STM32(board) || IS_SKY9X(board);
312 inline bool HAS_LARGE_LCD(Board::Type board)
314 return IS_HORUS(board) || IS_TARANIS_X9(board);
317 inline bool HAS_EXTERNAL_ANTENNA(Board::Type board)
319 return (board == Board::BOARD_X10 || board == Board::BOARD_HORUS_X12S || (IS_TARANIS_XLITE(board) && !IS_TARANIS_XLITES(board)));
322 inline bool IS_ACCESS_RADIO(Board::Type board, QString &id)
324 return (IS_TARANIS_XLITES(board) || IS_TARANIS_X9LITE(board) || board == Board::BOARD_TARANIS_X9DP_2019 || board == Board::BOARD_X10_EXPRESS ||
325 (IS_HORUS(board) && id.contains("internalaccess")));
328 #endif // _BOARDS_H_