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.
24 // TODO remove all those constants
25 // Update: These are now all only used within this class.
26 // External access is only via getEEpromSize() and getFlashSize()
28 #define EESIZE_STOCK 2048
29 #define EESIZE_M128 4096
30 #define EESIZE_GRUVIN9X 4096
31 #define EESIZE_TARANIS (32*1024)
32 #define EESIZE_SKY9X (128*4096)
33 #define EESIZE_9XRPRO (128*4096)
34 #define EESIZE_MAX EESIZE_9XRPRO
36 // getFlashSize() (and these macros) is only used by radiointerface::getDfuArgs (perhaps can find a better way?)
37 #define FSIZE_STOCK (64*1024)
38 #define FSIZE_M128 (128*1024)
39 #define FSIZE_GRUVIN9X (256*1024)
40 #define FSIZE_TARANIS (512*1024)
41 #define FSIZE_SKY9X (256*1024)
42 #define FSIZE_9XRPRO (512*1024)
43 #define FSIZE_HORUS (2048*1024)
44 #define FSIZE_MAX FSIZE_HORUS
46 using namespace Board
;
48 void Boards::setBoardType(const Type
& board
)
50 if (board
>= BOARD_UNKNOWN
&& board
< BOARD_ENUM_COUNT
)
53 m_boardType
= BOARD_UNKNOWN
;
56 const int Boards::getEEpromSize(Board::Type board
)
65 return EESIZE_GRUVIN9X
;
71 case BOARD_TARANIS_X7
:
72 case BOARD_TARANIS_X9D
:
73 case BOARD_TARANIS_X9DP
:
74 case BOARD_TARANIS_X9E
:
76 return EESIZE_TARANIS
;
80 return 0; // unlimited
84 const int Boards::getFlashSize(Type board
)
93 return FSIZE_GRUVIN9X
;
99 case BOARD_TARANIS_X9D
:
100 case BOARD_TARANIS_X9DP
:
101 case BOARD_TARANIS_X9E
:
103 return FSIZE_TARANIS
;
114 const SwitchInfo
Boards::getSwitchInfo(Board::Type board
, unsigned index
)
116 if (IS_TARANIS_X7(board
)) {
117 const Board::SwitchInfo switches
[] = {
123 {SWITCH_TOGGLE
, "SH"}
125 if (index
< DIM(switches
))
126 return switches
[index
];
128 else if (IS_HORUS_OR_TARANIS(board
)) {
129 const Board::SwitchInfo switches
[] = {
137 {SWITCH_TOGGLE
, "SH"},
149 if (index
< DIM(switches
))
150 return switches
[index
];
153 const Board::SwitchInfo switches
[] = {
154 {SWITCH_2POS
, "THR"},
155 {SWITCH_2POS
, "RUD"},
156 {SWITCH_2POS
, "ELE"},
157 {SWITCH_3POS
, "3POS"},
158 {SWITCH_2POS
, "AIL"},
159 {SWITCH_2POS
, "GEA"},
160 {SWITCH_TOGGLE
, "TRN"}
162 if (index
< DIM(switches
))
163 return switches
[index
];
166 return {SWITCH_NOT_AVAILABLE
, "???"};
169 const int Boards::getCapability(Board::Type board
, Board::Capability capability
)
171 switch (capability
) {
177 else if (IS_TARANIS_X7(board
))
179 else if (IS_TARANIS_X9E(board
))
181 else if (IS_TARANIS(board
))
188 else if (IS_TARANIS_X7(board
))
190 else if (IS_TARANIS_X9E(board
))
192 else if (IS_TARANIS(board
))
201 case FactoryInstalledSwitches
:
202 if (IS_TARANIS_X9E(board
))
206 if (IS_TARANIS_X9E(board
))
208 else if (IS_TARANIS_X7(board
))
210 else if (IS_HORUS_OR_TARANIS(board
))
214 case SwitchPositions
:
215 if (IS_HORUS_OR_TARANIS(board
))
216 return getCapability(board
, Switches
) * 3;
224 case NumTrimSwitches
:
225 return getCapability(board
, NumTrims
) * 2;
231 const QString
Boards::getAxisName(int index
)
233 const QString axes
[] = {
234 QObject::tr("Left Horizontal"),
235 QObject::tr("Left Vertical"),
236 QObject::tr("Right Vertical"),
237 QObject::tr("Right Horizontal"),
238 QObject::tr("Aux. 1"),
239 QObject::tr("Aux. 2"),
241 if (index
< (int)DIM(axes
))
244 return QObject::tr("Unknown");
249 const QString Boards::getBoardName(Board::Type board)
260 case BOARD_TARANIS_X7:
262 case BOARD_TARANIS_X9D:
263 return "Taranis X9D";
264 case BOARD_TARANIS_X9DP:
265 return "Taranis X9D+";
266 case BOARD_TARANIS_X9E:
267 return "Taranis X9E";
279 return QObject::tr("Unknown");