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_DEFAULT QT_TRANSLATE_NOOP("Multiprotocols", "DEFAULT")
35 static const QStringList
STR_SUBTYPE_CUSTOM ({
36 STR_MULTI_SUBTYPE
" 0", STR_MULTI_SUBTYPE
" 1", STR_MULTI_SUBTYPE
" 2", STR_MULTI_SUBTYPE
" 3",
37 STR_MULTI_SUBTYPE
" 4", STR_MULTI_SUBTYPE
" 5", STR_MULTI_SUBTYPE
" 6", STR_MULTI_SUBTYPE
" 7"
39 static const QStringList STR_SUBTYPE_FLYSKY
{"Standard", "V9x9", "V6x6", "V912", "CX20"};
40 static const QStringList STR_SUBTYPE_FRSKY
{"D16", "D8", "D16 8ch", "V8", "D16 EU-LBT", "D16 EU-LBT 8ch"};
41 static const QStringList STR_SUBTYPE_HISKY
{"HiSky", "HK310"};
42 static const QStringList STR_SUBTYPE_V2X2
{"V2x2", "JXD506"};
43 static const QStringList STR_SUBTYPE_DSM
{"DSM2 22ms", "DSM2 11ms", "DSMX 22ms", "DSMX 11ms"};
44 static const QStringList STR_SUBTYPE_YD717
{"YD717", "Skywalker", "Syma X2", "XINXUN", "NIHUI"};
45 static const QStringList STR_SUBTYPE_SYMAX
{"Standard", "Syma X5C"};
46 static const QStringList STR_SUBTYPE_SLT
{"SLT", "Vista"};
47 static const QStringList STR_SUBTYPE_CX10
{"Green", "Blue", "DM007", "-", "JC3015a", "JC3015b", "MK33041", "Q242"};
48 static const QStringList STR_SUBTYPE_CG023
{"CG023", "YD829", "H8 3D"};
49 static const QStringList STR_SUBTYPE_BAYANG
{"Bayang", "H8S3D", "X16 AH"};
50 static const QStringList STR_SUBTYPE_KN
{"WLtoys", "FeiLun"};
51 static const QStringList STR_SUBTYPE_MT99
{"MT99", "H7", "YZ", "LS", "FY805"};
52 static const QStringList STR_SUBTYPE_MJXQ
{"WLH08", "X600", "X800", "H26D", "E010", "H26WH"};
53 static const QStringList STR_SUBTYPE_FY326
{"FY326", "FY319"};
54 static const QStringList STR_SUBTYPE_HONTAI
{"Standard", "JJRC X1", "X5C1 Clone"};
55 static const QStringList STR_SUBTYPE_AFHDS2A
{"PWM and IBUS", "PPM and IBUS", "PWM and SBUS", "PPM and SBUS"};
56 static const QStringList STR_SUBTYPE_Q2X2
{"Q222", "Q242", "Q282"};
57 static const QStringList STR_SUBTYPE_WK2x01
{"WK2801", "WK2401", "W6_5_1", "W6_6_1", "W6_HEL", "W6_HEL_I"};
58 static const QStringList STR_SUBTYPE_Q303
{"Q303", "CX35", "CX10D", "CX10WD"};
59 static const QStringList NO_SUBTYPE
{STR_MULTI_DEFAULT
};
62 // Table is designed to be shared with gui_common_arm.cpp
64 const Multiprotocols multiProtocols
{
65 {MM_RF_PROTO_FLYSKY
, 4, false, STR_SUBTYPE_FLYSKY
, nullptr},
66 {MM_RF_PROTO_HUBSAN
, 0, false, NO_SUBTYPE
, STR_MULTI_VIDFREQ
},
67 {MM_RF_PROTO_FRSKY
, 5, false, STR_SUBTYPE_FRSKY
, STR_MULTI_RFTUNE
},
68 {MM_RF_PROTO_HISKY
, 1, false, STR_SUBTYPE_HISKY
, nullptr},
69 {MM_RF_PROTO_V2X2
, 1, false, STR_SUBTYPE_V2X2
, nullptr},
70 {MM_RF_PROTO_DSM2
, 3, false, STR_SUBTYPE_DSM
, nullptr},
71 {MM_RF_PROTO_YD717
, 4, false, STR_SUBTYPE_YD717
, nullptr},
72 {MM_RF_PROTO_KN
, 1, false, STR_SUBTYPE_KN
, nullptr},
73 {MM_RF_PROTO_SYMAX
, 1, false, STR_SUBTYPE_SYMAX
, nullptr},
74 {MM_RF_PROTO_SLT
, 1, false, STR_SUBTYPE_SLT
, nullptr},
75 {MM_RF_PROTO_CX10
, 7, false, STR_SUBTYPE_CX10
, nullptr},
76 {MM_RF_PROTO_CG023
, 2, false, STR_SUBTYPE_CG023
, nullptr},
77 {MM_RF_PROTO_BAYANG
, 2, false, STR_SUBTYPE_BAYANG
, STR_MULTI_TELEMETRY
},
78 {MM_RF_PROTO_MT99XX
, 4, false, STR_SUBTYPE_MT99
, nullptr},
79 {MM_RF_PROTO_MJXQ
, 5, false, STR_SUBTYPE_MJXQ
, nullptr},
80 {MM_RF_PROTO_FY326
, 1, false, STR_SUBTYPE_FY326
, nullptr},
81 {MM_RF_PROTO_SFHSS
, 0, false, NO_SUBTYPE
, STR_MULTI_RFTUNE
},
82 {MM_RF_PROTO_HONTAI
, 2, false, STR_SUBTYPE_HONTAI
, nullptr},
83 {MM_RF_PROTO_OLRS
, 0, false, NO_SUBTYPE
, STR_MULTI_RFPOWER
},
84 {MM_RF_PROTO_FS_AFHDS2A
, 3, true, STR_SUBTYPE_AFHDS2A
, STR_MULTI_SERVOFREQ
},
85 {MM_RF_PROTO_Q2X2
, 2, false, STR_SUBTYPE_Q2X2
, nullptr},
86 {MM_RF_PROTO_WK_2X01
, 5, false, STR_SUBTYPE_WK2x01
, nullptr},
87 {MM_RF_PROTO_Q303
, 3, false, STR_SUBTYPE_Q303
, nullptr},
88 {MM_RF_CUSTOM_SELECTED
, 7, true, STR_SUBTYPE_CUSTOM
, STR_MULTI_OPTION
},
90 // Sentinel and default for protocols not listed above (MM_RF_CUSTOM is 0xff)
91 { 0xfe, 0, false, NO_SUBTYPE
, nullptr}
94 int Multiprotocols::MultiProtocolDefinition::getOptionMin() const {
95 if (optionsstr
== STR_MULTI_RFPOWER
)
97 else if (optionsstr
== STR_MULTI_SERVOFREQ
)
103 int Multiprotocols::MultiProtocolDefinition::getOptionMax() const {
104 if (optionsstr
== STR_MULTI_RFPOWER
)
106 else if (optionsstr
== STR_MULTI_SERVOFREQ
)
112 const Multiprotocols::MultiProtocolDefinition
& Multiprotocols::getProtocol(int protocol
) const {
113 for (const Multiprotocols::MultiProtocolDefinition
& proto
: protocols
)
114 if (proto
.protocol
== protocol
)
117 // Protocol not found, return the default (last) proto
118 Q_ASSERT(protocols
.rbegin()->protocol
== 0xfe);
119 return *protocols
.rbegin();