diff --git a/ground/gcs/src/plugins/config/commonhwsettingswidget.cpp b/ground/gcs/src/plugins/config/commonhwsettingswidget.cpp index a758e0fff..2bbe40941 100644 --- a/ground/gcs/src/plugins/config/commonhwsettingswidget.cpp +++ b/ground/gcs/src/plugins/config/commonhwsettingswidget.cpp @@ -25,19 +25,32 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "commonhwsettingswidget.h" - #include "ui_commonhwsettingswidget.h" +#include "hwsettings.h" #include +#include +#include "uavobjectmanager.h" + CommonHWSettingsWidget::CommonHWSettingsWidget(QWidget *parent) : QWidget(parent) { m_ui = new Ui_CommonHWSettingsWidget(); m_ui->setupUi(this); + m_ui->cbDSMxBind->addItem(tr("Disabled"), 0); + + m_ui->cbDSMxBind->addItem(tr("DSM2 1024bit/22ms"), 3); + m_ui->cbDSMxBind->addItem(tr("DSM2 2048bit/11ms"), 5); + m_ui->cbDSMxBind->addItem(tr("DSMX 1024bit/22ms"), 7); + m_ui->cbDSMxBind->addItem(tr("DSMX 2048bit/22ms"), 8); + m_ui->cbDSMxBind->addItem(tr("DSMX 2048bit/11ms"), 9); + + m_ui->cbDSMxBind->setCurrentIndex(0); + setFeatures(0); - /* Relay signals from private members */ + // Relay signals from private members connect(m_ui->cbUSBHID, SIGNAL(currentIndexChanged(int)), this, SIGNAL(USBHIDFunctionChanged(int))); connect(m_ui->cbUSBVCP, SIGNAL(currentIndexChanged(int)), this, SIGNAL(USBVCPFunctionChanged(int))); } @@ -49,10 +62,6 @@ CommonHWSettingsWidget::~CommonHWSettingsWidget() void CommonHWSettingsWidget::registerWidgets(ConfigTaskWidget &ct) { -// addAutoBindings(); - -// ct.addUAVObject("HwSettings"); - ct.addWidgetBinding("HwSettings", "USB_HIDPort", m_ui->cbUSBHID); ct.addWidgetBinding("HwSettings", "USB_VCPPort", m_ui->cbUSBVCP); @@ -60,11 +69,25 @@ void CommonHWSettingsWidget::registerWidgets(ConfigTaskWidget &ct) ct.addWidgetBinding("HwSettings", "GPSSpeed", m_ui->cbGPSSpeed); ct.addWidgetBinding("HwSettings", "DebugConsoleSpeed", m_ui->cbDebugConsoleSpeed); ct.addWidgetBinding("HwSettings", "SBusMode", m_ui->cbSBUSMode); + ct.addWidgetBinding("HwSettings", "DSMxBind", m_ui->cbDSMxBind, 0, 1, true); ct.addWidgetBinding("GPSSettings", "DataProtocol", m_ui->cbGPSProtocol); } +void CommonHWSettingsWidget::refreshWidgetsValues(UAVObject *obj) +{ + Q_UNUSED(obj); + + UAVObjectManager *objMngr = ExtensionSystem::PluginManager::instance()->getObject(); + + int option = HwSettings::GetInstance(objMngr)->getDSMxBind(); + + if(m_ui->cbDSMxBind->findData(option) == -1) { + m_ui->cbDSMxBind->addItem(tr("%1 Pulses").arg(option), option); + m_ui->cbDSMxBind->setCurrentIndex(-1); + } +} void CommonHWSettingsWidget::setFeatures(quint32 features) { diff --git a/ground/gcs/src/plugins/config/commonhwsettingswidget.h b/ground/gcs/src/plugins/config/commonhwsettingswidget.h index 95e72add5..a66f9eb63 100644 --- a/ground/gcs/src/plugins/config/commonhwsettingswidget.h +++ b/ground/gcs/src/plugins/config/commonhwsettingswidget.h @@ -46,7 +46,8 @@ public: virtual ~CommonHWSettingsWidget(); void registerWidgets(ConfigTaskWidget &ct); - + void refreshWidgetsValues(UAVObject *obj); + void setFeatures(quint32 features); QComboBox *USBVCPComboBox(); diff --git a/ground/gcs/src/plugins/config/config.pro b/ground/gcs/src/plugins/config/config.pro index a2d72543c..41df344e1 100644 --- a/ground/gcs/src/plugins/config/config.pro +++ b/ground/gcs/src/plugins/config/config.pro @@ -51,6 +51,7 @@ HEADERS += \ configrevohwwidget.h \ configspracingf3evohwwidget.h \ configtinyfishhwwidget.h \ + configpikoblxhwwidget.h \ commonhwsettingswidget.h \ calibration/calibrationutils.h \ calibration/wizardstate.h \ @@ -101,6 +102,7 @@ SOURCES += \ configrevohwwidget.cpp \ configspracingf3evohwwidget.cpp \ configtinyfishhwwidget.cpp \ + configpikoblxhwwidget.cpp \ commonhwsettingswidget.cpp \ calibration/calibrationutils.cpp \ calibration/wizardstate.cpp \ @@ -141,6 +143,7 @@ FORMS += \ autotune.ui \ configspracingf3evohwwidget.ui \ configtinyfishhwwidget.ui \ + configpikoblxhwwidget.ui \ commonhwsettingswidget.ui \ oplink.ui \ configrevonanohwwidget.ui \ diff --git a/ground/gcs/src/plugins/config/configpikoblxhwwidget.cpp b/ground/gcs/src/plugins/config/configpikoblxhwwidget.cpp new file mode 100644 index 000000000..4c01b3f0f --- /dev/null +++ b/ground/gcs/src/plugins/config/configpikoblxhwwidget.cpp @@ -0,0 +1,191 @@ +/** + ****************************************************************************** + * + * @file configpikoblxhwwidget.cpp + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2016-2017. + * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief PikoBLX hardware configuration panel + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "configpikoblxhwwidget.h" + +#include "ui_configpikoblxhwwidget.h" + +#include "hwsettings.h" + +#include + +ConfigPikoBLXHWWidget::ConfigPikoBLXHWWidget(QWidget *parent) : ConfigTaskWidget(parent) +{ + m_ui = new Ui_PikoBLXHWWidget(); + m_ui->setupUi(this); + + // must be done before auto binding ! + setWikiURL("PikoBLX+Configuration"); + + addAutoBindings(); + + addUAVObject("HwSettings"); + addUAVObject("HwPikoBLXSettings"); + + addWidgetBinding("HwPikoBLXSettings", "UARTPort", m_ui->cbUART1, 0, 1, true); + addWidgetBinding("HwPikoBLXSettings", "UARTPort", m_ui->cbUART2, 1, 1, true); + addWidgetBinding("HwPikoBLXSettings", "UARTPort", m_ui->cbUART3, 2, 1, true); + addWidgetBinding("HwPikoBLXSettings", "LEDPort", m_ui->cbLEDPort); + + m_cbUART[0] = m_ui->cbUART1; + m_cbUART[1] = m_ui->cbUART2; + m_cbUART[2] = m_ui->cbUART3; + + for(quint32 i = 0; i < HwPikoBLXSettings::UARTPORT_NUMELEM; ++i) { + connect(m_cbUART[i], static_cast(&QComboBox::currentIndexChanged), this, &ConfigPikoBLXHWWidget::UARTxChanged); + } + + m_ui->commonHWSettings->registerWidgets(*this); + + connect(m_ui->commonHWSettings, &CommonHWSettingsWidget::USBVCPFunctionChanged, this, &ConfigPikoBLXHWWidget::USBVCPFunctionChanged); + + updateFeatures(); +} + +ConfigPikoBLXHWWidget::~ConfigPikoBLXHWWidget() +{ + delete m_ui; +} + +void ConfigPikoBLXHWWidget::refreshWidgetsValuesImpl(UAVObject *obj) +{ +// is this needed? This is to force sane state +// UART1Changed(0); +// UART2Changed(0); +// UART3Changed(0); + + m_ui->commonHWSettings->refreshWidgetsValues(obj); +} + +void ConfigPikoBLXHWWidget::updateObjectsFromWidgetsImpl() +{ + updateFeatures(); +} + +void ConfigPikoBLXHWWidget::updateFeatures() +{ + quint32 features = CommonHWSettingsWidget::F_USB; + + for(quint32 i = 0; i < HwPikoBLXSettings::UARTPORT_NUMELEM; ++i) { + switch (getComboboxSelectedOption(m_cbUART[i])) { + case HwPikoBLXSettings::UARTPORT_TELEMETRY: + features |= CommonHWSettingsWidget::F_TELEMETRY; + break; + case HwPikoBLXSettings::UARTPORT_DSM: + features |= CommonHWSettingsWidget::F_DSM; + break; + case HwPikoBLXSettings::UARTPORT_SBUS: + features |= CommonHWSettingsWidget::F_SBUS; + break; + case HwPikoBLXSettings::UARTPORT_GPS: + features |= CommonHWSettingsWidget::F_GPS; + break; + case HwPikoBLXSettings::UARTPORT_DEBUGCONSOLE: + features |= CommonHWSettingsWidget::F_DEBUGCONSOLE; + break; + default: + break; + } + } + + m_ui->commonHWSettings->setFeatures(features); + + HwSettings::GetInstance(getObjectManager()) + ->setOptionalModules(HwSettings::OPTIONALMODULES_GPS, + (features & CommonHWSettingsWidget::F_GPS) + ? HwSettings::OPTIONALMODULES_ENABLED : HwSettings::OPTIONALMODULES_DISABLED); +} + +bool ConfigPikoBLXHWWidget::optionConflict(int uartOption, int vcpOption) +{ + return (vcpOption == HwSettings::USB_VCPPORT_DEBUGCONSOLE + && uartOption == HwPikoBLXSettings::UARTPORT_DEBUGCONSOLE) + || (vcpOption == HwSettings::USB_VCPPORT_MAVLINK + && uartOption == HwPikoBLXSettings::UARTPORT_MAVLINK); +} + +void ConfigPikoBLXHWWidget::UARTxChanged(int index) +{ + Q_UNUSED(index); + + QComboBox *cbUARTx = qobject_cast(sender()); + + if(!cbUARTx) { + return; + } + + // Everything except HwPikoBLXSettings::UARTPORT_DISABLED and HwPikoBLXSettings::UARTPORT_DSM + // is allowed on single port only. + // HoTT SUMD & SUMH belong to the same receiver group, therefore cannot be configure at the same time + // + + int option = getComboboxSelectedOption(cbUARTx); + + if (option == HwPikoBLXSettings::UARTPORT_HOTTSUMD) { + option = HwPikoBLXSettings::UARTPORT_HOTTSUMH; + } + + if (option != HwPikoBLXSettings::UARTPORT_DISABLED && option != HwPikoBLXSettings::UARTPORT_DSM) { + + for(quint32 i = 0; i < HwPikoBLXSettings::UARTPORT_NUMELEM; ++i) { + if (m_cbUART[i] == cbUARTx) { + continue; + } + int other = getComboboxSelectedOption(m_cbUART[i]); + if (other == HwPikoBLXSettings::UARTPORT_HOTTSUMD) { + other = HwPikoBLXSettings::UARTPORT_HOTTSUMH; + } + if (other == option) { + setComboboxSelectedOption(m_cbUART[i], HwPikoBLXSettings::UARTPORT_DISABLED); + } + } + + QComboBox *cbUSBVCP = m_ui->commonHWSettings->USBVCPComboBox(); + + if (optionConflict(option, getComboboxSelectedOption(cbUSBVCP))) { + setComboboxSelectedOption(cbUSBVCP, HwSettings::USB_VCPPORT_DISABLED); + } + } + + updateFeatures(); +} + +void ConfigPikoBLXHWWidget::USBVCPFunctionChanged(int index) +{ + Q_UNUSED(index); + + int vcpOption = getComboboxSelectedOption(m_ui->commonHWSettings->USBVCPComboBox()); + + for(quint32 i = 0; i < HwPikoBLXSettings::UARTPORT_NUMELEM; ++i) { + if (optionConflict(getComboboxSelectedOption(m_cbUART[i]), vcpOption)) { + setComboboxSelectedOption(m_cbUART[i], HwPikoBLXSettings::UARTPORT_DISABLED); + } + } + + updateFeatures(); +} + diff --git a/ground/gcs/src/plugins/config/configpikoblxhwwidget.h b/ground/gcs/src/plugins/config/configpikoblxhwwidget.h new file mode 100644 index 000000000..5351d178b --- /dev/null +++ b/ground/gcs/src/plugins/config/configpikoblxhwwidget.h @@ -0,0 +1,65 @@ +/** + ****************************************************************************** + * + * @file configpikoblxhwwidget.h + * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2017. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief PikoBLX hardware configuration panel + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef CONFIGPIKOBLXHWWIDGET_H +#define CONFIGPIKOBLXHWWIDGET_H + +#include "../uavobjectwidgetutils/configtaskwidget.h" + +#include "hwpikoblxsettings.h" + +class Ui_PikoBLXHWWidget; + +class UAVObject; + +class QWidget; + +class ConfigPikoBLXHWWidget : public ConfigTaskWidget { + Q_OBJECT + +public: + ConfigPikoBLXHWWidget(QWidget *parent = 0); + ~ConfigPikoBLXHWWidget(); + +protected: + virtual void refreshWidgetsValuesImpl(UAVObject *obj); + virtual void updateObjectsFromWidgetsImpl(); + +private: + Ui_PikoBLXHWWidget *m_ui; + + QComboBox *m_cbUART[HwPikoBLXSettings::UARTPORT_NUMELEM]; + + void updateFeatures(); + + bool optionConflict(int uartOption, int vcpOption); + +private slots: + void UARTxChanged(int index); + void USBVCPFunctionChanged(int index); +}; + +#endif // CONFIGPIKOBLXHWWIDGET_H diff --git a/ground/gcs/src/plugins/config/configpikoblxhwwidget.ui b/ground/gcs/src/plugins/config/configpikoblxhwwidget.ui new file mode 100644 index 000000000..6ed410ff8 --- /dev/null +++ b/ground/gcs/src/plugins/config/configpikoblxhwwidget.ui @@ -0,0 +1,663 @@ + + + PikoBLXHWWidget + + + + 0 + 0 + 1680 + 1050 + + + + Form + + + + + + 0 + + + + true + + + HW settings + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + 255 + 255 + 255 + + + + + + + 232 + 232 + 232 + + + + + + + + + 255 + 255 + 255 + + + + + + + 232 + 232 + 232 + + + + + + + + + 232 + 232 + 232 + + + + + + + 232 + 232 + 232 + + + + + + + + border-color: rgb(255, 0, 0); + + + QFrame::NoFrame + + + QFrame::Plain + + + true + + + + + 0 + 0 + 1650 + 950 + + + + + 12 + + + 12 + + + 12 + + + 12 + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 75 + true + + + + Changes on this page only take effect after board reset or power cycle + + + Qt::AlignCenter + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 10 + 20 + + + + + + + + + 0 + 0 + + + + + 350 + 350 + + + + + + + :/configgadget/images/pikoblx_top.png + + + false + + + Qt::AlignCenter + + + Qt::NoTextInteraction + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 115 + + + + + + + + Receiver + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + LED Strip + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + UART2 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + UART1 + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + 0 + 0 + + + + + + + + + + + 20 + 80 + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 75 + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 20 + 60 + + + + + + + + + + + + + + + + + + + + 4 + + + + + Qt::Horizontal + + + + 369 + 20 + + + + + + + + + 0 + 0 + + + + + 25 + 25 + + + + + 25 + 25 + + + + Takes you to the wiki page + + + + + + + :/core/images/helpicon.svg:/core/images/helpicon.svg + + + + 25 + 25 + + + + true + + + button:help + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + + + + + 255 + 255 + 255 + + + + + + + 232 + 232 + 232 + + + + + + + + + 255 + 255 + 255 + + + + + + + 232 + 232 + 232 + + + + + + + + + 232 + 232 + 232 + + + + + + + 232 + 232 + 232 + + + + + + + + Send to board but don't write in SD. +Beware of not locking yourself out! + + + false + + + + + + Apply + + + + 16 + 16 + + + + false + + + button:apply + + + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + Applies and Saves all settings to SD. +Beware of not locking yourself out! + + + false + + + + + + Save + + + button:save + + + + + + + + + + CommonHWSettingsWidget + QWidget +
commonhwsettingswidget.h
+ 1 +
+
+ + + + + +
diff --git a/ground/gcs/src/plugins/config/configspracingf3evohwwidget.cpp b/ground/gcs/src/plugins/config/configspracingf3evohwwidget.cpp index d6e4c6d3e..f106d9f71 100644 --- a/ground/gcs/src/plugins/config/configspracingf3evohwwidget.cpp +++ b/ground/gcs/src/plugins/config/configspracingf3evohwwidget.cpp @@ -30,7 +30,6 @@ #include "ui_configspracingf3evohwwidget.h" #include "hwsettings.h" -#include "hwspracingf3evosettings.h" #include @@ -52,11 +51,15 @@ ConfigSPRacingF3EVOHWWidget::ConfigSPRacingF3EVOHWWidget(QWidget *parent) : Conf addWidgetBinding("HwSPRacingF3EVOSettings", "UARTPort", m_ui->cbUART3, 2, 1, true); addWidgetBinding("HwSPRacingF3EVOSettings", "LEDPort", m_ui->cbLEDPort); addWidgetBinding("HwSPRacingF3EVOSettings", "I2CPort", m_ui->cbI2C1); - - connect(m_ui->cbUART1, static_cast(&QComboBox::currentIndexChanged), this, &ConfigSPRacingF3EVOHWWidget::UART1Changed); - connect(m_ui->cbUART2, static_cast(&QComboBox::currentIndexChanged), this, &ConfigSPRacingF3EVOHWWidget::UART2Changed); - connect(m_ui->cbUART3, static_cast(&QComboBox::currentIndexChanged), this, &ConfigSPRacingF3EVOHWWidget::UART3Changed); - + + m_cbUART[0] = m_ui->cbUART1; + m_cbUART[1] = m_ui->cbUART2; + m_cbUART[2] = m_ui->cbUART3; + + for(quint32 i = 0; i < HwSPRacingF3EVOSettings::UARTPORT_NUMELEM; ++i) { + connect(m_cbUART[i], static_cast(&QComboBox::currentIndexChanged), this, &ConfigSPRacingF3EVOHWWidget::UARTxChanged); + } + m_ui->commonHWSettings->registerWidgets(*this); connect(m_ui->commonHWSettings, &CommonHWSettingsWidget::USBVCPFunctionChanged, this, &ConfigSPRacingF3EVOHWWidget::USBVCPFunctionChanged); @@ -66,16 +69,17 @@ ConfigSPRacingF3EVOHWWidget::ConfigSPRacingF3EVOHWWidget(QWidget *parent) : Conf ConfigSPRacingF3EVOHWWidget::~ConfigSPRacingF3EVOHWWidget() { - // Do nothing + delete m_ui; } void ConfigSPRacingF3EVOHWWidget::refreshWidgetsValuesImpl(UAVObject *obj) { - Q_UNUSED(obj); - - UART1Changed(0); - UART2Changed(0); - UART3Changed(0); +// is this needed? This is to force sane state +// UART1Changed(0); +// UART2Changed(0); +// UART3Changed(0); + + m_ui->commonHWSettings->refreshWidgetsValues(obj); } void ConfigSPRacingF3EVOHWWidget::updateObjectsFromWidgetsImpl() @@ -87,10 +91,8 @@ void ConfigSPRacingF3EVOHWWidget::updateFeatures() { quint32 features = CommonHWSettingsWidget::F_USB; - QComboBox *ports[3] = { m_ui->cbUART1, m_ui->cbUART2, m_ui->cbUART3 }; - - for (int i = 0; i < 3; ++i) { - switch (getComboboxSelectedOption(ports[i])) { + for(quint32 i = 0; i < HwSPRacingF3EVOSettings::UARTPORT_NUMELEM; ++i) { + switch (getComboboxSelectedOption(m_cbUART[i])) { case HwSPRacingF3EVOSettings::UARTPORT_TELEMETRY: features |= CommonHWSettingsWidget::F_TELEMETRY; break; @@ -127,12 +129,20 @@ bool ConfigSPRacingF3EVOHWWidget::optionConflict(int uartOption, int vcpOption) && uartOption == HwSPRacingF3EVOSettings::UARTPORT_MAVLINK); } -void ConfigSPRacingF3EVOHWWidget::UARTxChanged(QComboBox *cbUARTx) +void ConfigSPRacingF3EVOHWWidget::UARTxChanged(int index) { - /* Everything except HwSPRacingF3EVOSettings::UARTPORT_DISABLED and HwSPRacingF3EVOSettings::UARTPORT_DSM - * is allowed on single port only. - * HoTT SUMD & SUMH belong to the same receiver group, therefore cannot be configure at the same time - */ + Q_UNUSED(index); + + QComboBox *cbUARTx = qobject_cast(sender()); + + if(!cbUARTx) { + return; + } + + // Everything except HwSPRacingF3EVOSettings::UARTPORT_DISABLED and HwSPRacingF3EVOSettings::UARTPORT_DSM + // is allowed on single port only. + // HoTT SUMD & SUMH belong to the same receiver group, therefore cannot be configure at the same time + // int option = getComboboxSelectedOption(cbUARTx); @@ -141,18 +151,17 @@ void ConfigSPRacingF3EVOHWWidget::UARTxChanged(QComboBox *cbUARTx) } if (option != HwSPRacingF3EVOSettings::UARTPORT_DISABLED && option != HwSPRacingF3EVOSettings::UARTPORT_DSM) { - QComboBox *ports[3] = { m_ui->cbUART1, m_ui->cbUART2, m_ui->cbUART3 }; - for (int i = 0; i < 3; ++i) { - if (ports[i] == cbUARTx) { + for(quint32 i = 0; i < HwSPRacingF3EVOSettings::UARTPORT_NUMELEM; ++i) { + if (m_cbUART[i] == cbUARTx) { continue; } - int other = getComboboxSelectedOption(ports[i]); + int other = getComboboxSelectedOption(m_cbUART[i]); if (other == HwSPRacingF3EVOSettings::UARTPORT_HOTTSUMD) { other = HwSPRacingF3EVOSettings::UARTPORT_HOTTSUMH; } if (other == option) { - setComboboxSelectedOption(ports[i], HwSPRacingF3EVOSettings::UARTPORT_DISABLED); + setComboboxSelectedOption(m_cbUART[i], HwSPRacingF3EVOSettings::UARTPORT_DISABLED); } } @@ -172,31 +181,12 @@ void ConfigSPRacingF3EVOHWWidget::USBVCPFunctionChanged(int index) int vcpOption = getComboboxSelectedOption(m_ui->commonHWSettings->USBVCPComboBox()); - QComboBox *ports[3] = { m_ui->cbUART1, m_ui->cbUART2, m_ui->cbUART3 }; - - for (int i = 0; i < 3; ++i) { - if (optionConflict(getComboboxSelectedOption(ports[i]), vcpOption)) { - setComboboxSelectedOption(ports[i], HwSPRacingF3EVOSettings::UARTPORT_DISABLED); + for(quint32 i = 0; i < HwSPRacingF3EVOSettings::UARTPORT_NUMELEM; ++i) { + if (optionConflict(getComboboxSelectedOption(m_cbUART[i]), vcpOption)) { + setComboboxSelectedOption(m_cbUART[i], HwSPRacingF3EVOSettings::UARTPORT_DISABLED); } } updateFeatures(); } -void ConfigSPRacingF3EVOHWWidget::UART1Changed(int index) -{ - Q_UNUSED(index); - UARTxChanged(m_ui->cbUART1); -} - -void ConfigSPRacingF3EVOHWWidget::UART2Changed(int index) -{ - Q_UNUSED(index); - UARTxChanged(m_ui->cbUART2); -} - -void ConfigSPRacingF3EVOHWWidget::UART3Changed(int index) -{ - Q_UNUSED(index); - UARTxChanged(m_ui->cbUART3); -} diff --git a/ground/gcs/src/plugins/config/configspracingf3evohwwidget.h b/ground/gcs/src/plugins/config/configspracingf3evohwwidget.h index 4f90a2f33..7c4c73ff7 100644 --- a/ground/gcs/src/plugins/config/configspracingf3evohwwidget.h +++ b/ground/gcs/src/plugins/config/configspracingf3evohwwidget.h @@ -30,6 +30,8 @@ #include "../uavobjectwidgetutils/configtaskwidget.h" +#include "hwspracingf3evosettings.h" + class Ui_SPRacingF3EVOHWWidget; class UAVObject; @@ -49,15 +51,15 @@ protected: private: Ui_SPRacingF3EVOHWWidget *m_ui; - void UARTxChanged(QComboBox *cbUARTx); + + QComboBox *m_cbUART[HwSPRacingF3EVOSettings::UARTPORT_NUMELEM]; + void updateFeatures(); bool optionConflict(int uartOption, int vcpOption); private slots: - void UART1Changed(int index); - void UART2Changed(int index); - void UART3Changed(int index); + void UARTxChanged(int index); void USBVCPFunctionChanged(int index); }; diff --git a/ground/gcs/src/plugins/config/configtinyfishhwwidget.cpp b/ground/gcs/src/plugins/config/configtinyfishhwwidget.cpp index be078f2c8..7f0771125 100644 --- a/ground/gcs/src/plugins/config/configtinyfishhwwidget.cpp +++ b/ground/gcs/src/plugins/config/configtinyfishhwwidget.cpp @@ -49,7 +49,7 @@ ConfigTinyFISHHWWidget::ConfigTinyFISHHWWidget(QWidget *parent) : ConfigTaskWidg addWidgetBinding("HwTinyFISHSettings", "UART3Port", m_ui->cbUART3, 0, 1, true); addWidgetBinding("HwTinyFISHSettings", "LEDPort", m_ui->cbLEDPort); - connect(m_ui->cbUART3, static_cast(&QComboBox::currentIndexChanged), this, &ConfigTinyFISHHWWidget::UART3Changed); + connect(m_ui->cbUART3, static_cast(&QComboBox::currentIndexChanged), this, &ConfigTinyFISHHWWidget::UARTxChanged); m_ui->commonHWSettings->registerWidgets(*this); @@ -60,14 +60,14 @@ ConfigTinyFISHHWWidget::ConfigTinyFISHHWWidget(QWidget *parent) : ConfigTaskWidg ConfigTinyFISHHWWidget::~ConfigTinyFISHHWWidget() { - // Do nothing + delete m_ui; } void ConfigTinyFISHHWWidget::refreshWidgetsValuesImpl(UAVObject *obj) { - Q_UNUSED(obj); - - UART3Changed(0); +// UART3Changed(0); + + m_ui->commonHWSettings->refreshWidgetsValues(obj); } void ConfigTinyFISHHWWidget::updateObjectsFromWidgetsImpl() @@ -115,12 +115,15 @@ bool ConfigTinyFISHHWWidget::optionConflict(int uartOption, int vcpOption) && uartOption == HwTinyFISHSettings::UART3PORT_MAVLINK); } -void ConfigTinyFISHHWWidget::UARTxChanged(QComboBox *cbUARTx) +void ConfigTinyFISHHWWidget::UARTxChanged(int index) { - /* Everything except HwTinyFISHSettings::UARTPORT_DISABLED and HwTinyFISHSettings::UARTPORT_DSM - * is allowed on single port only. - * HoTT SUMD & SUMH belong to the same receiver group, therefore cannot be configure at the same time - */ + Q_UNUSED(index); + + QComboBox *cbUARTx = qobject_cast(sender()); + + if(!cbUARTx) { + return; + } int option = getComboboxSelectedOption(cbUARTx); @@ -149,9 +152,3 @@ void ConfigTinyFISHHWWidget::USBVCPFunctionChanged(int index) updateFeatures(); } - -void ConfigTinyFISHHWWidget::UART3Changed(int index) -{ - Q_UNUSED(index); - UARTxChanged(m_ui->cbUART3); -} diff --git a/ground/gcs/src/plugins/config/configtinyfishhwwidget.h b/ground/gcs/src/plugins/config/configtinyfishhwwidget.h index 8363d74f4..9481f43f1 100644 --- a/ground/gcs/src/plugins/config/configtinyfishhwwidget.h +++ b/ground/gcs/src/plugins/config/configtinyfishhwwidget.h @@ -48,13 +48,12 @@ protected: private: Ui_TinyFISHHWWidget *m_ui; - void UARTxChanged(QComboBox *cbUARTx); void updateFeatures(); bool optionConflict(int uartOption, int vcpOption); private slots: - void UART3Changed(int index); + void UARTxChanged(int index); void USBVCPFunctionChanged(int index); };