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.
28 // TODO create a Board class with all these functions
45 BOARD_TARANIS_X9DP_2019
,
53 BOARD_TARANIS_X9LITES
,
58 constexpr int BOARD_TYPE_MAX
= BOARD_JUMPER_T16
;
120 FactoryInstalledPots
,
126 MultiposPotsPositions
,
129 FactoryInstalledSwitches
,
140 struct SwitchPosition
{
141 SwitchPosition(unsigned int index
, unsigned int position
):
147 unsigned int position
;
154 Q_DECLARE_TR_FUNCTIONS(Boards
)
158 Boards(Board::Type 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
);
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")));