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.
23 #include "multiprotocols.h"
24 #include "radiodata.h"
26 #define STR_MULTI_SUBTYPE QT_TRANSLATE_NOOP("Multiprotocols", "Subtype")
27 #define STR_MULTI_VIDFREQ QT_TRANSLATE_NOOP("Multiprotocols", "Video TX frequency")
28 #define STR_MULTI_RFTUNE QT_TRANSLATE_NOOP("Multiprotocols", "CC2500 frequency fine tune")
29 #define STR_MULTI_TELEMETRY QT_TRANSLATE_NOOP("Multiprotocols", "Telemetry")
30 #define STR_MULTI_RFPOWER QT_TRANSLATE_NOOP("Multiprotocols", "Radio output power")
31 #define STR_MULTI_SERVOFREQ QT_TRANSLATE_NOOP("Multiprotocols", "Servo output frequency")
32 #define STR_MULTI_OPTION QT_TRANSLATE_NOOP("Multiprotocols", "Option value")
33 #define STR_MULTI_FIXEDID QT_TRANSLATE_NOOP("Multiprotocols", "Fixed ID value")
34 #define STR_MULTI_DEFAULT QT_TRANSLATE_NOOP("Multiprotocols", "DEFAULT")
36 static const QStringList
STR_SUBTYPE_CUSTOM ({
37 STR_MULTI_SUBTYPE
" 0", STR_MULTI_SUBTYPE
" 1", STR_MULTI_SUBTYPE
" 2", STR_MULTI_SUBTYPE
" 3",
38 STR_MULTI_SUBTYPE
" 4", STR_MULTI_SUBTYPE
" 5", STR_MULTI_SUBTYPE
" 6", STR_MULTI_SUBTYPE
" 7"
40 static const QStringList STR_SUBTYPE_FLYSKY
{"Standard", "V9x9", "V6x6", "V912", "CX20"};
41 static const QStringList STR_SUBTYPE_HUBSAN
{"H107", "H301", "H501"};
42 static const QStringList STR_SUBTYPE_FRSKY
{"D16", "D8", "D16 8ch", "V8", "D16 EU-LBT", "D16 EU-LBT 8ch"};
43 static const QStringList STR_SUBTYPE_HISKY
{"Standard", "HK310"};
44 static const QStringList STR_SUBTYPE_V2X2
{"Standard", "JXD506"};
45 static const QStringList STR_SUBTYPE_DSM
{"DSM2 22ms", "DSM2 11ms", "DSMX 22ms", "DSMX 11ms"};
46 static const QStringList STR_SUBTYPE_DEVO
{"8 Channel", "10 Channel", "12 Channel", "6 Channel", "7 Channel"};
47 static const QStringList STR_SUBTYPE_YD717
{"Standard", "Skywalker", "Syma X4", "XINXUN", "NIHUI"};
48 static const QStringList STR_SUBTYPE_KN
{"WLtoys", "FeiLun"};
49 static const QStringList STR_SUBTYPE_SYMAX
{"Standard", "Syma X5C"};
50 static const QStringList STR_SUBTYPE_SLT
{"V1 (6 Channel)", "V2 (8 Channel)", "Q100", "Q200", "MR100"};
51 static const QStringList STR_SUBTYPE_CX10
{"Green", "Blue", "DM007", "-", "JC3015a", "JC3015b", "MK33041"};
52 static const QStringList STR_SUBTYPE_CG023
{"Standard", "YD829"};
53 static const QStringList STR_SUBTYPE_BAYANG
{"Standard", "H8S3D", "X16 AH", "IRDRONE", "DHD D4"};
54 static const QStringList STR_SUBTYPE_MT99
{"MT99", "H7", "YZ", "LS", "FY805"};
55 static const QStringList STR_SUBTYPE_MJXQ
{"WLH08", "X600", "X800", "H26D", "E010", "H26WH", "Phoenix"};
56 static const QStringList STR_SUBTYPE_FY326
{"Standard", "FY319"};
57 static const QStringList STR_SUBTYPE_HONTAI
{"Standard", "JJRC X1", "X5C1 Clone", "FQ777_951"};
58 static const QStringList STR_SUBTYPE_AFHDS2A
{"PWM and IBUS", "PPM and IBUS", "PWM and SBUS", "PPM and SBUS"};
59 static const QStringList STR_SUBTYPE_Q2X2
{"Q222", "Q242", "Q282"};
60 static const QStringList STR_SUBTYPE_WK2x01
{"WK2801", "WK2401", "W6_5_1", "W6_6_1", "W6_HEL", "W6_HEL_I"};
61 static const QStringList STR_SUBTYPE_Q303
{"Standard", "CX35", "CX10D", "CX10WD"};
62 static const QStringList STR_SUBTYPE_CABELL
{"Cabell V3", "Cab V3 Telem", "-", "-", "-", "-", "Set FailSafe", "Unbind"};
63 static const QStringList STR_SUBTYPE_H83D
{"H8 Mini 3D", "H20H", "H20 Mini", "H30 Mini"};
64 static const QStringList STR_SUBTYPE_CORONA
{"Corona V1", "Corona V2", "Flydream V3"};
65 static const QStringList STR_SUBTYPE_HITEC
{"Optima", "Optima Hub Telem", "Minima"};
66 static const QStringList STR_SUBTYPE_TRAXXAS
{"6519 RX"};
67 static const QStringList STR_SUBTYPE_BUGS_MINI
{"Standard", "Bugs 3H"};
68 static const QStringList STR_SUBTYPE_E01X
{"E012", "E015", "E016H"};
69 static const QStringList STR_SUBTYPE_GD00X
{"GD V1", "GD V2"};
70 static const QStringList STR_SUBTYPE_REDPINE
{"Fast", "Slow"};
71 static const QStringList STR_SUBTYPE_POTENSIC
{"A20 Firefly"};
72 static const QStringList STR_SUBTYPE_ZSX
{"JJRC ZSX-280"};
73 static const QStringList STR_SUBTYPE_FLYZONE
{"FZ-410 TX"};
74 static const QStringList STR_SUBTYPE_FRSKYX_RX
{"D16 FCC", "D16 LBT"};
76 static const QStringList NO_SUBTYPE
{STR_MULTI_DEFAULT
};
79 // Table is designed to be shared with gui_common_arm.cpp
81 const Multiprotocols multiProtocols
{
82 {MODULE_SUBTYPE_MULTI_FLYSKY
, 4, false, STR_SUBTYPE_FLYSKY
, nullptr},
83 {MODULE_SUBTYPE_MULTI_HUBSAN
, 2, false, STR_SUBTYPE_HUBSAN
, STR_MULTI_VIDFREQ
},
84 {MODULE_SUBTYPE_MULTI_FRSKY
, 5, false, STR_SUBTYPE_FRSKY
, STR_MULTI_RFTUNE
},
85 {MODULE_SUBTYPE_MULTI_HISKY
, 1, false, STR_SUBTYPE_HISKY
, nullptr},
86 {MODULE_SUBTYPE_MULTI_V2X2
, 1, false, STR_SUBTYPE_V2X2
, nullptr},
87 {MODULE_SUBTYPE_MULTI_DSM2
, 3, false, STR_SUBTYPE_DSM
, nullptr},
88 {MODULE_SUBTYPE_MULTI_DEVO
, 4, false, STR_SUBTYPE_DEVO
, STR_MULTI_FIXEDID
},
89 {MODULE_SUBTYPE_MULTI_YD717
, 4, false, STR_SUBTYPE_YD717
, nullptr},
90 {MODULE_SUBTYPE_MULTI_KN
, 1, false, STR_SUBTYPE_KN
, nullptr},
91 {MODULE_SUBTYPE_MULTI_SYMAX
, 1, false, STR_SUBTYPE_SYMAX
, nullptr},
92 {MODULE_SUBTYPE_MULTI_SLT
, 4, false, STR_SUBTYPE_SLT
, nullptr},
93 {MODULE_SUBTYPE_MULTI_CX10
, 6, false, STR_SUBTYPE_CX10
, nullptr},
94 {MODULE_SUBTYPE_MULTI_CG023
, 1, false, STR_SUBTYPE_CG023
, nullptr},
95 {MODULE_SUBTYPE_MULTI_BAYANG
, 4, false, STR_SUBTYPE_BAYANG
, STR_MULTI_TELEMETRY
},
96 {MODULE_SUBTYPE_MULTI_MT99XX
, 4, false, STR_SUBTYPE_MT99
, nullptr},
97 {MODULE_SUBTYPE_MULTI_MJXQ
, 6, false, STR_SUBTYPE_MJXQ
, STR_MULTI_RFTUNE
},
98 {MODULE_SUBTYPE_MULTI_FY326
, 1, false, STR_SUBTYPE_FY326
, nullptr},
99 {MODULE_SUBTYPE_MULTI_SFHSS
, 0, true, NO_SUBTYPE
, STR_MULTI_RFTUNE
},
100 {MODULE_SUBTYPE_MULTI_HONTAI
, 3, false, STR_SUBTYPE_HONTAI
, nullptr},
101 {MODULE_SUBTYPE_MULTI_OLRS
, 0, false, NO_SUBTYPE
, STR_MULTI_RFPOWER
},
102 {MODULE_SUBTYPE_MULTI_FS_AFHDS2A
, 3, true, STR_SUBTYPE_AFHDS2A
, STR_MULTI_SERVOFREQ
},
103 {MODULE_SUBTYPE_MULTI_Q2X2
, 2, false, STR_SUBTYPE_Q2X2
, nullptr},
104 {MODULE_SUBTYPE_MULTI_WK_2X01
, 5, false, STR_SUBTYPE_WK2x01
, nullptr},
105 {MODULE_SUBTYPE_MULTI_Q303
, 3, false, STR_SUBTYPE_Q303
, nullptr},
106 {MODULE_SUBTYPE_MULTI_CABELL
, 7, false, STR_SUBTYPE_CABELL
, STR_MULTI_OPTION
},
107 {MODULE_SUBTYPE_MULTI_H83D
, 3, false, STR_SUBTYPE_H83D
, nullptr},
108 {MODULE_SUBTYPE_MULTI_CORONA
, 2, false, STR_SUBTYPE_CORONA
, STR_MULTI_RFTUNE
},
109 {MODULE_SUBTYPE_MULTI_HITEC
, 2, false, STR_SUBTYPE_HITEC
, STR_MULTI_RFTUNE
},
110 {MODULE_SUBTYPE_MULTI_BUGS_MINI
, 1, false, STR_SUBTYPE_BUGS_MINI
, nullptr},
111 {MODULE_SUBTYPE_MULTI_TRAXXAS
, 0, false, STR_SUBTYPE_TRAXXAS
, nullptr},
112 {MODULE_SUBTYPE_MULTI_E01X
, 2, false, STR_SUBTYPE_E01X
, STR_MULTI_OPTION
},
113 {MODULE_SUBTYPE_MULTI_V911S
, 0, false, NO_SUBTYPE
, STR_MULTI_RFTUNE
},
114 {MODULE_SUBTYPE_MULTI_GD00X
, 1, false, STR_SUBTYPE_GD00X
, nullptr},
115 {MODULE_SUBTYPE_MULTI_KF606
, 0, false, NO_SUBTYPE
, STR_MULTI_RFTUNE
},
116 {MODULE_SUBTYPE_MULTI_REDPINE
, 1, false, STR_SUBTYPE_REDPINE
, STR_MULTI_RFTUNE
},
117 {MODULE_SUBTYPE_MULTI_POTENSIC
, 0, false, STR_SUBTYPE_POTENSIC
, nullptr},
118 {MODULE_SUBTYPE_MULTI_ZSX
, 0, false, STR_SUBTYPE_ZSX
, nullptr},
119 {MODULE_SUBTYPE_MULTI_FLYZONE
, 0, false, STR_SUBTYPE_FLYZONE
, nullptr},
120 {MODULE_SUBTYPE_MULTI_FRSKYX_RX
, 1, false, STR_SUBTYPE_FRSKYX_RX
, STR_MULTI_RFTUNE
},
121 {MM_RF_CUSTOM_SELECTED
, 7, true, STR_SUBTYPE_CUSTOM
, STR_MULTI_OPTION
},
123 // Sentinel and default for protocols not listed above (MM_RF_CUSTOM is 0xff)
124 { 0xfe, 0, false, NO_SUBTYPE
, nullptr}
127 int Multiprotocols::MultiProtocolDefinition::getOptionMin() const {
128 if (optionsstr
== STR_MULTI_RFPOWER
)
130 else if (optionsstr
== STR_MULTI_SERVOFREQ
)
136 int Multiprotocols::MultiProtocolDefinition::getOptionMax() const {
137 if (optionsstr
== STR_MULTI_RFPOWER
)
139 else if (optionsstr
== STR_MULTI_SERVOFREQ
)
145 const Multiprotocols::MultiProtocolDefinition
& Multiprotocols::getProtocol(int protocol
) const {
146 for (const Multiprotocols::MultiProtocolDefinition
& proto
: protocols
)
147 if (proto
.protocol
== protocol
)
150 // Protocol not found, return the default (last) proto
151 Q_ASSERT(protocols
.rbegin()->protocol
== 0xfe);
152 return *protocols
.rbegin();
156 QString
Multiprotocols::protocolToString(int protocol
, bool custom
)
158 static const QStringList
strings({
159 "FlySky", "Hubsan", "FrSky", "Hisky", "V2x2", "DSM", "Devo", "YD717", "KN", "SymaX", "SLT", "CX10", "CG023",
160 "Bayang", "ESky", "MT99XX", "MJXQ", "Shenqi", "FY326", "SFHSS", "J6 PRO","FQ777","Assan","Hontai","Open LRS",
161 "FlySky AFHDS2A", "Q2x2", "Walkera", "Q303", "GW008", "DM002", "Cabell", "ESky 150", "H8 3D", "Corona", "CFlie",
162 "Hitec", "Wfly", "Bugs", "Bugs Mini", "Traxxas", "NCC-1701-A", "E01X", "WL Heli V911S", "GD00X", "Volantex V761",
163 "KFPlan KF606", "Redpine", "Potensic", "ZXS", "FlyZone", "Scanner", "FrSky RX", "FlySky AFHDS2A RX"
166 if (protocol
== MM_RF_CUSTOM_SELECTED
|| custom
)
167 return tr("Custom - proto %1)").arg(protocol
);
169 return strings
.value(protocol
, CPN_STR_UNKNOWN_ITEM
);
173 QString
Multiprotocols::subTypeToString(int protocol
, unsigned subType
)
175 if (protocol
> MODULE_SUBTYPE_MULTI_LAST
)
176 return tr(qPrintable(QString::number(subType
)));
178 return tr(qPrintable(multiProtocols
.getProtocol(protocol
).subTypeStrings
.value(subType
, CPN_STR_UNKNOWN_ITEM
)));