2 ******************************************************************************
4 * @file configtelemetrywidget.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
8 * @addtogroup ConfigPlugin Config Plugin
10 * @brief The Configuration Gadget used to update settings in the firmware
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 #include "config_cc_hw_widget.h"
28 #include "hwsettings.h"
30 #include <QStringList>
33 #include <QVBoxLayout>
34 #include <QPushButton>
35 #include <QDesktopServices>
37 #include <extensionsystem/pluginmanager.h>
38 #include <coreplugin/generalsettings.h>
41 ConfigCCHWWidget::ConfigCCHWWidget(QWidget
*parent
) : ConfigTaskWidget(parent
)
43 m_telemetry
= new Ui_CC_HW_Widget();
44 m_telemetry
->setupUi(this);
46 ExtensionSystem::PluginManager
*pm
= ExtensionSystem::PluginManager::instance();
47 Core::Internal::GeneralSettings
*settings
= pm
->getObject
<Core::Internal::GeneralSettings
>();
48 if (!settings
->useExpertMode()) {
49 m_telemetry
->saveTelemetryToRAM
->setVisible(false);
53 UAVObjectUtilManager
*utilMngr
= pm
->getObject
<UAVObjectUtilManager
>();
54 int id
= utilMngr
->getBoardModel();
58 m_telemetry
->label_2
->setPixmap(QPixmap(":/uploader/images/deviceID-0101.svg"));
61 m_telemetry
->label_2
->setPixmap(QPixmap(":/uploader/images/deviceID-0301.svg"));
64 m_telemetry
->label_2
->setPixmap(QPixmap(":/configgadget/images/coptercontrol.svg"));
67 m_telemetry
->label_2
->setPixmap(QPixmap(":/configgadget/images/coptercontrol.svg"));
70 m_telemetry
->label_2
->setPixmap(QPixmap(":/uploader/images/deviceID-0201.svg"));
73 m_telemetry
->label_2
->setPixmap(QPixmap(":/configgadget/images/coptercontrol.svg"));
76 addApplySaveButtons(m_telemetry
->saveTelemetryToRAM
, m_telemetry
->saveTelemetryToSD
);
77 addWidgetBinding("HwSettings", "CC_FlexiPort", m_telemetry
->cbFlexi
);
78 addWidgetBinding("HwSettings", "CC_MainPort", m_telemetry
->cbTele
);
79 addWidgetBinding("HwSettings", "CC_RcvrPort", m_telemetry
->cbRcvr
);
80 addWidgetBinding("HwSettings", "USB_HIDPort", m_telemetry
->cbUsbHid
);
81 addWidgetBinding("HwSettings", "USB_VCPPort", m_telemetry
->cbUsbVcp
);
82 addWidgetBinding("HwSettings", "TelemetrySpeed", m_telemetry
->telemetrySpeed
);
83 addWidgetBinding("HwSettings", "GPSSpeed", m_telemetry
->gpsSpeed
);
84 // Add Gps protocol configuration
86 HwSettings
*hwSettings
= HwSettings::GetInstance(getObjectManager());
87 HwSettings::DataFields hwSettingsData
= hwSettings
->getData();
89 if (hwSettingsData
.OptionalModules
[HwSettings::OPTIONALMODULES_GPS
] != HwSettings::OPTIONALMODULES_ENABLED
) {
90 m_telemetry
->gpsProtocol
->setEnabled(false);
91 m_telemetry
->gpsProtocol
->setToolTip(tr("Enable GPS module and reboot the board to be able to select GPS protocol"));
93 addWidgetBinding("GPSSettings", "DataProtocol", m_telemetry
->gpsProtocol
);
96 addWidgetBinding("HwSettings", "ComUsbBridgeSpeed", m_telemetry
->comUsbBridgeSpeed
);
97 connect(m_telemetry
->cchwHelp
, SIGNAL(clicked()), this, SLOT(openHelp()));
98 enableSaveButtons(false);
100 refreshWidgetsValues();
101 forceConnectedState();
104 ConfigCCHWWidget::~ConfigCCHWWidget()
109 void ConfigCCHWWidget::refreshValues()
112 void ConfigCCHWWidget::widgetsContentsChanged()
114 ConfigTaskWidget::widgetsContentsChanged();
116 if (((m_telemetry
->cbTele
->currentIndex() == HwSettings::CC_MAINPORT_DEBUGCONSOLE
) &&
117 (m_telemetry
->cbFlexi
->currentIndex() == HwSettings::CC_FLEXIPORT_DEBUGCONSOLE
)) ||
118 ((m_telemetry
->cbFlexi
->currentIndex() == HwSettings::CC_FLEXIPORT_DEBUGCONSOLE
) &&
119 (m_telemetry
->cbUsbVcp
->currentIndex() == HwSettings::USB_VCPPORT_DEBUGCONSOLE
)) ||
120 ((m_telemetry
->cbUsbVcp
->currentIndex() == HwSettings::USB_VCPPORT_DEBUGCONSOLE
) &&
121 (m_telemetry
->cbTele
->currentIndex() == HwSettings::CC_MAINPORT_DEBUGCONSOLE
))) {
122 enableSaveButtons(false);
123 m_telemetry
->problems
->setText(tr("Warning: you have configured more than one DebugConsole, this currently is not supported"));
124 } else if (((m_telemetry
->cbTele
->currentIndex() == HwSettings::CC_MAINPORT_TELEMETRY
) && (m_telemetry
->cbFlexi
->currentIndex() == HwSettings::CC_FLEXIPORT_TELEMETRY
)) ||
125 ((m_telemetry
->cbTele
->currentIndex() == HwSettings::CC_MAINPORT_GPS
) && (m_telemetry
->cbFlexi
->currentIndex() == HwSettings::CC_FLEXIPORT_GPS
)) ||
126 ((m_telemetry
->cbTele
->currentIndex() == HwSettings::CC_MAINPORT_DEBUGCONSOLE
) && (m_telemetry
->cbFlexi
->currentIndex() == HwSettings::CC_FLEXIPORT_DEBUGCONSOLE
)) ||
127 ((m_telemetry
->cbTele
->currentIndex() == HwSettings::CC_MAINPORT_COMBRIDGE
) && (m_telemetry
->cbFlexi
->currentIndex() == HwSettings::CC_FLEXIPORT_COMBRIDGE
))) {
128 enableSaveButtons(false);
129 m_telemetry
->problems
->setText(tr("Warning: you have configured both MainPort and FlexiPort for the same function, this currently is not supported"));
130 } else if ((m_telemetry
->cbUsbHid
->currentIndex() == HwSettings::USB_HIDPORT_USBTELEMETRY
) && (m_telemetry
->cbUsbVcp
->currentIndex() == HwSettings::USB_VCPPORT_USBTELEMETRY
)) {
131 enableSaveButtons(false);
132 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"));
133 } else if ((m_telemetry
->cbUsbHid
->currentIndex() != HwSettings::USB_HIDPORT_USBTELEMETRY
) && (m_telemetry
->cbUsbVcp
->currentIndex() != HwSettings::USB_VCPPORT_USBTELEMETRY
)) {
134 enableSaveButtons(false);
135 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"));
137 m_telemetry
->problems
->setText("");
138 enableSaveButtons(true);
142 void ConfigCCHWWidget::enableSaveButtons(bool enable
)
144 m_telemetry
->saveTelemetryToRAM
->setEnabled(enable
);
145 m_telemetry
->saveTelemetryToSD
->setEnabled(enable
);
148 void ConfigCCHWWidget::openHelp()
150 QDesktopServices::openUrl(QUrl(tr("http://wiki.openpilot.org/x/D4AUAQ"), QUrl::StrictMode
));