Fix doc path
[opentx.git] / companion / src / firmwares / boards.h
blobce9dafe5af122b4bcca7ac5856599d70a66fa20e
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_STOCK = 0,
36 BOARD_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_X9E,
46 BOARD_X12S,
47 BOARD_X10,
48 BOARD_TARANIS_XLITE,
49 BOARD_ENUM_COUNT
52 enum PotType
54 POT_NONE,
55 POT_WITH_DETENT,
56 POT_MULTIPOS_SWITCH,
57 POT_WITHOUT_DETENT
60 enum SliderType
62 SLIDER_NONE,
63 SLIDER_WITH_DETENT
66 enum SwitchType
68 SWITCH_NOT_AVAILABLE,
69 SWITCH_TOGGLE,
70 SWITCH_2POS,
71 SWITCH_3POS
74 enum StickAxes {
75 STICK_AXIS_LH = 0,
76 STICK_AXIS_LV,
77 STICK_AXIS_RV,
78 STICK_AXIS_RH,
79 STICK_AXIS_COUNT
82 enum TrimAxes {
83 TRIM_AXIS_LH = 0,
84 TRIM_AXIS_LV,
85 TRIM_AXIS_RV,
86 TRIM_AXIS_RH,
87 TRIM_AXIS_T5,
88 TRIM_AXIS_T6,
89 TRIM_AXIS_COUNT
92 enum TrimSwitches
94 TRIM_SW_LH_DEC,
95 TRIM_SW_LH_INC,
96 TRIM_SW_LV_DEC,
97 TRIM_SW_LV_INC,
98 TRIM_SW_RV_DEC,
99 TRIM_SW_RV_INC,
100 TRIM_SW_RH_DEC,
101 TRIM_SW_RH_INC,
102 TRIM_SW_T5_DEC,
103 TRIM_SW_T5_INC,
104 TRIM_SW_T6_DEC,
105 TRIM_SW_T6_INC,
106 TRIM_SW_COUNT
109 enum Capability {
110 Sticks,
111 Pots,
112 FactoryInstalledPots,
113 Sliders,
114 MouseAnalogs,
115 MaxAnalogs,
116 MultiposPots,
117 MultiposPotsPositions,
118 Switches,
119 SwitchPositions,
120 FactoryInstalledSwitches,
121 NumTrims,
122 NumTrimSwitches
125 struct SwitchInfo
127 SwitchType config;
128 QString name;
131 struct SwitchPosition {
132 SwitchPosition(unsigned int index, unsigned int position):
133 index(index),
134 position(position)
137 unsigned int index;
138 unsigned int position;
143 class Boards
145 Q_DECLARE_TR_FUNCTIONS(Boards)
147 public:
149 Boards(Board::Type board)
151 setBoardType(board);
154 void setBoardType(const Board::Type & board);
155 Board::Type getBoardType() const { return m_boardType; }
157 const uint32_t getFourCC() const { return getFourCC(m_boardType); }
158 const int getEEpromSize() const { return getEEpromSize(m_boardType); }
159 const int getFlashSize() const { return getFlashSize(m_boardType); }
160 const Board::SwitchInfo getSwitchInfo(unsigned index) const { return getSwitchInfo(m_boardType, index); }
161 const int getCapability(Board::Capability capability) const { return getCapability(m_boardType, capability); }
162 const QString getAnalogInputName(unsigned index) const { return getAnalogInputName(m_boardType, index); }
163 const bool isBoardCompatible(Board::Type board2) const { return isBoardCompatible(m_boardType, board2); }
165 static uint32_t getFourCC(Board::Type board);
166 static const int getEEpromSize(Board::Type board);
167 static const int getFlashSize(Board::Type board);
168 static const Board::SwitchInfo getSwitchInfo(Board::Type board, unsigned index);
169 static const int getCapability(Board::Type board, Board::Capability capability);
170 static const QString getAxisName(int index);
171 static const QString getAnalogInputName(Board::Type board, unsigned index);
172 static const bool isBoardCompatible(Board::Type board1, Board::Type board2);
173 static const QString getBoardName(Board::Type board);
175 protected:
177 Board::Type m_boardType;
180 // temporary aliases for transition period, use Boards class instead.
181 #define getBoardCapability(b__, c__) Boards::getCapability(b__, c__)
182 #define getEEpromSize(b__) Boards::getEEpromSize(b__)
183 #define getSwitchInfo(b__, i__) Boards::getSwitchInfo(b__, i__)
185 #define IS_9X(board) (board==Board::BOARD_STOCK || board==Board::BOARD_M128)
186 #define IS_STOCK(board) (board==Board::BOARD_STOCK)
187 #define IS_M128(board) (board==Board::BOARD_M128)
188 #define IS_2560(board) (board==Board::BOARD_GRUVIN9X || board==Board::BOARD_MEGA2560)
189 #define IS_SKY9X(board) (board==Board::BOARD_SKY9X || board==Board::BOARD_9XRPRO || board==Board::BOARD_AR9X)
190 #define IS_9XRPRO(board) (board==Board::BOARD_9XRPRO)
191 #define IS_TARANIS_XLITE(board) (board==Board::BOARD_TARANIS_XLITE)
192 #define IS_TARANIS_X7(board) (board==Board::BOARD_TARANIS_X7)
193 #define IS_TARANIS_X9(board) (board==Board::BOARD_TARANIS_X9D || board==Board::BOARD_TARANIS_X9DP || board==Board::BOARD_TARANIS_X9E)
194 #define IS_TARANIS_X9D(board) (board==Board::BOARD_TARANIS_X9D || board==Board::BOARD_TARANIS_X9DP)
195 #define IS_TARANIS_PLUS(board) (board==Board::BOARD_TARANIS_X9DP || board==Board::BOARD_TARANIS_X9E)
196 #define IS_TARANIS_X9E(board) (board==Board::BOARD_TARANIS_X9E)
197 #define IS_TARANIS(board) (IS_TARANIS_X9(board) || IS_TARANIS_X7(board) || IS_TARANIS_XLITE(board))
198 #define IS_TARANIS_SMALL(board) (board==Board::BOARD_TARANIS_X7 || board==Board::BOARD_TARANIS_XLITE)
199 #define IS_TARANIS_NOT_X9E(board) (IS_TARANIS(board) && !IS_TARANIS_X9E(board))
200 #define IS_HORUS_X12S(board) (board==Board::BOARD_X12S)
201 #define IS_HORUS_X10(board) (board==Board::BOARD_X10)
202 #define IS_HORUS(board) (IS_HORUS_X12S(board) || IS_HORUS_X10(board))
203 #define IS_HORUS_OR_TARANIS(board) (IS_HORUS(board) || IS_TARANIS(board))
204 #define IS_STM32(board) (IS_TARANIS(board) || IS_HORUS(board))
205 #define IS_ARM(board) (IS_STM32(board) || IS_SKY9X(board))
206 #define HAS_LARGE_LCD(board) (IS_HORUS(board) || IS_TARANIS_X9(board))
208 #endif // _BOARDS_H_