[MULTI] Implement option Value adjustment in Companion (#4459)
* [MULTI] Implement option Value adjustment in Companion Also refactor ui code to use the same multi table as the radio to make updates easier and consistent * Fix warnings with gcc 6 * Make the whole thing more C++ like Using QVector instead of std::vector gives me strange errors. * Fix gcc warning * another signedness fix * Add missing include * Add Gw008 protocol and move subtype definitions out of the translations * Add note about struct * More cleanups Integrate @mpaperno’s latest ideas about cleaning up
This commit is contained in:
committed by
Bertrand Songis
parent
00b2799427
commit
40dae8a8a7
@@ -22,6 +22,7 @@
|
||||
#include "modelprinter.h"
|
||||
#include <QPainter>
|
||||
#include <QFile>
|
||||
#include "multiprotocols.h"
|
||||
|
||||
QString changeColor(const QString & input, const QString & to, const QString & from)
|
||||
{
|
||||
@@ -62,7 +63,7 @@ QString addFont(const QString & input, const QString & color, const QString & si
|
||||
if (!face.isEmpty()) {
|
||||
faceStr = "face='" + face + "'";
|
||||
}
|
||||
return "<font " + sizeStr + " " + faceStr + " " + colorStr + ">" + input + "</font>";
|
||||
return "<font " + sizeStr + " " + faceStr + " " + colorStr + ">" + input + "</font>";
|
||||
}
|
||||
|
||||
QString ModelPrinter::printEEpromSize()
|
||||
@@ -131,7 +132,7 @@ QString ModelPrinter::printMultiRfProtocol(int rfProtocol, bool custom)
|
||||
static const char *strings[] = {
|
||||
"FlySky", "Hubsan", "FrSky", "Hisky", "V2x2", "DSM", "Devo", "YD717", "KN", "SymaX", "SLT", "CX10", "CG023",
|
||||
"Bayang", "ESky", "MT99XX", "MJXQ", "Shenqi", "FY326", "SFHSS", "J6 PRO","FQ777","Assan","Hontai","OLRS",
|
||||
"FlySky AFHDS2A", "Q2x2", "Q303"
|
||||
"FlySky AFHDS2A", "Q2x2", "Walkera", "Q303", "GW008"
|
||||
};
|
||||
if (custom)
|
||||
return "Custom - proto " + QString::number(rfProtocol);
|
||||
@@ -139,77 +140,18 @@ QString ModelPrinter::printMultiRfProtocol(int rfProtocol, bool custom)
|
||||
return CHECK_IN_ARRAY(strings, rfProtocol);
|
||||
}
|
||||
|
||||
QString ModelPrinter::printMultiSubType(int rfProtocol, bool custom, int subType) {
|
||||
QString ModelPrinter::printMultiSubType(int rfProtocol, bool custom, unsigned int subType) {
|
||||
/* custom protocols */
|
||||
static const char *custom_subtype_strings[] = {"Subtype 0", "Subtype 1", "Subtype 2", "Subtype 3", "Subtype 4", "Subtype 5", "Subtype 6", "Subtype 7"};
|
||||
static const char *flysky_strings[] = {"Standard", "V9x9", "V6x6", "V912", "CX20"};
|
||||
static const char *frsky_strings[] = {"D16", "D8", "D16 8ch", "V8", "D16 EU-LBT", "D16 EU-LBT 8ch"};
|
||||
static const char *hisky_strings[] = {"HiSky", "HK310"};
|
||||
static const char *v2x2_strings[] = {"V2x2", "JXD506"};
|
||||
static const char *dsm2_strings[] = {"DSM2 22ms", "DSM2 11ms", "DSMX 22ms", "DSMX 11ms"};
|
||||
static const char *yd717_strings[] = {"YD717", "Skywalker", "Syma X2", "XINXUN", "NIHUI"};
|
||||
static const char *symax_strings[] = {"Standard", "Syma X5C"};
|
||||
static const char *slt_strings[] = {"SLT", "Vista"};
|
||||
static const char *cx10_strings[] = {"Green", "Blue", "DM007", "-", "JC3015a", "JC3015b", "MK33041", "Q242"};
|
||||
static const char *cg023_strings[] = {"CG023", "YD829", "H3 3D"};
|
||||
static const char *bayang_strings[] = {"Bayang", "H8S3D"};
|
||||
static const char *kn_strings[] = {"WLtoys", "FeiLun"};
|
||||
static const char *mt99_strings[] = {"MT99", "H7", "YZ"};
|
||||
static const char *mjxq_strings[] = {"WLH08", "X600", "X800", "H26D", "E010"};
|
||||
static const char *fy326_strings[] = {"FY326", "FY319"};
|
||||
static const char *hontai_strings[] = {"Standard", "JJRC X1", "X5C1 Clone"};
|
||||
static const char *afhds2a_strings[] = {"PWM and IBUS", "PPM and IBUS", "PWM and SBUS", "PPM and SBUS"};
|
||||
static const char *q2x2_strings[] = {"Q222", "Q242", "Q282"};
|
||||
static const char *walkera_wk2x01_strings[] = {"WK2801", "WK2401", "W6_5_1", "W6_6_1", "W6_HEL", "W6_HEL_I"};
|
||||
static const char *q303_strings[] = { "Q303", "CX35", "CX10D", "CX10WD"};
|
||||
|
||||
if (custom)
|
||||
return CHECK_IN_ARRAY(custom_subtype_strings, subType);
|
||||
|
||||
switch (rfProtocol) {
|
||||
case MM_RF_PROTO_FLYSKY:
|
||||
return CHECK_IN_ARRAY(flysky_strings, subType);
|
||||
case MM_RF_PROTO_FRSKY:
|
||||
return CHECK_IN_ARRAY(frsky_strings, subType);
|
||||
case MM_RF_PROTO_HISKY:
|
||||
return CHECK_IN_ARRAY(hisky_strings, subType);
|
||||
case MM_RF_PROTO_DSM2:
|
||||
return CHECK_IN_ARRAY(dsm2_strings, subType);
|
||||
case MM_RF_PROTO_V2X2:
|
||||
return CHECK_IN_ARRAY(v2x2_strings, subType);
|
||||
case MM_RF_PROTO_YD717:
|
||||
return CHECK_IN_ARRAY(yd717_strings, subType);
|
||||
case MM_RF_PROTO_SYMAX:
|
||||
return CHECK_IN_ARRAY(symax_strings, subType);
|
||||
case MM_RF_PROTO_SLT:
|
||||
return CHECK_IN_ARRAY(slt_strings, subType);
|
||||
case MM_RF_PROTO_CX10:
|
||||
return CHECK_IN_ARRAY(cx10_strings, subType);
|
||||
case MM_RF_PROTO_CG023:
|
||||
return CHECK_IN_ARRAY(cg023_strings, subType);
|
||||
case MM_RF_PROTO_BAYANG:
|
||||
return CHECK_IN_ARRAY(bayang_strings, subType);
|
||||
case MM_RF_PROTO_KN:
|
||||
return CHECK_IN_ARRAY(kn_strings, subType);
|
||||
case MM_RF_PROTO_MT99XX:
|
||||
return CHECK_IN_ARRAY(mt99_strings, subType);
|
||||
case MM_RF_PROTO_MJXQ:
|
||||
return CHECK_IN_ARRAY(mjxq_strings, subType);
|
||||
case MM_RF_PROTO_FY326:
|
||||
return CHECK_IN_ARRAY(fy326_strings, subType);
|
||||
case MM_RF_PROTO_HONTAI:
|
||||
return CHECK_IN_ARRAY(hontai_strings, subType);
|
||||
case MM_RF_PROTO_AFHDS2A:
|
||||
return CHECK_IN_ARRAY(afhds2a_strings, subType);
|
||||
case MM_RF_PROTO_Q2X2:
|
||||
return CHECK_IN_ARRAY(q2x2_strings, subType);
|
||||
case MM_RF_PROTO_WK_2X01:
|
||||
return CHECK_IN_ARRAY(walkera_wk2x01_strings, subType);
|
||||
case MM_RF_PROTO_Q303:
|
||||
return CHECK_IN_ARRAY(q303_strings, subType);
|
||||
default:
|
||||
return "DEFAULT";
|
||||
}
|
||||
if (custom)
|
||||
rfProtocol = MM_RF_CUSTOM_SELECTED;
|
||||
|
||||
Multiprotocols::MultiProtocolDefinition pdef = multiProtocols.getProtocol(rfProtocol);
|
||||
|
||||
if (subType < (unsigned int) pdef.subTypeStrings.size())
|
||||
return pdef.subTypeStrings[subType];
|
||||
else
|
||||
return "???";
|
||||
}
|
||||
|
||||
QString ModelPrinter::printModule(int idx) {
|
||||
@@ -316,7 +258,7 @@ QString ModelPrinter::printTimer(int idx)
|
||||
QString ModelPrinter::printTimer(const TimerData & timer)
|
||||
{
|
||||
QStringList result;
|
||||
if (firmware->getCapability(TimersName) && timer.name[0])
|
||||
if (firmware->getCapability(TimersName) && timer.name[0])
|
||||
result += tr("Name(%1)").arg(timer.name);
|
||||
result += QString("%1:%2").arg(timer.val/60, 2, 10, QChar('0')).arg(timer.val%60, 2, 10, QChar('0'));
|
||||
result += timer.mode.toString();
|
||||
@@ -337,9 +279,9 @@ QString ModelPrinter::printTrim(int flightModeIndex, int stickIndex)
|
||||
{
|
||||
const FlightModeData & fm = model.flightModeData[flightModeIndex];
|
||||
|
||||
if (fm.trimMode[stickIndex] == -1) {
|
||||
if (fm.trimMode[stickIndex] == -1) {
|
||||
return tr("Off");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (fm.trimRef[stickIndex] == flightModeIndex) {
|
||||
return QString("%1").arg(fm.trim[stickIndex]);
|
||||
@@ -349,7 +291,7 @@ QString ModelPrinter::printTrim(int flightModeIndex, int stickIndex)
|
||||
return tr("FM%1").arg(fm.trimRef[stickIndex]);
|
||||
}
|
||||
else {
|
||||
if (fm.trim[stickIndex] < 0)
|
||||
if (fm.trim[stickIndex] < 0)
|
||||
return tr("FM%1%2").arg(fm.trimRef[stickIndex]).arg(fm.trim[stickIndex]);
|
||||
else
|
||||
return tr("FM%1+%2").arg(fm.trimRef[stickIndex]).arg(fm.trim[stickIndex]);
|
||||
@@ -441,7 +383,7 @@ QString ModelPrinter::printInputLine(const ExpoData & input)
|
||||
if (input.offset)
|
||||
str += " " + tr("Offset(%1)").arg(getGVarString(input.offset)).toHtmlEscaped();
|
||||
|
||||
if (firmware->getCapability(HasExpoNames) && input.name[0])
|
||||
if (firmware->getCapability(HasExpoNames) && input.name[0])
|
||||
str += QString(" [%1]").arg(input.name).toHtmlEscaped();
|
||||
|
||||
return str;
|
||||
@@ -516,7 +458,7 @@ QString ModelPrinter::printMixerLine(const MixData & mix, bool showMultiplex, in
|
||||
str += " " + tr("Slow(u%1:d%2)").arg((double)mix.speedUp/scale).arg((double)mix.speedDown/scale).toHtmlEscaped();
|
||||
if (mix.mixWarn)
|
||||
str += " " + tr("Warn(%1)").arg(mix.mixWarn).toHtmlEscaped();
|
||||
if (firmware->getCapability(HasMixerNames) && mix.name[0])
|
||||
if (firmware->getCapability(HasMixerNames) && mix.name[0])
|
||||
str += QString(" [%1]").arg(mix.name).toHtmlEscaped();
|
||||
return str;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user