1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Control gadget: make it configurable. Mock-up of config interface included, does not work yet.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2090 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
edouard 2010-11-07 15:16:58 +00:00 committed by edouard
parent bb1b6d8b8d
commit 1ed26a8514
9 changed files with 667 additions and 4 deletions

View File

@ -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

View File

@ -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();

View File

@ -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);
*/
}

View File

@ -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 <coreplugin/iuavgadgetconfiguration.h>
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

View File

@ -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<GCSControlGadgetConfiguration*>(config));
}

View File

@ -29,6 +29,8 @@
#define GCSControlGADGETFACTORY_H_
#include <coreplugin/iuavgadgetfactory.h>
#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_

View File

@ -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 <QFileDialog>
#include <QtAlgorithms>
#include <QStringList>
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;
}

View File

@ -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 <QStringList>
#include <QDebug>
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

View File

@ -0,0 +1,309 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GCSControlGadgetOptionsPage</class>
<widget class="QWidget" name="GCSControlGadgetOptionsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>587</width>
<height>359</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Control Mode:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="connectionMode">
<item>
<property name="text">
<string>Mode 1</string>
</property>
</item>
<item>
<property name="text">
<string>Mode 2</string>
</property>
</item>
<item>
<property name="text">
<string>Mode 3</string>
</property>
</item>
<item>
<property name="text">
<string>Mode 4</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>External input Device:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox">
<property name="toolTip">
<string>Define the external input device you want to use here.</string>
</property>
<item>
<property name="text">
<string>Joystick</string>
</property>
</item>
<item>
<property name="text">
<string>Audio</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabWidgetPage2" native="true">
<attribute name="title">
<string>Joystick</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="1">
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QComboBox" name="comboBox_2"/>
</item>
<item row="2" column="2">
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QComboBox" name="comboBox_3"/>
</item>
<item row="4" column="0">
<widget class="QComboBox" name="comboBox_4"/>
</item>
<item row="5" column="0">
<widget class="QComboBox" name="comboBox_5"/>
</item>
<item row="6" column="0">
<widget class="QComboBox" name="comboBox_6"/>
</item>
<item row="7" column="0">
<widget class="QComboBox" name="comboBox_7"/>
</item>
<item row="8" column="0">
<widget class="QComboBox" name="comboBox_8"/>
</item>
<item row="9" column="0">
<widget class="QComboBox" name="comboBox_9"/>
</item>
<item row="3" column="1">
<widget class="QProgressBar" name="progressBar">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QProgressBar" name="progressBar_2">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QProgressBar" name="progressBar_3">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QProgressBar" name="progressBar_4">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QProgressBar" name="progressBar_5">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QProgressBar" name="progressBar_6">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QProgressBar" name="progressBar_7">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QProgressBar" name="progressBar_8">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QCheckBox" name="checkBox_3">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
<item row="5" column="2">
<widget class="QCheckBox" name="checkBox_4">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QCheckBox" name="checkBox_5">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QCheckBox" name="checkBox_6">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
<item row="8" column="2">
<widget class="QCheckBox" name="checkBox_7">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QCheckBox" name="checkBox_8">
<property name="text">
<string>Rev</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Move your joystick controls to identify channels</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabWidgetPage3" native="true">
<attribute name="title">
<string>Audio</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_5">
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="telemetryLabel">
<property name="text">
<string>Audio: soundcard-based PPM decoding for trainer port. Not implemented yet.</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>276</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>