2011-03-29 22:32:09 +02:00
/**
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* @ file configtelemetrywidget . h
2011-08-20 20:10:28 +02:00
* @ author The OpenPilot Team , http : //www.openpilot.org Copyright (C) 2010.
2011-03-29 22:32:09 +02:00
* @ addtogroup GCSPlugins GCS Plugins
* @ {
* @ addtogroup ConfigPlugin Config Plugin
* @ {
* @ brief The Configuration Gadget used to update settings in the firmware
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* 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
*/
2011-07-19 15:50:42 +02:00
# include "config_cc_hw_widget.h"
2011-11-01 17:48:07 +01:00
# include "hwsettings.h"
2011-03-29 22:32:09 +02:00
# include <QDebug>
# include <QStringList>
2013-09-15 23:06:25 +02:00
# include <QWidget>
# include <QTextEdit>
# include <QVBoxLayout>
# include <QPushButton>
2011-08-11 17:58:22 +02:00
# include <QDesktopServices>
# include <QUrl>
2012-07-19 14:22:36 +02:00
# include <extensionsystem/pluginmanager.h>
# include <coreplugin/generalsettings.h>
2012-07-21 21:28:55 +02:00
2012-07-19 14:22:36 +02:00
2011-07-19 15:50:42 +02:00
ConfigCCHWWidget : : ConfigCCHWWidget ( QWidget * parent ) : ConfigTaskWidget ( parent )
2011-03-29 22:32:09 +02:00
{
2011-07-19 15:50:42 +02:00
m_telemetry = new Ui_CC_HW_Widget ( ) ;
2011-03-29 22:32:09 +02:00
m_telemetry - > setupUi ( this ) ;
2012-01-31 21:11:04 +01:00
2013-05-19 16:37:30 +02:00
ExtensionSystem : : PluginManager * pm = ExtensionSystem : : PluginManager : : instance ( ) ;
Core : : Internal : : GeneralSettings * settings = pm - > getObject < Core : : Internal : : GeneralSettings > ( ) ;
if ( ! settings - > useExpertMode ( ) ) {
2012-07-19 14:22:36 +02:00
m_telemetry - > saveTelemetryToRAM - > setVisible ( false ) ;
2013-05-19 16:37:30 +02:00
}
2012-07-21 21:28:55 +02:00
2012-07-19 14:22:36 +02:00
2013-05-19 16:37:30 +02:00
UAVObjectUtilManager * utilMngr = pm - > getObject < UAVObjectUtilManager > ( ) ;
2012-07-09 03:34:23 +02:00
int id = utilMngr - > getBoardModel ( ) ;
2012-01-31 21:11:04 +01:00
2012-07-09 03:34:23 +02:00
switch ( id ) {
case 0x0101 :
m_telemetry - > label_2 - > setPixmap ( QPixmap ( " :/uploader/images/deviceID-0101.svg " ) ) ;
break ;
case 0x0301 :
m_telemetry - > label_2 - > setPixmap ( QPixmap ( " :/uploader/images/deviceID-0301.svg " ) ) ;
break ;
case 0x0401 :
2012-08-24 18:50:28 +02:00
m_telemetry - > label_2 - > setPixmap ( QPixmap ( " :/configgadget/images/coptercontrol.svg " ) ) ;
2012-07-09 03:34:23 +02:00
break ;
case 0x0402 :
2012-08-24 18:50:28 +02:00
m_telemetry - > label_2 - > setPixmap ( QPixmap ( " :/configgadget/images/coptercontrol.svg " ) ) ;
2012-07-09 03:34:23 +02:00
break ;
case 0x0201 :
m_telemetry - > label_2 - > setPixmap ( QPixmap ( " :/uploader/images/deviceID-0201.svg " ) ) ;
break ;
default :
m_telemetry - > label_2 - > setPixmap ( QPixmap ( " :/configgadget/images/coptercontrol.svg " ) ) ;
break ;
}
2013-05-19 16:37:30 +02:00
addApplySaveButtons ( m_telemetry - > saveTelemetryToRAM , m_telemetry - > saveTelemetryToSD ) ;
2014-01-01 22:49:04 +01:00
addWidgetBinding ( " HwSettings " , " CC_FlexiPort " , m_telemetry - > cbFlexi ) ;
addWidgetBinding ( " HwSettings " , " CC_MainPort " , m_telemetry - > cbTele ) ;
addWidgetBinding ( " HwSettings " , " CC_RcvrPort " , m_telemetry - > cbRcvr ) ;
addWidgetBinding ( " HwSettings " , " USB_HIDPort " , m_telemetry - > cbUsbHid ) ;
addWidgetBinding ( " HwSettings " , " USB_VCPPort " , m_telemetry - > cbUsbVcp ) ;
addWidgetBinding ( " HwSettings " , " TelemetrySpeed " , m_telemetry - > telemetrySpeed ) ;
addWidgetBinding ( " HwSettings " , " GPSSpeed " , m_telemetry - > gpsSpeed ) ;
2014-03-13 21:24:31 +01:00
// Add Gps protocol configuration
2014-04-20 13:26:06 +02:00
HwSettings * hwSettings = HwSettings : : GetInstance ( getObjectManager ( ) ) ;
HwSettings : : DataFields hwSettingsData = hwSettings - > getData ( ) ;
2014-07-02 23:27:58 +02:00
if ( hwSettingsData . OptionalModules [ HwSettings : : OPTIONALMODULES_GPS ] ! = HwSettings : : OPTIONALMODULES_ENABLED ) {
2014-04-20 13:26:06 +02:00
m_telemetry - > gpsProtocol - > setEnabled ( false ) ;
m_telemetry - > gpsProtocol - > setToolTip ( tr ( " Enable GPS module and reboot the board to be able to select GPS protocol " ) ) ;
} else {
addWidgetBinding ( " GPSSettings " , " DataProtocol " , m_telemetry - > gpsProtocol ) ;
}
2014-03-12 20:51:19 +01:00
2014-01-01 22:49:04 +01:00
addWidgetBinding ( " HwSettings " , " ComUsbBridgeSpeed " , m_telemetry - > comUsbBridgeSpeed ) ;
2013-05-19 16:37:30 +02:00
connect ( m_telemetry - > cchwHelp , SIGNAL ( clicked ( ) ) , this , SLOT ( openHelp ( ) ) ) ;
2013-06-25 13:41:15 +02:00
enableSaveButtons ( false ) ;
2011-07-26 00:18:41 +02:00
populateWidgets ( ) ;
refreshWidgetsValues ( ) ;
2012-08-01 16:17:05 +02:00
forceConnectedState ( ) ;
2011-03-29 22:32:09 +02:00
}
2011-07-19 15:50:42 +02:00
ConfigCCHWWidget : : ~ ConfigCCHWWidget ( )
2011-03-29 22:32:09 +02:00
{
2011-07-26 00:18:41 +02:00
// Do nothing
2011-03-29 22:32:09 +02:00
}
2011-07-19 15:50:42 +02:00
void ConfigCCHWWidget : : refreshValues ( )
2013-05-19 16:37:30 +02:00
{ }
2011-03-29 22:32:09 +02:00
2011-07-26 00:18:41 +02:00
void ConfigCCHWWidget : : widgetsContentsChanged ( )
2011-03-29 22:32:09 +02:00
{
2011-07-26 21:35:38 +02:00
ConfigTaskWidget : : widgetsContentsChanged ( ) ;
2013-05-19 16:37:30 +02:00
2012-10-11 06:51:09 +02:00
if ( ( ( m_telemetry - > cbTele - > currentIndex ( ) = = HwSettings : : CC_MAINPORT_DEBUGCONSOLE ) & &
2013-05-19 16:37:30 +02:00
( m_telemetry - > cbFlexi - > currentIndex ( ) = = HwSettings : : CC_FLEXIPORT_DEBUGCONSOLE ) ) | |
( ( m_telemetry - > cbFlexi - > currentIndex ( ) = = HwSettings : : CC_FLEXIPORT_DEBUGCONSOLE ) & &
( m_telemetry - > cbUsbVcp - > currentIndex ( ) = = HwSettings : : USB_VCPPORT_DEBUGCONSOLE ) ) | |
( ( m_telemetry - > cbUsbVcp - > currentIndex ( ) = = HwSettings : : USB_VCPPORT_DEBUGCONSOLE ) & &
( m_telemetry - > cbTele - > currentIndex ( ) = = HwSettings : : CC_MAINPORT_DEBUGCONSOLE ) ) ) {
2013-06-25 13:41:15 +02:00
enableSaveButtons ( false ) ;
2012-10-11 06:51:09 +02:00
m_telemetry - > problems - > setText ( tr ( " Warning: you have configured more than one DebugConsole, this currently is not supported " ) ) ;
2013-05-19 16:37:30 +02:00
} else if ( ( ( m_telemetry - > cbTele - > currentIndex ( ) = = HwSettings : : CC_MAINPORT_TELEMETRY ) & & ( m_telemetry - > cbFlexi - > currentIndex ( ) = = HwSettings : : CC_FLEXIPORT_TELEMETRY ) ) | |
( ( m_telemetry - > cbTele - > currentIndex ( ) = = HwSettings : : CC_MAINPORT_GPS ) & & ( m_telemetry - > cbFlexi - > currentIndex ( ) = = HwSettings : : CC_FLEXIPORT_GPS ) ) | |
( ( m_telemetry - > cbTele - > currentIndex ( ) = = HwSettings : : CC_MAINPORT_DEBUGCONSOLE ) & & ( m_telemetry - > cbFlexi - > currentIndex ( ) = = HwSettings : : CC_FLEXIPORT_DEBUGCONSOLE ) ) | |
( ( m_telemetry - > cbTele - > currentIndex ( ) = = HwSettings : : CC_MAINPORT_COMBRIDGE ) & & ( m_telemetry - > cbFlexi - > currentIndex ( ) = = HwSettings : : CC_FLEXIPORT_COMBRIDGE ) ) ) {
2013-06-25 13:41:15 +02:00
enableSaveButtons ( false ) ;
2011-11-01 00:16:43 +01:00
m_telemetry - > problems - > setText ( tr ( " Warning: you have configured both MainPort and FlexiPort for the same function, this currently is not supported " ) ) ;
2013-05-19 16:37:30 +02:00
} else if ( ( m_telemetry - > cbUsbHid - > currentIndex ( ) = = HwSettings : : USB_HIDPORT_USBTELEMETRY ) & & ( m_telemetry - > cbUsbVcp - > currentIndex ( ) = = HwSettings : : USB_VCPPORT_USBTELEMETRY ) ) {
2013-06-25 13:41:15 +02:00
enableSaveButtons ( false ) ;
2011-12-28 22:18:44 +01:00
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 " ) ) ;
2013-05-19 16:37:30 +02:00
} else if ( ( m_telemetry - > cbUsbHid - > currentIndex ( ) ! = HwSettings : : USB_HIDPORT_USBTELEMETRY ) & & ( m_telemetry - > cbUsbVcp - > currentIndex ( ) ! = HwSettings : : USB_VCPPORT_USBTELEMETRY ) ) {
2013-06-25 13:41:15 +02:00
enableSaveButtons ( false ) ;
2011-12-30 19:12:46 +01:00
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 " ) ) ;
2013-05-19 16:37:30 +02:00
} else {
2011-07-26 00:18:41 +02:00
m_telemetry - > problems - > setText ( " " ) ;
2013-06-25 13:41:15 +02:00
enableSaveButtons ( true ) ;
2011-07-26 00:18:41 +02:00
}
2011-03-29 22:32:09 +02:00
}
2011-07-26 00:18:41 +02:00
2013-06-25 13:41:15 +02:00
void ConfigCCHWWidget : : enableSaveButtons ( bool enable )
{
m_telemetry - > saveTelemetryToRAM - > setEnabled ( enable ) ;
m_telemetry - > saveTelemetryToSD - > setEnabled ( enable ) ;
}
2011-08-11 17:58:22 +02:00
void ConfigCCHWWidget : : openHelp ( )
{
2014-05-10 11:56:24 +02:00
QDesktopServices : : openUrl ( QUrl ( tr ( " http://wiki.openpilot.org/x/D4AUAQ " ) , QUrl : : StrictMode ) ) ;
2011-08-11 17:58:22 +02:00
}
/**
2013-05-19 16:37:30 +02:00
* @ }
* @ }
*/