[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
@@ -170,6 +170,7 @@ set(companion_SRCS
|
||||
radionotfound.cpp
|
||||
wizarddata.cpp
|
||||
wizarddialog.cpp
|
||||
multiprotocols.cpp
|
||||
)
|
||||
|
||||
set(companion_MOC_HDRS
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "wizarddata.h"
|
||||
#include "firmwareinterface.h"
|
||||
#include "macros.h"
|
||||
#include "multiprotocols.h"
|
||||
#include <stdio.h>
|
||||
#include <list>
|
||||
#include <float.h>
|
||||
@@ -1844,46 +1845,6 @@ SimulatorInterface * getCurrentSimulator()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned int getNumSubtypes(MultiModuleRFProtocols type)
|
||||
{
|
||||
switch (type) {
|
||||
case MM_RF_PROTO_HISKY:
|
||||
case MM_RF_PROTO_SYMAX:
|
||||
case MM_RF_PROTO_KN:
|
||||
case MM_RF_PROTO_SLT:
|
||||
case MM_RF_PROTO_FY326:
|
||||
case MM_RF_PROTO_BAYANG:
|
||||
case MM_RF_PROTO_V2X2:
|
||||
return 2;
|
||||
|
||||
case MM_RF_PROTO_Q2X2:
|
||||
case MM_RF_PROTO_CG023:
|
||||
return 3;
|
||||
|
||||
case MM_RF_PROTO_DSM2:
|
||||
case MM_RF_PROTO_MT99XX:
|
||||
case MM_RF_PROTO_HONTAI:
|
||||
case MM_RF_PROTO_AFHDS2A:
|
||||
case MM_RF_PROTO_Q303:
|
||||
return 4;
|
||||
|
||||
case MM_RF_PROTO_FLYSKY:
|
||||
case MM_RF_PROTO_MJXQ:
|
||||
case MM_RF_PROTO_YD717:
|
||||
return 5;
|
||||
|
||||
case MM_RF_PROTO_FRSKY:
|
||||
case MM_RF_PROTO_WK_2X01:
|
||||
return 6;
|
||||
|
||||
case MM_RF_PROTO_CX10:
|
||||
return 8;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FlightModeData::clear(const int phase)
|
||||
{
|
||||
memset(this, 0, sizeof(FlightModeData));
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "helpers.h"
|
||||
#include "appdata.h"
|
||||
#include "modelprinter.h"
|
||||
#include "multiprotocols.h"
|
||||
|
||||
TimerPanel::TimerPanel(QWidget *parent, ModelData & model, TimerData & timer, GeneralSettings & generalSettings, Firmware * firmware, QWidget * prevFocus):
|
||||
ModelPanel(parent, model, generalSettings, firmware),
|
||||
@@ -157,6 +158,7 @@ void TimerPanel::on_name_editingFinished()
|
||||
#define MASK_OPEN_DRAIN 64
|
||||
#define MASK_MULTIMODULE 128
|
||||
#define MASK_ANTENNA 256
|
||||
#define MASK_MULTIOPTION 512
|
||||
|
||||
quint8 ModulePanel::failsafesValueDisplayType = ModulePanel::FAILSAFE_DISPLAY_PERCENT;
|
||||
|
||||
@@ -381,6 +383,13 @@ void ModulePanel::update()
|
||||
break;
|
||||
case PULSES_MULTIMODULE:
|
||||
mask |= MASK_CHANNELS_RANGE | MASK_RX_NUMBER | MASK_MULTIMODULE;
|
||||
max_rx_num = 15;
|
||||
if (module.multi.rfProtocol == MM_RF_PROTO_DSM2)
|
||||
mask |= MASK_CHANNELS_COUNT;
|
||||
else
|
||||
module.channelsCount = 16;
|
||||
if (multiProtocols.getProtocol(module.multi.rfProtocol).optionsstr != nullptr)
|
||||
mask |= MASK_MULTIOPTION;
|
||||
break;
|
||||
case PULSES_OFF:
|
||||
break;
|
||||
@@ -442,9 +451,11 @@ void ModulePanel::update()
|
||||
ui->multiProtocol->setCurrentIndex(module.multi.rfProtocol);
|
||||
ui->label_multiSubType->setVisible(mask & MASK_MULTIMODULE);
|
||||
ui->multiSubType->setVisible(mask & MASK_MULTIMODULE);
|
||||
ui->label_option->setVisible(mask & MASK_MULTIOPTION);
|
||||
ui->optionValue->setVisible(mask & MASK_MULTIOPTION);
|
||||
|
||||
if (mask & MASK_MULTIMODULE) {
|
||||
int numEntries = getNumSubtypes(static_cast<MultiModuleRFProtocols>(module.multi.rfProtocol));
|
||||
int numEntries = multiProtocols.getProtocol(module.multi.rfProtocol).numSubytes();
|
||||
if (module.multi.customProto)
|
||||
numEntries=8;
|
||||
// Removes extra items
|
||||
@@ -456,6 +467,14 @@ void ModulePanel::update()
|
||||
ui->multiSubType->addItem(ModelPrinter::printMultiSubType(module.multi.rfProtocol, module.multi.customProto, i), (QVariant) i);
|
||||
}
|
||||
}
|
||||
|
||||
if (mask & MASK_MULTIOPTION) {
|
||||
auto pdef = multiProtocols.getProtocol(module.multi.rfProtocol);
|
||||
ui->optionValue->setMinimum(pdef.getOptionMin());
|
||||
ui->optionValue->setMaximum(pdef.getOptionMax());
|
||||
ui->optionValue->setValue(module.multi.optionValue);
|
||||
ui->label_option->setText(pdef.optionsstr);
|
||||
}
|
||||
ui->multiSubType->setCurrentIndex(module.subType);
|
||||
|
||||
ui->autoBind->setVisible(mask & MASK_MULTIMODULE);
|
||||
@@ -592,8 +611,8 @@ void ModulePanel::on_multiProtocol_currentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
lock=true;
|
||||
module.multi.rfProtocol = index;
|
||||
unsigned int maxSubTypes = getNumSubtypes(static_cast<MultiModuleRFProtocols>(index));
|
||||
module.multi.rfProtocol = (unsigned int) index;
|
||||
unsigned int maxSubTypes = multiProtocols.getProtocol(index).numSubytes();
|
||||
if (module.multi.customProto)
|
||||
maxSubTypes=8;
|
||||
module.subType = std::min(module.subType, maxSubTypes -1);
|
||||
@@ -603,6 +622,12 @@ void ModulePanel::on_multiProtocol_currentIndexChanged(int index)
|
||||
}
|
||||
}
|
||||
|
||||
void ModulePanel::on_optionValue_editingFinished()
|
||||
{
|
||||
module.multi.optionValue = ui->optionValue->value();
|
||||
emit modified();
|
||||
}
|
||||
|
||||
void ModulePanel::on_multiSubType_currentIndexChanged(int index)
|
||||
{
|
||||
if (!lock) {
|
||||
|
||||
@@ -91,6 +91,7 @@ class ModulePanel : public ModelPanel
|
||||
void onFailsafePercentChanged(double value);
|
||||
void onFailsafesDisplayValueTypeChanged(int type);
|
||||
void updateFailsafe(int channel);
|
||||
void on_optionValue_editingFinished();
|
||||
|
||||
private:
|
||||
enum FailsafeValueDisplayTypes { FAILSAFE_DISPLAY_PERCENT = 1, FAILSAFE_DISPLAY_USEC = 2 };
|
||||
|
||||
@@ -274,6 +274,20 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="optionValue">
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_option">
|
||||
<property name="text">
|
||||
<string>Option value</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class ModelPrinter: public QObject
|
||||
QString printThrottleTrimMode();
|
||||
static QString printModuleProtocol(unsigned int protocol);
|
||||
static QString printMultiRfProtocol(int rfProtocol, bool custom);
|
||||
static QString printMultiSubType(int rfProtocol, bool custom, int subType);
|
||||
static QString printMultiSubType(int rfProtocol, bool custom, unsigned int subType);
|
||||
QString printFlightModeSwitch(int index);
|
||||
QString printFlightModeName(int index);
|
||||
QString printFlightModes(unsigned int flightModes);
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "multiprotocols.h"
|
||||
#include "radiodata.h"
|
||||
|
||||
#define tr QObject::tr
|
||||
|
||||
static const QStringList STR_SUBTYPE_CUSTOM ({tr("Subtype 0"), tr("Subtype 1"), tr("Subtype 2"), tr("Subtype 3"),
|
||||
tr("Subtype 4"), tr("Subtype 5"), tr("Subtype 6"), tr("Subtype 7")});
|
||||
static const QStringList STR_SUBTYPE_FLYSKY {"Standard", "V9x9", "V6x6", "V912", "CX20"};
|
||||
static const QStringList STR_SUBTYPE_FRSKY {"D16", "D8", "D16 8ch", "V8", "D16 EU-LBT", "D16 EU-LBT 8ch"};
|
||||
static const QStringList STR_SUBTYPE_HISKY {"HiSky", "HK310"};
|
||||
static const QStringList STR_SUBTYPE_V2X2 {"V2x2", "JXD506"};
|
||||
static const QStringList STR_SUBTYPE_DSM {"DSM2 22ms", "DSM2 11ms", "DSMX 22ms", "DSMX 11ms"};
|
||||
static const QStringList STR_SUBTYPE_YD717 {"YD717", "Skywalker", "Syma X2", "XINXUN", "NIHUI"};
|
||||
static const QStringList STR_SUBTYPE_SYMAX {"Standard", "Syma X5C"};
|
||||
static const QStringList STR_SUBTYPE_SLT {"SLT", "Vista"};
|
||||
static const QStringList STR_SUBTYPE_CX10 {"Green", "Blue", "DM007", "-", "JC3015a", "JC3015b", "MK33041", "Q242"};
|
||||
static const QStringList STR_SUBTYPE_CG023 {"CG023", "YD829", "H3 3D"};
|
||||
static const QStringList STR_SUBTYPE_BAYANG {"Bayang", "H8S3D"};
|
||||
static const QStringList STR_SUBTYPE_KN {"WLtoys", "FeiLun"};
|
||||
static const QStringList STR_SUBTYPE_MT99 {"MT99", "H7", "YZ", "LS", "FY805"};
|
||||
static const QStringList STR_SUBTYPE_MJXQ {"WLH08", "X600", "X800", "H26D", "E010", "H26WH"};
|
||||
static const QStringList STR_SUBTYPE_FY326 {"FY326", "FY319"};
|
||||
static const QStringList STR_SUBTYPE_HONTAI {"Standard", "JJRC X1", "X5C1 Clone"};
|
||||
static const QStringList STR_SUBTYPE_AFHDS2A {"PWM and IBUS", "PPM and IBUS", "PWM and SBUS", "PPM and SBUS"};
|
||||
static const QStringList STR_SUBTYPE_Q2X2 {"Q222", "Q242", "Q282"};
|
||||
static const QStringList STR_SUBTYPE_WK2x01 {"WK2801", "WK2401", "W6_5_1", "W6_6_1", "W6_HEL", "W6_HEL_I"};
|
||||
static const QStringList STR_SUBTYPE_Q303 {"Q303", "CX35", "CX10D", "CX10WD"};
|
||||
static const QStringList NO_SUBTYPE {tr("DEFAULT")};
|
||||
|
||||
static const QString STR_MULTI_VIDFREQ = tr("Video TX frequency");
|
||||
static const QString STR_MULTI_RFTUNE = tr("C2500 frequency fine tune");
|
||||
static const QString STR_MULTI_TELEMETRY = tr("Telemetry");
|
||||
static const QString STR_MULTI_RFPOWER = tr("Radio output power");
|
||||
static const QString STR_MULTI_SERVOFREQ = tr("Servo output frequency");
|
||||
static const QString STR_MULTI_OPTION= tr("Option value");
|
||||
|
||||
|
||||
// Table is designed to be shared with gui_common_arm.cpp
|
||||
|
||||
const Multiprotocols multiProtocols {
|
||||
{ MM_RF_PROTO_FLYSKY, STR_SUBTYPE_FLYSKY, 4, nullptr },
|
||||
{ MM_RF_PROTO_HUBSAN, NO_SUBTYPE, 0, STR_MULTI_VIDFREQ },
|
||||
{ MM_RF_PROTO_FRSKY, STR_SUBTYPE_FRSKY, 5, STR_MULTI_RFTUNE },
|
||||
{ MM_RF_PROTO_HISKY, STR_SUBTYPE_HISKY, 1, nullptr },
|
||||
{ MM_RF_PROTO_V2X2, STR_SUBTYPE_V2X2, 1, nullptr },
|
||||
{ MM_RF_PROTO_DSM2, STR_SUBTYPE_DSM, 3, nullptr },
|
||||
{ MM_RF_PROTO_YD717, STR_SUBTYPE_YD717, 4, nullptr },
|
||||
{ MM_RF_PROTO_KN, STR_SUBTYPE_KN, 1, nullptr },
|
||||
{ MM_RF_PROTO_SYMAX, STR_SUBTYPE_SYMAX, 1, nullptr },
|
||||
{ MM_RF_PROTO_SLT, STR_SUBTYPE_SLT, 1, nullptr },
|
||||
{ MM_RF_PROTO_CX10, STR_SUBTYPE_CX10, 7, nullptr },
|
||||
{ MM_RF_PROTO_CG023, STR_SUBTYPE_CG023, 2, nullptr },
|
||||
{ MM_RF_PROTO_BAYANG, STR_SUBTYPE_BAYANG, 1, STR_MULTI_TELEMETRY },
|
||||
{ MM_RF_PROTO_MT99XX, STR_SUBTYPE_MT99, 4, nullptr },
|
||||
{ MM_RF_PROTO_MJXQ, STR_SUBTYPE_MJXQ, 5, nullptr },
|
||||
{ MM_RF_PROTO_FY326, STR_SUBTYPE_FY326, 1, nullptr },
|
||||
{ MM_RF_PROTO_SFHSS, NO_SUBTYPE, 0, STR_MULTI_RFTUNE },
|
||||
{ MM_RF_PROTO_HONTAI, STR_SUBTYPE_HONTAI, 2, nullptr },
|
||||
{ MM_RF_PROTO_OLRS, NO_SUBTYPE, 0, STR_MULTI_RFPOWER },
|
||||
{ MM_RF_PROTO_FS_AFHDS2A, STR_SUBTYPE_AFHDS2A, 3, STR_MULTI_SERVOFREQ },
|
||||
{ MM_RF_PROTO_Q2X2, STR_SUBTYPE_Q2X2, 2, nullptr },
|
||||
{ MM_RF_PROTO_WK_2X01, STR_SUBTYPE_WK2x01, 5, nullptr },
|
||||
{ MM_RF_PROTO_Q303, STR_SUBTYPE_Q303, 3, nullptr },
|
||||
{ MM_RF_PROTO_GW08, NO_SUBTYPE, 0, nullptr },
|
||||
{ MM_RF_CUSTOM_SELECTED, STR_SUBTYPE_CUSTOM, 7, STR_MULTI_OPTION },
|
||||
|
||||
//Sential and default for protocols not listed above (MM_RF_CUSTOM is 0xff()
|
||||
{ 0xfe, NO_SUBTYPE, 0, nullptr }
|
||||
};
|
||||
|
||||
int Multiprotocols::MultiProtocolDefinition::getOptionMin() const {
|
||||
if (optionsstr == STR_MULTI_RFPOWER)
|
||||
return -1;
|
||||
else if (optionsstr == STR_MULTI_SERVOFREQ)
|
||||
return 0;
|
||||
else
|
||||
return -128;
|
||||
}
|
||||
|
||||
int Multiprotocols::MultiProtocolDefinition::getOptionMax() const {
|
||||
if (optionsstr == STR_MULTI_RFPOWER)
|
||||
return 7;
|
||||
else if (optionsstr == STR_MULTI_SERVOFREQ)
|
||||
return 70;
|
||||
else
|
||||
return 127;
|
||||
}
|
||||
|
||||
const Multiprotocols::MultiProtocolDefinition & Multiprotocols::getProtocol(int protocol) const {
|
||||
for (const Multiprotocols::MultiProtocolDefinition & proto: protocols)
|
||||
if (proto.protocol == protocol)
|
||||
return proto;
|
||||
|
||||
// Protocol not found, return the default (last) proto
|
||||
Q_ASSERT(protocols.rbegin()->protocol == 0xfe);
|
||||
return *protocols.rbegin();
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef OPENTX_MULTI_H
|
||||
#define OPENTX_MULTI_H
|
||||
|
||||
#include <vector>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QStringList>
|
||||
|
||||
#define MM_RF_CUSTOM_SELECTED 0xff
|
||||
|
||||
class Multiprotocols {
|
||||
|
||||
struct radio_mm_definition {
|
||||
int protocol;
|
||||
QStringList protocols;
|
||||
unsigned int maxSubtype;
|
||||
QString optionsstr;
|
||||
};
|
||||
|
||||
public:
|
||||
struct MultiProtocolDefinition {
|
||||
int protocol;
|
||||
QStringList subTypeStrings;
|
||||
const QString &optionsstr;
|
||||
|
||||
unsigned int numSubytes() const
|
||||
{ return (unsigned int) subTypeStrings.length(); }
|
||||
|
||||
int getOptionMin() const;
|
||||
|
||||
int getOptionMax() const;
|
||||
|
||||
MultiProtocolDefinition(const radio_mm_definition &rd) : protocol(rd.protocol), subTypeStrings(rd.protocols),
|
||||
optionsstr(rd.optionsstr)
|
||||
{
|
||||
Q_ASSERT(rd.maxSubtype + 1 == (unsigned int) rd.protocols.length());
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
std::vector<MultiProtocolDefinition> protocols;
|
||||
|
||||
public:
|
||||
Multiprotocols(std::initializer_list<radio_mm_definition> l)
|
||||
{
|
||||
for (radio_mm_definition rd: l)
|
||||
protocols.push_back(MultiProtocolDefinition(rd));
|
||||
}
|
||||
|
||||
const MultiProtocolDefinition &getProtocol(int protocol) const;
|
||||
};
|
||||
|
||||
extern const Multiprotocols multiProtocols;
|
||||
|
||||
#endif //OPENTX_MULTI_H
|
||||
@@ -795,15 +795,14 @@ enum MultiModuleRFProtocols {
|
||||
MM_RF_PROTO_ASSAN,
|
||||
MM_RF_PROTO_HONTAI,
|
||||
MM_RF_PROTO_OLRS,
|
||||
MM_RF_PROTO_AFHDS2A,
|
||||
MM_RF_PROTO_FS_AFHDS2A,
|
||||
MM_RF_PROTO_Q2X2,
|
||||
MM_RF_PROTO_WK_2X01,
|
||||
MM_RF_PROTO_Q303,
|
||||
MM_RF_PROTO_LAST=MM_RF_PROTO_Q303
|
||||
MM_RF_PROTO_GW08,
|
||||
MM_RF_PROTO_LAST=MM_RF_PROTO_GW08
|
||||
};
|
||||
|
||||
unsigned int getNumSubtypes(MultiModuleRFProtocols type);
|
||||
|
||||
enum TrainerProtocol {
|
||||
TRAINER_MASTER_JACK,
|
||||
TRAINER_SLAVE_JACK,
|
||||
|
||||
@@ -227,7 +227,7 @@
|
||||
|
||||
#ifdef MOUNTED_GETMNTINFO
|
||||
|
||||
# if ! HAVE_STRUCT_STATFS_F_FSTYPENAME && !defined(__clang__)
|
||||
# if ! HAVE_STRUCT_STATFS_F_FSTYPENAME && defined(MOUNTED_VMOUNT)
|
||||
static const char *
|
||||
fstype_to_string (short int t)
|
||||
{
|
||||
@@ -323,7 +323,8 @@ fstype_to_string (short int t)
|
||||
}
|
||||
# endif
|
||||
|
||||
#if !defined(__clang__)
|
||||
// Not used
|
||||
#if 0
|
||||
static const char *
|
||||
fsp_to_string (const struct statfs *fsp)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user