[Companion] Refactoring - fixes the X9E=>X7 conversion segfault
[opentx.git] / companion / src / boards.cpp
blob00db08bbb7e2650770909c588d2e2282d85f7ef8
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 #include "boards.h"
22 #include "macros.h"
24 int getEEpromSize(BoardEnum board)
26 switch (board) {
27 case BOARD_STOCK:
28 return EESIZE_STOCK;
29 case BOARD_M128:
30 return EESIZE_M128;
31 case BOARD_MEGA2560:
32 case BOARD_GRUVIN9X:
33 return EESIZE_GRUVIN9X;
34 case BOARD_SKY9X:
35 return EESIZE_SKY9X;
36 case BOARD_9XRPRO:
37 case BOARD_AR9X:
38 return EESIZE_9XRPRO;
39 case BOARD_TARANIS_X7:
40 case BOARD_TARANIS_X9D:
41 case BOARD_TARANIS_X9DP:
42 case BOARD_TARANIS_X9E:
43 case BOARD_FLAMENCO:
44 return EESIZE_TARANIS;
45 default:
46 return 0; // unlimited
50 SwitchInfo getSwitchInfo(BoardEnum board, unsigned index)
52 if (IS_TARANIS_X7(board)) {
53 const SwitchInfo switches[] = {{SWITCH_3POS, "SA"},
54 {SWITCH_3POS, "SB"},
55 {SWITCH_3POS, "SC"},
56 {SWITCH_3POS, "SD"},
57 {SWITCH_2POS, "SF"},
58 {SWITCH_TOGGLE, "SH"}};
59 if (index < DIM(switches))
60 return switches[index];
62 else if (IS_HORUS_OR_TARANIS(board)) {
63 const SwitchInfo switches[] = {{SWITCH_3POS, "SA"},
64 {SWITCH_3POS, "SB"},
65 {SWITCH_3POS, "SC"},
66 {SWITCH_3POS, "SD"},
67 {SWITCH_3POS, "SE"},
68 {SWITCH_2POS, "SF"},
69 {SWITCH_3POS, "SG"},
70 {SWITCH_TOGGLE, "SH"},
71 {SWITCH_3POS, "SI"},
72 {SWITCH_3POS, "SJ"},
73 {SWITCH_3POS, "SK"},
74 {SWITCH_3POS, "SL"},
75 {SWITCH_3POS, "SM"},
76 {SWITCH_3POS, "SN"},
77 {SWITCH_3POS, "SO"},
78 {SWITCH_3POS, "SP"},
79 {SWITCH_3POS, "SQ"},
80 {SWITCH_3POS, "SR"}};
81 if (index < DIM(switches))
82 return switches[index];
84 else {
85 const SwitchInfo switches[] = {{SWITCH_2POS, "THR"},
86 {SWITCH_2POS, "RUD"},
87 {SWITCH_2POS, "ELE"},
88 {SWITCH_3POS, "3POS"},
89 {SWITCH_2POS, "AIL"},
90 {SWITCH_2POS, "GEA"},
91 {SWITCH_TOGGLE, "TRN"}};
92 if (index < DIM(switches))
93 return switches[index];
96 return {SWITCH_NOT_AVAILABLE, "???"};