Bsongis/companion r9m fixes (#5914)

* Cosmetics

* First part ...

* First part ...

* Second part ...

* End?

* Handle new  R9M and R9M lite

* Display 'mini' module in case of R9M and xlite
This commit is contained in:
Bertrand Songis
2018-06-02 18:16:51 +02:00
committed by GitHub
parent 0e1a6bd60b
commit 806715e166
9 changed files with 536 additions and 67 deletions
+1
View File
@@ -9,6 +9,7 @@ set(firmwares_SRCS
io_data.cpp io_data.cpp
logicalswitchdata.cpp logicalswitchdata.cpp
modeldata.cpp modeldata.cpp
moduledata.cpp
multiprotocols.cpp multiprotocols.cpp
radiodata.cpp radiodata.cpp
radiodataconversionstate.cpp radiodataconversionstate.cpp
+4
View File
@@ -454,4 +454,8 @@ void ModelData::convert(RadioDataConversionState & cstate)
for (int i=0; i<CPN_MAX_FLIGHT_MODES; i++) { for (int i=0; i<CPN_MAX_FLIGHT_MODES; i++) {
flightModeData[i].convert(cstate.withComponentIndex(i)); flightModeData[i].convert(cstate.withComponentIndex(i));
} }
for (int i=0; i<CPN_MAX_MODULES; i++) {
moduleData[i].convert(cstate.withComponentIndex(i));
}
} }
+29
View File
@@ -0,0 +1,29 @@
/*
* 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 "moduledata.h"
#include "radiodataconversionstate.h"
void ModuleData::convert(RadioDataConversionState & cstate)
{
if (protocol == PULSES_PXX_R9M && (IS_TARANIS_XLITE(cstate.fromType) || IS_TARANIS_XLITE(cstate.toType))) {
clear();
}
}
+8
View File
@@ -25,6 +25,8 @@
#include <QtCore> #include <QtCore>
class RadioDataConversionState;
enum PulsesProtocol { enum PulsesProtocol {
PULSES_OFF, PULSES_OFF,
PULSES_PPM, PULSES_PPM,
@@ -97,6 +99,11 @@ enum TrainerProtocol {
TRAINER_MASTER_SBUS_BATT_COMPARTMENT TRAINER_MASTER_SBUS_BATT_COMPARTMENT
}; };
enum R9MSubTypes {
R9M_FCC,
R9M_LBT
};
class ModuleData { class ModuleData {
Q_DECLARE_TR_FUNCTIONS(ModuleData) Q_DECLARE_TR_FUNCTIONS(ModuleData)
@@ -138,6 +145,7 @@ class ModuleData {
void clear() { memset(this, 0, sizeof(ModuleData)); } void clear() { memset(this, 0, sizeof(ModuleData)); }
QString polarityToString() const { return ppm.pulsePol ? tr("Positive") : tr("Negative"); } // TODO ModelPrinter QString polarityToString() const { return ppm.pulsePol ? tr("Positive") : tr("Negative"); } // TODO ModelPrinter
void convert(RadioDataConversionState & cstate);
}; };
#endif // MODULEDATA_H #endif // MODULEDATA_H
+35 -5
View File
@@ -23,7 +23,6 @@
#include "ui_setup_timer.h" #include "ui_setup_timer.h"
#include "ui_setup_module.h" #include "ui_setup_module.h"
#include "switchitemmodel.h" #include "switchitemmodel.h"
#include "helpers.h"
#include "appdata.h" #include "appdata.h"
#include "modelprinter.h" #include "modelprinter.h"
#include "multiprotocols.h" #include "multiprotocols.h"
@@ -229,6 +228,9 @@ ModulePanel::ModulePanel(QWidget * parent, ModelData & model, ModuleData & modul
// The protocols available on this board // The protocols available on this board
for (int i=0; i<PULSES_PROTOCOL_LAST; i++) { for (int i=0; i<PULSES_PROTOCOL_LAST; i++) {
if (firmware->isAvailable((PulsesProtocol) i, moduleIdx)) { if (firmware->isAvailable((PulsesProtocol) i, moduleIdx)) {
if (IS_TARANIS_XLITE(firmware->getBoard()) && i == PULSES_PXX_R9M) //TODO remove when mini are handled as a different module type
ui->protocol->addItem("FrSky R9M Mini", (QVariant) i);
else
ui->protocol->addItem(ModelPrinter::printModuleProtocol(i), (QVariant) i); ui->protocol->addItem(ModelPrinter::printModuleProtocol(i), (QVariant) i);
if (i == module.protocol) if (i == module.protocol)
ui->protocol->setCurrentIndex(ui->protocol->count()-1); ui->protocol->setCurrentIndex(ui->protocol->count()-1);
@@ -476,9 +478,37 @@ void ModulePanel::update()
ui->antennaMode->setCurrentIndex(module.pxx.external_antenna); ui->antennaMode->setCurrentIndex(module.pxx.external_antenna);
// R9M options // R9M options
ui->r9mPower->setVisible((mask & MASK_R9M) && module.subType == 0); ui->r9mPower->setVisible(mask & MASK_R9M);
ui->label_r9mPower->setVisible((mask & MASK_R9M) && module.subType == 0); ui->label_r9mPower->setVisible(mask & MASK_R9M);
ui->warning_r9mPower->setVisible((mask & MASK_R9M) && module.subType == R9M_LBT);
if (mask & MASK_R9M) { if (mask & MASK_R9M) {
ui->r9mPower->clear();
Board::Type board = firmware->getBoard();
if (IS_TARANIS_XLITE(board)) {
if (module.subType == R9M_FCC) {
ui->r9mPower->addItem(tr("100 mW - 16CH"));
}
else {
ui->r9mPower->addItem(tr("25 mW - 8CH"));
ui->r9mPower->addItem(tr("25 mW - 16CH"));
ui->r9mPower->addItem(tr("100 mW - 16CH, no telemetry"));
}
}
else {
if (module.subType == R9M_FCC) {
ui->r9mPower->addItem(tr("10 mW - 16CH"));
ui->r9mPower->addItem(tr("100 mW - 16CH"));
ui->r9mPower->addItem(tr("500 mW - 16CH"));
ui->r9mPower->addItem(tr("1000 mW - 16CH"));
}
else {
ui->r9mPower->addItem(tr("25 mW - 8CH"));
ui->r9mPower->addItem(tr("25 mW - 16CH"));
ui->r9mPower->addItem(tr("200 mW - 16CH"));
ui->r9mPower->addItem(tr("500 mW - 16CH"));
}
}
ui->r9mPower->setCurrentIndex(module.pxx.power); ui->r9mPower->setCurrentIndex(module.pxx.power);
} }
@@ -508,8 +538,8 @@ void ModulePanel::update()
if (mask & MASK_MULTIMODULE) { if (mask & MASK_MULTIMODULE) {
ui->multiProtocol->setCurrentIndex(module.multi.rfProtocol); ui->multiProtocol->setCurrentIndex(module.multi.rfProtocol);
ui->autoBind->setChecked(module.multi.autoBindMode ? Qt::Checked : Qt::Unchecked); ui->autoBind->setChecked(module.multi.autoBindMode);
ui->lowPower->setChecked(module.multi.lowPowerMode ? Qt::Checked : Qt::Unchecked); ui->lowPower->setChecked(module.multi.lowPowerMode);
} }
if (mask & MASK_MULTIOPTION) { if (mask & MASK_MULTIOPTION) {
+439 -51
View File
@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>708</width> <width>1042</width>
<height>259</height> <height>315</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -237,30 +237,9 @@
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="3" column="1">
<widget class="QComboBox" name="r9mPower"> <widget class="QComboBox" name="r9mPower"/>
<item>
<property name="text">
<string>10 mW</string>
</property>
</item> </item>
<item> <item row="5" column="0" colspan="2">
<property name="text">
<string>100 mW</string>
</property>
</item>
<item>
<property name="text">
<string>500 mW</string>
</property>
</item>
<item>
<property name="text">
<string>1000 mW</string>
</property>
</item>
</widget>
</item>
<item row="4" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QCheckBox" name="autoBind"> <widget class="QCheckBox" name="autoBind">
@@ -278,6 +257,428 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="4" column="1">
<widget class="QLabel" name="warning_r9mPower">
<property name="palette">
<palette>
<active>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>127</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>63</green>
<blue>63</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>127</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>127</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>127</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>63</green>
<blue>63</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>127</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>127</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="WindowText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>127</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Button">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Light">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>127</green>
<blue>127</blue>
</color>
</brush>
</colorrole>
<colorrole role="Midlight">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>63</green>
<blue>63</blue>
</color>
</brush>
</colorrole>
<colorrole role="Dark">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>127</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Mid">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>170</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Text">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>127</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="BrightText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="ButtonText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>127</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="Shadow">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="AlternateBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipBase">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>220</blue>
</color>
</brush>
</colorrole>
<colorrole role="ToolTipText">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="text">
<string>WARNING: changing RF Output Power needs RE-BIND</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
@@ -707,6 +1108,19 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="0" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" colspan="3"> <item row="1" column="0" colspan="3">
<widget class="QGroupBox" name="failsafesGroupBox"> <widget class="QGroupBox" name="failsafesGroupBox">
<property name="styleSheet"> <property name="styleSheet">
@@ -796,32 +1210,6 @@ QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top left; pad
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="2" column="0" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="3" rowspan="3">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
+15 -6
View File
@@ -207,7 +207,7 @@ QString ModelPrinter::printMultiRfProtocol(int rfProtocol, bool custom)
"FlySky AFHDS2A", "Q2x2", "Walkera", "Q303", "GW008", "DM002", "CABELL", "Esky 150", "H8 3D", "Corona", "CFlie" "FlySky AFHDS2A", "Q2x2", "Walkera", "Q303", "GW008", "DM002", "CABELL", "Esky 150", "H8 3D", "Corona", "CFlie"
}; };
if (custom) if (custom)
return "Custom - proto " + QString::number(rfProtocol); return QObject::tr("Custom - proto %1)").arg(QString::number(rfProtocol));
else else
return CHECK_IN_ARRAY(strings, rfProtocol); return CHECK_IN_ARRAY(strings, rfProtocol);
} }
@@ -228,13 +228,22 @@ QString ModelPrinter::printMultiSubType(unsigned rfProtocol, bool custom, unsign
QString ModelPrinter::printR9MPowerValue(unsigned subType, unsigned val, bool telem) QString ModelPrinter::printR9MPowerValue(unsigned subType, unsigned val, bool telem)
{ {
static const QStringList strFTC = QStringList() << tr("10mW") << tr("100mW") << tr("500mW") << tr("1W"); QStringList strFCC;
static const QStringList strLBT = QStringList() << tr("25mW") << tr("500mW"); QStringList strLBT;
if (IS_TARANIS_XLITE(firmware->getBoard())) {
strFCC = QStringList() << tr("100mW - 16CH");
strLBT = QStringList() << tr("25mW - 8CH") << tr("25mW - 16CH") << tr("100mW 16CH");
}
else {
strFCC = QStringList() << tr("10mW") << tr("100mW") << tr("500mW") << tr("1W");
strLBT = QStringList() << tr("25mW - 8CH") << tr("25mW - 16CH") << tr("200mW 16CH") << tr("500mW 16CH");
}
if (subType == 0 && (int)val < strFTC.size()) if (subType == R9M_FCC && (int)val < strFCC.size())
return strFTC.at(val); return strFCC.at(val);
else if (subType == 1) else if (subType == R9M_LBT)
return (telem ? strLBT.at(0) : strLBT.at(1)); return (telem ? strLBT.at(0) : strLBT.at(1));
else else
return "???"; return "???";
+1 -1
View File
@@ -59,7 +59,7 @@ class ModelPrinter: public QObject
QString printThrottle(); QString printThrottle();
static QString printModuleProtocol(unsigned int protocol); static QString printModuleProtocol(unsigned int protocol);
static QString printMultiRfProtocol(int rfProtocol, bool custom); static QString printMultiRfProtocol(int rfProtocol, bool custom);
static QString printR9MPowerValue(unsigned subType, unsigned val, bool telem); QString printR9MPowerValue(unsigned subType, unsigned val, bool telem);
static QString printMultiSubType(unsigned rfProtocol, bool custom, unsigned int subType); static QString printMultiSubType(unsigned rfProtocol, bool custom, unsigned int subType);
static QString printModuleSubType(unsigned protocol, unsigned subType, unsigned rfProtocol = 0, bool custom = false); static QString printModuleSubType(unsigned protocol, unsigned subType, unsigned rfProtocol = 0, bool custom = false);
QString printFlightModeSwitch(const RawSwitch & swtch); QString printFlightModeSwitch(const RawSwitch & swtch);