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
:
102 case BOARD_TARANIS_X7
:
104 return FSIZE_TARANIS
;
115 const SwitchInfo
Boards::getSwitchInfo(Board::Type board
, unsigned index
)
117 if (IS_TARANIS_X7(board
)) {
118 const Board::SwitchInfo switches
[] = {
124 {SWITCH_TOGGLE
, "SH"}
126 if (index
< DIM(switches
))
127 return switches
[index
];
129 else if (IS_HORUS_OR_TARANIS(board
)) {
130 const Board::SwitchInfo switches
[] = {
138 {SWITCH_TOGGLE
, "SH"},
150 if (index
< DIM(switches
))
151 return switches
[index
];
154 const Board::SwitchInfo switches
[] = {
155 {SWITCH_3POS
, "3POS"},
156 {SWITCH_2POS
, "THR"},
157 {SWITCH_2POS
, "RUD"},
158 {SWITCH_2POS
, "ELE"},
159 {SWITCH_2POS
, "AIL"},
160 {SWITCH_2POS
, "GEA"},
161 {SWITCH_TOGGLE
, "TRN"}
163 if (index
< DIM(switches
))
164 return switches
[index
];
167 return {SWITCH_NOT_AVAILABLE
, "???"};
170 const int Boards::getCapability(Board::Type board
, Board::Capability capability
)
172 switch (capability
) {
178 else if (IS_TARANIS_X7(board
))
180 else if (IS_TARANIS_X9E(board
))
182 else if (IS_TARANIS(board
))
189 else if (IS_TARANIS_X7(board
))
191 else if (IS_TARANIS_X9E(board
))
193 else if (IS_TARANIS(board
))
202 case FactoryInstalledSwitches
:
203 if (IS_TARANIS_X9E(board
))
207 if (IS_TARANIS_X9E(board
))
209 else if (IS_TARANIS_X7(board
))
211 else if (IS_HORUS_OR_TARANIS(board
))
215 case SwitchPositions
:
216 if (IS_HORUS_OR_TARANIS(board
))
217 return getCapability(board
, Switches
) * 3;
225 case NumTrimSwitches
:
226 return getCapability(board
, NumTrims
) * 2;
232 const QString
Boards::getAxisName(int index
)
234 const QString axes
[] = {
235 QObject::tr("Left Horizontal"),
236 QObject::tr("Left Vertical"),
237 QObject::tr("Right Vertical"),
238 QObject::tr("Right Horizontal"),
239 QObject::tr("Aux. 1"),
240 QObject::tr("Aux. 2"),
242 if (index
< (int)DIM(axes
))
245 return QObject::tr("Unknown");
250 const QString Boards::getBoardName(Board::Type board)
261 case BOARD_TARANIS_X7:
263 case BOARD_TARANIS_X9D:
264 return "Taranis X9D";
265 case BOARD_TARANIS_X9DP:
266 return "Taranis X9D+";
267 case BOARD_TARANIS_X9E:
268 return "Taranis X9E";
280 return QObject::tr("Unknown");