X10 fixes (#5221)
[opentx.git] / companion / src / boards.h
blobce9e15695008fc7f70c4732a9a997f9924a07394
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 <QObject>
25 #include <QString>
27 // TODO create a Board class with all these functions
29 namespace Board {
31 enum Type
33 BOARD_UNKNOWN = -1,
34 BOARD_STOCK = 0,
35 BOARD_M128,
36 BOARD_MEGA2560,
37 BOARD_GRUVIN9X,
38 BOARD_SKY9X,
39 BOARD_9XRPRO,
40 BOARD_AR9X,
41 BOARD_TARANIS_X7,
42 BOARD_TARANIS_X9D,
43 BOARD_TARANIS_X9DP,
44 BOARD_TARANIS_X9E,
45 BOARD_FLAMENCO,
46 BOARD_X12S,
47 BOARD_X10,
48 BOARD_ENUM_COUNT
51 enum PotType
53 POT_NONE,
54 POT_WITH_DETENT,
55 POT_MULTIPOS_SWITCH,
56 POT_WITHOUT_DETENT
59 enum SliderType
61 SLIDER_NONE,
62 SLIDER_WITH_DETENT
65 enum SwitchType
67 SWITCH_NOT_AVAILABLE,
68 SWITCH_TOGGLE,
69 SWITCH_2POS,
70 SWITCH_3POS
73 enum StickAxes {
74 STICK_AXIS_LH = 0,
75 STICK_AXIS_LV,
76 STICK_AXIS_RV,
77 STICK_AXIS_RH,
78 STICK_AXIS_COUNT
81 enum TrimAxes {
82 TRIM_AXIS_LH = 0,
83 TRIM_AXIS_LV,
84 TRIM_AXIS_RV,
85 TRIM_AXIS_RH,
86 TRIM_AXIS_T5,
87 TRIM_AXIS_T6,
88 TRIM_AXIS_COUNT
91 enum TrimSwitches
93 TRIM_SW_LH_DEC,
94 TRIM_SW_LH_INC,
95 TRIM_SW_LV_DEC,
96 TRIM_SW_LV_INC,
97 TRIM_SW_RV_DEC,
98 TRIM_SW_RV_INC,
99 TRIM_SW_RH_DEC,
100 TRIM_SW_RH_INC,
101 TRIM_SW_T5_DEC,
102 TRIM_SW_T5_INC,
103 TRIM_SW_T6_DEC,
104 TRIM_SW_T6_INC,
105 TRIM_SW_COUNT
108 enum Capability {
109 Sticks,
110 Pots,
111 Sliders,
112 MouseAnalogs,
113 Switches,
114 SwitchPositions,
115 FactoryInstalledSwitches,
116 NumTrims,
117 NumTrimSwitches
120 struct SwitchInfo
122 SwitchType config;
123 QString name;
126 struct SwitchPosition {
127 SwitchPosition(unsigned int index, unsigned int position):
128 index(index),
129 position(position)
132 unsigned int index;
133 unsigned int position;
138 class Boards
140 public:
142 Boards(Board::Type board)
144 setBoardType(board);
147 void setBoardType(const Board::Type & board);
148 Board::Type getBoardType() const { return m_boardType; }
150 const int getEEpromSize() { return getEEpromSize(m_boardType); }
151 const int getFlashSize() { return getFlashSize(m_boardType); }
152 const Board::SwitchInfo getSwitchInfo(unsigned index) { return getSwitchInfo(m_boardType, index); }
153 const int getCapability(Board::Capability capability) { return getCapability(m_boardType, capability); }
155 static const int getEEpromSize(Board::Type board);
156 static const int getFlashSize(Board::Type board);
157 static const Board::SwitchInfo getSwitchInfo(Board::Type board, unsigned index);
158 static const int getCapability(Board::Type board, Board::Capability capability);
159 static const QString getAxisName(int index);
161 protected:
163 Board::Type m_boardType;
166 // temporary aliases for transition period, use Boards class instead.
167 #define getBoardCapability(b__, c__) Boards::getCapability(b__, c__)
168 #define getEEpromSize(b__) Boards::getEEpromSize(b__)
169 #define getSwitchInfo(b__, i__) Boards::getSwitchInfo(b__, i__)
171 #define IS_9X(board) (board==Board::BOARD_STOCK || board==Board::BOARD_M128)
172 #define IS_STOCK(board) (board==Board::BOARD_STOCK)
173 #define IS_2560(board) (board==Board::BOARD_GRUVIN9X || board==Board::BOARD_MEGA2560)
174 #define IS_SKY9X(board) (board==Board::BOARD_SKY9X || board==Board::BOARD_9XRPRO || board==Board::BOARD_AR9X)
175 #define IS_9XRPRO(board) (board==Board::BOARD_9XRPRO)
176 #define IS_TARANIS_X7(board) (board==Board::BOARD_TARANIS_X7)
177 #define IS_TARANIS_X9(board) (board==Board::BOARD_TARANIS_X9D || board==Board::BOARD_TARANIS_X9DP || board==Board::BOARD_TARANIS_X9E)
178 #define IS_TARANIS_X9D(board) (board==Board::BOARD_TARANIS_X9D || board==Board::BOARD_TARANIS_X9DP)
179 #define IS_TARANIS_PLUS(board) (board==Board::BOARD_TARANIS_X9DP || board==Board::BOARD_TARANIS_X9E)
180 #define IS_TARANIS_X9E(board) (board==Board::BOARD_TARANIS_X9E)
181 #define IS_TARANIS(board) (IS_TARANIS_X9(board) || IS_TARANIS_X7(board))
182 #define IS_HORUS_X12S(board) (board==Board::BOARD_X12S)
183 #define IS_HORUS_X10(board) (board==Board::BOARD_X10)
184 #define IS_HORUS(board) (IS_HORUS_X12S(board) || IS_HORUS_X10(board))
185 #define IS_HORUS_OR_TARANIS(board) (IS_HORUS(board) || IS_TARANIS(board))
186 #define IS_FLAMENCO(board) (board==Board::BOARD_FLAMENCO)
187 #define IS_STM32(board) (IS_TARANIS(board) || IS_HORUS(board) || IS_FLAMENCO(board))
188 #define IS_ARM(board) (IS_STM32(board) || IS_SKY9X(board))
189 #define HAS_LARGE_LCD(board) (IS_HORUS(board) || (IS_TARANIS(board) && !IS_TARANIS_X7(board)))
191 #endif // _BOARDS_H_