diff --git a/ground/src/plugins/gcscontrol/gcscontrol.pro b/ground/src/plugins/gcscontrol/gcscontrol.pro index fe338dba4..6ed6d79bf 100644 --- a/ground/src/plugins/gcscontrol/gcscontrol.pro +++ b/ground/src/plugins/gcscontrol/gcscontrol.pro @@ -7,13 +7,17 @@ include(../../plugins/coreplugin/coreplugin.pri) include(../../plugins/uavobjects/uavobjects.pri) include(../../libs/sdlgamepad/sdlgamepad.pri) -HEADERS += gcscontrolgadget.h +HEADERS += gcscontrolgadget.h \ + gcscontrolgadgetconfiguration.h \ + gcscontrolgadgetoptionspage.h HEADERS += joystickcontrol.h HEADERS += gcscontrolgadgetwidget.h HEADERS += gcscontrolgadgetfactory.h HEADERS += gcscontrolplugin.h -SOURCES += gcscontrolgadget.cpp +SOURCES += gcscontrolgadget.cpp \ + gcscontrolgadgetconfiguration.cpp \ + gcscontrolgadgetoptionspage.cpp SOURCES += gcscontrolgadgetwidget.cpp SOURCES += gcscontrolgadgetfactory.cpp SOURCES += gcscontrolplugin.cpp @@ -21,6 +25,7 @@ SOURCES += joystickcontrol.cpp OTHER_FILES += GCSControl.pluginspec -FORMS += gcscontrol.ui +FORMS += gcscontrol.ui \ + gcscontrolgadgetoptionspage.ui RESOURCES += gcscontrol.qrc diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp b/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp index c056c98a6..59cd3d311 100644 --- a/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp +++ b/ground/src/plugins/gcscontrol/gcscontrolgadget.cpp @@ -118,7 +118,7 @@ void GCSControlGadget::axesValues(QListInt16 values) double leftX = values[0]; double leftY = values[1]; double rightX = values[2]; - double rightY = values[3]; + double rightY = 0; // values[3]; double max = 32767; if(joystickTime.elapsed() > JOYSTICK_UPDATE_RATE) { joystickTime.restart(); diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.cpp b/ground/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.cpp new file mode 100644 index 000000000..1941bbc40 --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.cpp @@ -0,0 +1,106 @@ +/** + ****************************************************************************** + * + * @file gcscontrolgadgetconfiguration.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin + * @{ + * @brief A gadget to control the UAV, either from the keyboard or a joystick + *****************************************************************************/ +/* + * 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 "gcscontrolgadgetconfiguration.h" + +/** + * Loads a saved configuration or defaults if non exist. + * + */ +GCSControlGadgetConfiguration::GCSControlGadgetConfiguration(QString classId, QSettings* qSettings, QObject *parent) : + IUAVGadgetConfiguration(classId, parent) +{ + //if a saved configuration exists load it + if(qSettings != 0) { + /* + BaudRateType speed; + DataBitsType databits; + FlowType flow; + ParityType parity; + StopBitsType stopbits; + + int ispeed = qSettings->value("defaultSpeed").toInt(); + int idatabits = qSettings->value("defaultDataBits").toInt(); + int iflow = qSettings->value("defaultFlow").toInt(); + int iparity = qSettings->value("defaultParity").toInt(); + int istopbits = qSettings->value("defaultStopBits").toInt(); + QString port = qSettings->value("defaultPort").toString(); + QString conMode = qSettings->value("connectionMode").toString(); + + databits = (DataBitsType) idatabits; + flow = (FlowType)iflow; + parity = (ParityType)iparity; + stopbits = (StopBitsType)istopbits; + speed = (BaudRateType)ispeed; + m_defaultPort = port; + m_defaultSpeed = speed; + m_defaultDataBits = databits; + m_defaultFlow = flow; + m_defaultParity = parity; + m_defaultStopBits = stopbits; + m_connectionMode = conMode; + */ + } + +} + +/** + * Clones a configuration. + * + */ +IUAVGadgetConfiguration *GCSControlGadgetConfiguration::clone() +{ + GCSControlGadgetConfiguration *m = new GCSControlGadgetConfiguration(this->classId()); + + /* + + m->m_defaultSpeed = m_defaultSpeed; + m->m_defaultDataBits = m_defaultDataBits; + m->m_defaultFlow = m_defaultFlow; + m->m_defaultParity = m_defaultParity; + m->m_defaultStopBits = m_defaultStopBits; + m->m_defaultPort = m_defaultPort; + m->m_connectionMode = m_connectionMode; + */ + return m; +} + +/** + * Saves a configuration. + * + */ +void GCSControlGadgetConfiguration::saveConfig(QSettings* settings) const { + /* + settings->setValue("defaultSpeed", m_defaultSpeed); + settings->setValue("defaultDataBits", m_defaultDataBits); + settings->setValue("defaultFlow", m_defaultFlow); + settings->setValue("defaultParity", m_defaultParity); + settings->setValue("defaultStopBits", m_defaultStopBits); + settings->setValue("defaultPort", m_defaultPort); + settings->setValue("connectionMode", m_connectionMode); +*/ +} diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.h b/ground/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.h new file mode 100644 index 000000000..33e6d7706 --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetconfiguration.h @@ -0,0 +1,81 @@ +/** + ****************************************************************************** + * + * @file gcscontrolgadgetconfiguration.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin + * @{ + * @brief A gadget to control the UAV, either from the keyboard or a joystick + *****************************************************************************/ +/* + * 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 GCSCONTROLGADGETCONFIGURATION_H +#define GCSCONTROLGADGETCONFIGURATION_H + +#include + +using namespace Core; + +class GCSControlGadgetConfiguration : public IUAVGadgetConfiguration +{ + Q_OBJECT + public: + explicit GCSControlGadgetConfiguration(QString classId, QSettings* qSettings = 0, QObject *parent = 0); + + /* + void setConnectionMode(QString mode) { m_connectionMode = mode; } + QString connectionMode() { return m_connectionMode; } + + //set port configuration functions + void setSpeed(BaudRateType speed) {m_defaultSpeed=speed;} + void setDataBits(DataBitsType databits) {m_defaultDataBits=databits;} + void setFlow(FlowType flow) {m_defaultFlow=flow;} + void setParity(ParityType parity) {m_defaultParity=parity;} + void setStopBits(StopBitsType stopbits) {m_defaultStopBits=stopbits;} + void setPort(QString port){m_defaultPort=port;} + void setTimeOut(long timeout){m_defaultTimeOut=timeout;} + + //get port configuration functions + QString port(){return m_defaultPort;} + BaudRateType speed() {return m_defaultSpeed;} + FlowType flow() {return m_defaultFlow;} + DataBitsType dataBits() {return m_defaultDataBits;} + StopBitsType stopBits() {return m_defaultStopBits;} + ParityType parity() {return m_defaultParity;} + long timeOut(){return m_defaultTimeOut;} + */ + + void saveConfig(QSettings* settings) const; + IUAVGadgetConfiguration *clone(); + + private: + /* + QString m_connectionMode; + QString m_defaultPort; + BaudRateType m_defaultSpeed; + DataBitsType m_defaultDataBits; + FlowType m_defaultFlow; + ParityType m_defaultParity; + StopBitsType m_defaultStopBits; + long m_defaultTimeOut; + */ + +}; + +#endif // GCSCONTROLGADGETCONFIGURATION_H diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.cpp b/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.cpp index d090a61a6..0f5f91cf1 100644 --- a/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.cpp +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.cpp @@ -45,3 +45,15 @@ IUAVGadget* GCSControlGadgetFactory::createGadget(QWidget *parent) { GCSControlGadgetWidget* gadgetWidget = new GCSControlGadgetWidget(parent); return new GCSControlGadget(QString("GCSControlGadget"), gadgetWidget, parent); } + +IUAVGadgetConfiguration *GCSControlGadgetFactory::createConfiguration(QSettings* qSettings) +{ + return new GCSControlGadgetConfiguration(QString("GCSControlGadget"), qSettings); +} + +IOptionsPage *GCSControlGadgetFactory::createOptionsPage(IUAVGadgetConfiguration *config) +{ + return new GCSControlGadgetOptionsPage(qobject_cast(config)); +} + + diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.h b/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.h index 283c36e80..1ffebf22c 100644 --- a/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.h +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetfactory.h @@ -29,6 +29,8 @@ #define GCSControlGADGETFACTORY_H_ #include +#include "gcscontrolgadgetconfiguration.h" +#include "gcscontrolgadgetoptionspage.h" namespace Core { class IUAVGadget; @@ -45,6 +47,9 @@ public: ~GCSControlGadgetFactory(); IUAVGadget *createGadget(QWidget *parent); + IUAVGadgetConfiguration *createConfiguration(QSettings* qSettings); + IOptionsPage *createOptionsPage(IUAVGadgetConfiguration *config); + }; #endif // GCSControlGADGETFACTORY_H_ diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.cpp b/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.cpp new file mode 100644 index 000000000..4f05eed7f --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.cpp @@ -0,0 +1,68 @@ +/** + ****************************************************************************** + * + * @file gcscontrolgadgetoptionspage.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin + * @{ + * @brief A place holder gadget plugin + *****************************************************************************/ +/* + * 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 "gcscontrolgadgetoptionspage.h" +#include "gcscontrolgadgetconfiguration.h" +#include "ui_gcscontrolgadgetoptionspage.h" + +#include +#include +#include + +GCSControlGadgetOptionsPage::GCSControlGadgetOptionsPage(GCSControlGadgetConfiguration *config, QObject *parent) : + IOptionsPage(parent), + m_config(config) +{ + +} + + +//creates options page widget (uses the UI file) +QWidget *GCSControlGadgetOptionsPage::createPage(QWidget *parent) +{ + options_page = new Ui::GCSControlGadgetOptionsPage(); + QWidget *optionsPageWidget = new QWidget; + options_page->setupUi(optionsPageWidget); + + return optionsPageWidget; +} + +/** + * Called when the user presses apply or OK. + * + * Saves the current values + * + */ +void GCSControlGadgetOptionsPage::apply() +{ + +} + +void GCSControlGadgetOptionsPage::finish() +{ + delete options_page; +} diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.h b/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.h new file mode 100644 index 000000000..ed229ae3b --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.h @@ -0,0 +1,77 @@ +/** + ****************************************************************************** + * + * @file gcscontrolgadgetoptionspage.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup GCSControlGadgetPlugin GCSControl Gadget Plugin + * @{ + * @brief A place holder gadget plugin + *****************************************************************************/ +/* + * 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 GCSCONTROLGADGETOPTIONSPAGE_H +#define GCSCONTROLGADGETOPTIONSPAGE_H + +#include "coreplugin/dialogs/ioptionspage.h" +#include "QString" +#include +#include + +namespace Core { +class IUAVGadgetConfiguration; +} + +class GCSControlGadgetConfiguration; + +namespace Ui { + class GCSControlGadgetOptionsPage; +} + +using namespace Core; + +class GCSControlGadgetOptionsPage : public IOptionsPage +{ +Q_OBJECT +public: + explicit GCSControlGadgetOptionsPage(GCSControlGadgetConfiguration *config, QObject *parent = 0); + + QWidget *createPage(QWidget *parent); + void apply(); + void finish(); + +private: + Ui::GCSControlGadgetOptionsPage *options_page; + GCSControlGadgetConfiguration *m_config; + + /* + QStringList BaudRateTypeString; + QStringList BaudRateTypeStringALL; + QStringList DataBitsTypeStringALL; + QStringList ParityTypeStringALL; + QStringList StopBitsTypeStringALL; + QStringList DataBitsTypeString; + QStringList ParityTypeString; + QStringList StopBitsTypeString; + QStringList FlowTypeString; + */ + +private slots: +}; + +#endif // GCSCONTROLGADGETOPTIONSPAGE_H diff --git a/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui b/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui new file mode 100644 index 000000000..50c81ab31 --- /dev/null +++ b/ground/src/plugins/gcscontrol/gcscontrolgadgetoptionspage.ui @@ -0,0 +1,309 @@ + + + GCSControlGadgetOptionsPage + + + + 0 + 0 + 587 + 359 + + + + + 0 + 0 + + + + Form + + + + 0 + + + + + + + + + + Control Mode: + + + + + + + + Mode 1 + + + + + Mode 2 + + + + + Mode 3 + + + + + Mode 4 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + External input Device: + + + + + + + Define the external input device you want to use here. + + + + Joystick + + + + + Audio + + + + + + + + + + Qt::Horizontal + + + + + + + 0 + + + + Joystick + + + + 0 + + + + + + + + + + Rev + + + + + + + Rev + + + + + + + + + + + + + + + + + + + + + + + + + + + + 24 + + + + + + + 24 + + + + + + + 24 + + + + + + + 24 + + + + + + + 24 + + + + + + + 24 + + + + + + + 24 + + + + + + + 24 + + + + + + + Rev + + + + + + + Rev + + + + + + + Rev + + + + + + + Rev + + + + + + + Rev + + + + + + + Rev + + + + + + + Move your joystick controls to identify channels + + + + + + + + + + Audio + + + + 0 + + + + + Audio: soundcard-based PPM decoding for trainer port. Not implemented yet. + + + + + + + Qt::Vertical + + + + 20 + 276 + + + + + + + + + + + + + + + +