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
logicalswitchdata.cpp
modeldata.cpp
moduledata.cpp
multiprotocols.cpp
radiodata.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++) {
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>
class RadioDataConversionState;
enum PulsesProtocol {
PULSES_OFF,
PULSES_PPM,
@@ -97,6 +99,11 @@ enum TrainerProtocol {
TRAINER_MASTER_SBUS_BATT_COMPARTMENT
};
enum R9MSubTypes {
R9M_FCC,
R9M_LBT
};
class ModuleData {
Q_DECLARE_TR_FUNCTIONS(ModuleData)
@@ -138,6 +145,7 @@ class ModuleData {
void clear() { memset(this, 0, sizeof(ModuleData)); }
QString polarityToString() const { return ppm.pulsePol ? tr("Positive") : tr("Negative"); } // TODO ModelPrinter
void convert(RadioDataConversionState & cstate);
};
#endif // MODULEDATA_H
+37 -7
View File
@@ -23,7 +23,6 @@
#include "ui_setup_timer.h"
#include "ui_setup_module.h"
#include "switchitemmodel.h"
#include "helpers.h"
#include "appdata.h"
#include "modelprinter.h"
#include "multiprotocols.h"
@@ -228,8 +227,11 @@ ModulePanel::ModulePanel(QWidget * parent, ModelData & model, ModuleData & modul
// The protocols available on this board
for (int i=0; i<PULSES_PROTOCOL_LAST; i++) {
if (firmware->isAvailable((PulsesProtocol)i, moduleIdx)) {
ui->protocol->addItem(ModelPrinter::printModuleProtocol(i), (QVariant)i);
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);
if (i == module.protocol)
ui->protocol->setCurrentIndex(ui->protocol->count()-1);
}
@@ -476,9 +478,37 @@ void ModulePanel::update()
ui->antennaMode->setCurrentIndex(module.pxx.external_antenna);
// R9M options
ui->r9mPower->setVisible((mask & MASK_R9M) && module.subType == 0);
ui->label_r9mPower->setVisible((mask & MASK_R9M) && module.subType == 0);
ui->r9mPower->setVisible(mask & MASK_R9M);
ui->label_r9mPower->setVisible(mask & MASK_R9M);
ui->warning_r9mPower->setVisible((mask & MASK_R9M) && module.subType == R9M_LBT);
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);
}
@@ -508,8 +538,8 @@ void ModulePanel::update()
if (mask & MASK_MULTIMODULE) {
ui->multiProtocol->setCurrentIndex(module.multi.rfProtocol);
ui->autoBind->setChecked(module.multi.autoBindMode ? Qt::Checked : Qt::Unchecked);
ui->lowPower->setChecked(module.multi.lowPowerMode ? Qt::Checked : Qt::Unchecked);
ui->autoBind->setChecked(module.multi.autoBindMode);
ui->lowPower->setChecked(module.multi.lowPowerMode);
}
if (mask & MASK_MULTIOPTION) {
+439 -51
View File
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>708</width>
<height>259</height>
<width>1042</width>
<height>315</height>
</rect>
</property>
<property name="windowTitle">
@@ -237,30 +237,9 @@
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="r9mPower">
<item>
<property name="text">
<string>10 mW</string>
</property>
</item>
<item>
<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>
<widget class="QComboBox" name="r9mPower"/>
</item>
<item row="4" column="0" colspan="2">
<item row="5" column="0" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="autoBind">
@@ -278,6 +257,428 @@
</item>
</layout>
</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>
</item>
<item row="0" column="2">
@@ -707,6 +1108,19 @@
</item>
</layout>
</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">
<widget class="QGroupBox" name="failsafesGroupBox">
<property name="styleSheet">
@@ -796,32 +1210,6 @@ QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top left; pad
</layout>
</widget>
</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>
</widget>
</item>
+16 -7
View File
@@ -201,13 +201,13 @@ QString ModelPrinter::printModuleProtocol(unsigned int protocol)
QString ModelPrinter::printMultiRfProtocol(int rfProtocol, bool custom)
{
static const char *strings[] = {
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", "Walkera", "Q303", "GW008", "DM002", "CABELL", "Esky 150", "H8 3D", "Corona", "CFlie"
};
if (custom)
return "Custom - proto " + QString::number(rfProtocol);
return QObject::tr("Custom - proto %1)").arg(QString::number(rfProtocol));
else
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)
{
static const QStringList strFTC = QStringList() << tr("10mW") << tr("100mW") << tr("500mW") << tr("1W");
static const QStringList strLBT = QStringList() << tr("25mW") << tr("500mW");
QStringList strFCC;
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())
return strFTC.at(val);
else if (subType == 1)
if (subType == R9M_FCC && (int)val < strFCC.size())
return strFCC.at(val);
else if (subType == R9M_LBT)
return (telem ? strLBT.at(0) : strLBT.at(1));
else
return "???";
+1 -1
View File
@@ -59,7 +59,7 @@ class ModelPrinter: public QObject
QString printThrottle();
static QString printModuleProtocol(unsigned int protocol);
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 printModuleSubType(unsigned protocol, unsigned subType, unsigned rfProtocol = 0, bool custom = false);
QString printFlightModeSwitch(const RawSwitch & swtch);
+1 -1
View File
@@ -1320,7 +1320,7 @@ void menuModelSetup(event_t event)
uint8_t moduleIdx = CURRENT_MODULE_EDITED(k);
if (IS_MODULE_R9M(moduleIdx)) {
lcdDrawTextAlignedLeft(y, TR_MULTI_RFPOWER);
if(IS_MODULE_R9M_FCC(moduleIdx)) {
if (IS_MODULE_R9M_FCC(moduleIdx)) {
g_model.moduleData[moduleIdx].pxx.power = min((uint8_t)g_model.moduleData[moduleIdx].pxx.power, (uint8_t)R9M_FCC_POWER_MAX); // Lite FCC has only one setting
#if defined(MODULE_R9M_FULLSIZE)
lcdDrawTextAtIndex(MODEL_SETUP_2ND_COLUMN, y, STR_R9M_FCC_POWER_VALUES, g_model.moduleData[moduleIdx].pxx.power, LEFT | attr);