LP-311 Remove basic/advanced stabilization tab auto-switch (autotune/txpid lock issues)
[librepilot.git] / ground / gcs / src / plugins / config / config_cc_hw_widget.cpp
blobfc827bb008da29a8f55d91fff3d3e283723ff33f
1 /**
2 ******************************************************************************
4 * @file configtelemetrywidget.h
5 * @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
6 * The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
7 * @addtogroup GCSPlugins GCS Plugins
8 * @{
9 * @addtogroup ConfigPlugin Config Plugin
10 * @{
11 * @brief The Configuration Gadget used to update settings in the firmware
12 *****************************************************************************/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 3 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * for more details.
24 * You should have received a copy of the GNU General Public License along
25 * with this program; if not, write to the Free Software Foundation, Inc.,
26 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "config_cc_hw_widget.h"
31 #include "ui_cc_hw_settings.h"
33 #include <extensionsystem/pluginmanager.h>
34 #include <coreplugin/generalsettings.h>
36 #include "hwsettings.h"
38 #include <QDebug>
39 #include <QStringList>
40 #include <QWidget>
41 #include <QTextEdit>
42 #include <QVBoxLayout>
43 #include <QPushButton>
44 #include <QDesktopServices>
45 #include <QUrl>
47 ConfigCCHWWidget::ConfigCCHWWidget(QWidget *parent) : ConfigTaskWidget(parent)
49 m_telemetry = new Ui_CC_HW_Widget();
50 m_telemetry->setupUi(this);
52 ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
53 Core::Internal::GeneralSettings *settings = pm->getObject<Core::Internal::GeneralSettings>();
54 if (!settings->useExpertMode()) {
55 m_telemetry->saveTelemetryToRAM->setVisible(false);
59 UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
60 int id = utilMngr->getBoardModel();
62 switch (id) {
63 case 0x0101:
64 m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0101.svg"));
65 break;
66 case 0x0301:
67 m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0301.svg"));
68 break;
69 case 0x0401:
70 m_telemetry->label_2->setPixmap(QPixmap(":/configgadget/images/coptercontrol.svg"));
71 break;
72 case 0x0402:
73 m_telemetry->label_2->setPixmap(QPixmap(":/configgadget/images/cc3d_top.png"));
74 break;
75 case 0x0201:
76 m_telemetry->label_2->setPixmap(QPixmap(":/uploader/images/deviceID-0201.svg"));
77 break;
78 default:
79 m_telemetry->label_2->setPixmap(QPixmap(":/configgadget/images/coptercontrol.svg"));
80 break;
82 addApplySaveButtons(m_telemetry->saveTelemetryToRAM, m_telemetry->saveTelemetryToSD);
83 addWidgetBinding("HwSettings", "CC_FlexiPort", m_telemetry->cbFlexi);
84 addWidgetBinding("HwSettings", "CC_MainPort", m_telemetry->cbTele);
85 addWidgetBinding("HwSettings", "CC_RcvrPort", m_telemetry->cbRcvr);
86 addWidgetBinding("HwSettings", "USB_HIDPort", m_telemetry->cbUsbHid);
87 addWidgetBinding("HwSettings", "USB_VCPPort", m_telemetry->cbUsbVcp);
88 addWidgetBinding("HwSettings", "TelemetrySpeed", m_telemetry->telemetrySpeed);
89 addWidgetBinding("HwSettings", "GPSSpeed", m_telemetry->gpsSpeed);
90 // Add Gps protocol configuration
92 HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager());
93 HwSettings::DataFields hwSettingsData = hwSettings->getData();
95 if (hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_GPS] != HwSettings::OPTIONALMODULES_ENABLED) {
96 m_telemetry->gpsProtocol->setEnabled(false);
97 m_telemetry->gpsProtocol->setToolTip(tr("Enable GPS module and reboot the board to be able to select GPS protocol"));
98 } else {
99 addWidgetBinding("GPSSettings", "DataProtocol", m_telemetry->gpsProtocol);
102 addWidgetBinding("HwSettings", "ComUsbBridgeSpeed", m_telemetry->comUsbBridgeSpeed);
103 connect(m_telemetry->cchwHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
104 enableSaveButtons(false);
105 populateWidgets();
106 refreshWidgetsValues();
107 forceConnectedState();
110 ConfigCCHWWidget::~ConfigCCHWWidget()
112 // Do nothing
115 void ConfigCCHWWidget::refreshValues()
118 void ConfigCCHWWidget::widgetsContentsChanged()
120 ConfigTaskWidget::widgetsContentsChanged();
122 if (((m_telemetry->cbTele->currentIndex() == HwSettings::CC_MAINPORT_DEBUGCONSOLE) &&
123 (m_telemetry->cbFlexi->currentIndex() == HwSettings::CC_FLEXIPORT_DEBUGCONSOLE)) ||
124 ((m_telemetry->cbFlexi->currentIndex() == HwSettings::CC_FLEXIPORT_DEBUGCONSOLE) &&
125 (m_telemetry->cbUsbVcp->currentIndex() == HwSettings::USB_VCPPORT_DEBUGCONSOLE)) ||
126 ((m_telemetry->cbUsbVcp->currentIndex() == HwSettings::USB_VCPPORT_DEBUGCONSOLE) &&
127 (m_telemetry->cbTele->currentIndex() == HwSettings::CC_MAINPORT_DEBUGCONSOLE))) {
128 enableSaveButtons(false);
129 m_telemetry->problems->setText(tr("Warning: you have configured more than one DebugConsole, this currently is not supported"));
130 } else if (((m_telemetry->cbTele->currentIndex() == HwSettings::CC_MAINPORT_TELEMETRY) && (m_telemetry->cbFlexi->currentIndex() == HwSettings::CC_FLEXIPORT_TELEMETRY)) ||
131 ((m_telemetry->cbTele->currentIndex() == HwSettings::CC_MAINPORT_GPS) && (m_telemetry->cbFlexi->currentIndex() == HwSettings::CC_FLEXIPORT_GPS)) ||
132 ((m_telemetry->cbTele->currentIndex() == HwSettings::CC_MAINPORT_DEBUGCONSOLE) && (m_telemetry->cbFlexi->currentIndex() == HwSettings::CC_FLEXIPORT_DEBUGCONSOLE)) ||
133 ((m_telemetry->cbTele->currentIndex() == HwSettings::CC_MAINPORT_COMBRIDGE) && (m_telemetry->cbFlexi->currentIndex() == HwSettings::CC_FLEXIPORT_COMBRIDGE))) {
134 enableSaveButtons(false);
135 m_telemetry->problems->setText(tr("Warning: you have configured both MainPort and FlexiPort for the same function, this currently is not supported"));
136 } else if ((m_telemetry->cbUsbHid->currentIndex() == HwSettings::USB_HIDPORT_USBTELEMETRY) && (m_telemetry->cbUsbVcp->currentIndex() == HwSettings::USB_VCPPORT_USBTELEMETRY)) {
137 enableSaveButtons(false);
138 m_telemetry->problems->setText(tr("Warning: you have configured both USB HID Port and USB VCP Port for the same function, this currently is not supported"));
139 } else if ((m_telemetry->cbUsbHid->currentIndex() != HwSettings::USB_HIDPORT_USBTELEMETRY) && (m_telemetry->cbUsbVcp->currentIndex() != HwSettings::USB_VCPPORT_USBTELEMETRY)) {
140 enableSaveButtons(false);
141 m_telemetry->problems->setText(tr("Warning: you have disabled USB Telemetry on both USB HID Port and USB VCP Port, this currently is not supported"));
142 } else {
143 m_telemetry->problems->setText("");
144 enableSaveButtons(true);
148 void ConfigCCHWWidget::enableSaveButtons(bool enable)
150 m_telemetry->saveTelemetryToRAM->setEnabled(enable);
151 m_telemetry->saveTelemetryToSD->setEnabled(enable);
154 void ConfigCCHWWidget::openHelp()
156 QDesktopServices::openUrl(QUrl(QString(WIKI_URL_ROOT) + QString("CC+Hardware+Configuration"),
157 QUrl::StrictMode));
161 * @}
162 * @}