2011-02-20 00:04:38 +01:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file configgadgetwidget.cpp
|
|
|
|
* @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @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-03-28 20:43:15 +02:00
|
|
|
|
2011-03-21 01:54:09 +01:00
|
|
|
#include "configahrswidget.h"
|
2011-02-20 00:04:38 +01:00
|
|
|
#include "configgadgetwidget.h"
|
|
|
|
|
2011-03-28 20:43:15 +02:00
|
|
|
#include "configairframewidget.h"
|
|
|
|
#include "configccattitudewidget.h"
|
2011-03-28 17:39:22 +02:00
|
|
|
#include "configinputwidget.h"
|
|
|
|
#include "configoutputwidget.h"
|
2011-03-28 20:43:15 +02:00
|
|
|
#include "configstabilizationwidget.h"
|
2011-02-20 00:04:38 +01:00
|
|
|
#include "configtelemetrywidget.h"
|
2011-03-29 22:32:09 +02:00
|
|
|
#include "defaultattitudewidget.h"
|
2011-03-21 01:54:09 +01:00
|
|
|
|
2011-03-28 23:15:44 +02:00
|
|
|
#include "uavobjectutilmanager.h"
|
2011-02-20 00:04:38 +01:00
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QtGui/QWidget>
|
|
|
|
#include <QtGui/QTextEdit>
|
|
|
|
#include <QtGui/QVBoxLayout>
|
|
|
|
#include <QtGui/QPushButton>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
|
|
|
|
{
|
|
|
|
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
|
|
|
|
2011-03-28 23:15:44 +02:00
|
|
|
ftw = new FancyTabWidget(this, true);
|
2011-02-20 00:04:38 +01:00
|
|
|
|
|
|
|
ftw->setIconSize(64);
|
|
|
|
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout;
|
|
|
|
layout->addWidget(ftw);
|
|
|
|
setLayout(layout);
|
|
|
|
|
|
|
|
// *********************
|
|
|
|
QWidget *qwd;
|
|
|
|
|
|
|
|
qwd = new ConfigAirframeWidget(this);
|
2011-03-25 13:16:49 +01:00
|
|
|
ftw->insertTab(0, qwd, QIcon(":/configgadget/images/Airframe.png"), QString("Aircraft"));
|
2011-02-20 00:04:38 +01:00
|
|
|
|
2011-03-28 17:39:22 +02:00
|
|
|
qwd = new ConfigInputWidget(this);
|
2011-03-29 02:15:38 +02:00
|
|
|
ftw->insertTab(1, qwd, QIcon(":/configgadget/images/Transmitter.png"), QString("Input"));
|
2011-03-28 17:39:22 +02:00
|
|
|
|
|
|
|
qwd = new ConfigOutputWidget(this);
|
|
|
|
ftw->insertTab(2, qwd, QIcon(":/configgadget/images/Servo.png"), QString("Output"));
|
2011-02-20 00:04:38 +01:00
|
|
|
|
2011-03-29 22:32:09 +02:00
|
|
|
qwd = new DefaultAttitudeWidget(this);
|
2011-03-28 17:39:22 +02:00
|
|
|
ftw->insertTab(3, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS"));
|
2011-02-20 00:04:38 +01:00
|
|
|
|
2011-02-22 23:03:32 +01:00
|
|
|
qwd = new ConfigStabilizationWidget(this);
|
2011-03-28 17:39:22 +02:00
|
|
|
ftw->insertTab(4, qwd, QIcon(":/configgadget/images/gyroscope.svg"), QString("Stabilization"));
|
2011-03-25 13:16:49 +01:00
|
|
|
|
|
|
|
qwd = new ConfigTelemetryWidget(this);
|
2011-03-28 17:39:22 +02:00
|
|
|
ftw->insertTab(5, qwd, QIcon(":/configgadget/images/XBee.svg"), QString("Telemetry"));
|
2011-02-22 23:03:32 +01:00
|
|
|
|
2011-03-28 20:43:15 +02:00
|
|
|
|
2011-03-28 23:15:44 +02:00
|
|
|
// qwd = new ConfigPipXtremeWidget(this);
|
2011-03-25 13:16:49 +01:00
|
|
|
// ftw->insertTab(5, qwd, QIcon(":/configgadget/images/PipXtreme.png"), QString("PipXtreme"));
|
2011-02-20 00:04:38 +01:00
|
|
|
|
|
|
|
// *********************
|
|
|
|
// Listen to autopilot connection events
|
|
|
|
|
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
TelemetryManager* telMngr = pm->getObject<TelemetryManager>();
|
|
|
|
connect(telMngr, SIGNAL(connected()), this, SLOT(onAutopilotConnect()));
|
2011-06-07 16:56:16 +02:00
|
|
|
connect(telMngr, SIGNAL(disconnected()), this, SLOT(onAutopilotDisconnect()));
|
2011-02-20 00:04:38 +01:00
|
|
|
|
2011-03-31 22:48:43 +02:00
|
|
|
// And check whether by any chance we are not already connected
|
|
|
|
if (telMngr->isConnected())
|
2011-06-07 16:56:16 +02:00
|
|
|
onAutopilotConnect();
|
2011-03-31 22:48:43 +02:00
|
|
|
|
2011-05-17 06:54:23 +02:00
|
|
|
help = 0;
|
2011-02-20 00:04:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ConfigGadgetWidget::~ConfigGadgetWidget()
|
|
|
|
{
|
|
|
|
// Do nothing
|
2011-02-22 23:03:32 +01:00
|
|
|
|
|
|
|
// TODO: properly delete all the tabs in ftw before exiting
|
2011-02-20 00:04:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigGadgetWidget::resizeEvent(QResizeEvent *event)
|
|
|
|
{
|
|
|
|
|
|
|
|
QWidget::resizeEvent(event);
|
|
|
|
}
|
|
|
|
|
2011-06-07 16:56:16 +02:00
|
|
|
void ConfigGadgetWidget::onAutopilotDisconnect() {
|
|
|
|
emit autopilotDisconnected();
|
|
|
|
}
|
|
|
|
|
2011-02-20 00:04:38 +01:00
|
|
|
void ConfigGadgetWidget::onAutopilotConnect() {
|
2011-03-28 23:15:44 +02:00
|
|
|
|
|
|
|
// First of all, check what Board type we are talking to, and
|
|
|
|
// if necessary, remove/add tabs in the config gadget:
|
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
UAVObjectUtilManager* utilMngr = pm->getObject<UAVObjectUtilManager>();
|
|
|
|
if (utilMngr) {
|
|
|
|
int board = utilMngr->getBoardModel();
|
|
|
|
qDebug() << "Board model: " << board;
|
|
|
|
if ((board & 0xff00) == 1024) {
|
|
|
|
// CopterControl family
|
|
|
|
// Delete the INS panel, replace with CC Panel:
|
|
|
|
ftw->setCurrentIndex(0);
|
|
|
|
ftw->removeTab(3);
|
|
|
|
QWidget *qwd = new ConfigCCAttitudeWidget(this);
|
|
|
|
ftw->insertTab(3, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("Attitude"));
|
|
|
|
} else if ((board & 0xff00) == 256 ) {
|
|
|
|
// Mainboard family
|
|
|
|
ftw->setCurrentIndex(0);
|
|
|
|
ftw->removeTab(3);
|
|
|
|
QWidget *qwd = new ConfigAHRSWidget(this);
|
|
|
|
ftw->insertTab(3, qwd, QIcon(":/configgadget/images/AHRS-v1.3.png"), QString("INS"));
|
|
|
|
}
|
|
|
|
}
|
2011-02-20 00:04:38 +01:00
|
|
|
emit autopilotConnected();
|
|
|
|
}
|
|
|
|
|
2011-05-17 06:54:23 +02:00
|
|
|
|
|
|
|
|