2011-02-22 22:03:32 +00:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
2013-05-01 12:59:07 +02:00
|
|
|
* @file configstabilizationwidget.cpp
|
2011-02-22 22:03:32 +00:00
|
|
|
* @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
|
|
|
|
*/
|
|
|
|
#include "configstabilizationwidget.h"
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QtGui/QWidget>
|
|
|
|
#include <QtGui/QTextEdit>
|
|
|
|
#include <QtGui/QVBoxLayout>
|
|
|
|
#include <QtGui/QPushButton>
|
2011-05-31 00:16:01 -07:00
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QUrl>
|
2012-02-02 16:22:40 +00:00
|
|
|
#include <QList>
|
2011-02-22 22:03:32 +00:00
|
|
|
|
2012-07-21 10:58:05 -07:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
#include <coreplugin/generalsettings.h>
|
|
|
|
|
2011-02-22 22:03:32 +00:00
|
|
|
ConfigStabilizationWidget::ConfigStabilizationWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui = new Ui_StabilizationWidget();
|
|
|
|
ui->setupUi(this);
|
2012-05-15 16:24:49 -05:00
|
|
|
|
2012-07-21 10:58:05 -07:00
|
|
|
|
2013-05-01 12:59:07 +02:00
|
|
|
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
Core::Internal::GeneralSettings* settings = pm->getObject<Core::Internal::GeneralSettings>();
|
|
|
|
if(!settings->useExpertMode()) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->saveStabilizationToRAM_6->setVisible(false);
|
2013-05-01 12:59:07 +02:00
|
|
|
}
|
2012-05-15 16:24:49 -05:00
|
|
|
|
2012-02-06 17:33:54 +00:00
|
|
|
autoLoadWidgets();
|
2012-02-10 16:34:07 +00:00
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
realtimeUpdates = new QTimer(this);
|
2013-05-01 12:59:07 +02:00
|
|
|
connect(realtimeUpdates, SIGNAL(timeout()), this, SLOT(apply()));
|
2012-02-10 16:34:07 +00:00
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
connect(ui->realTimeUpdates_6, SIGNAL(stateChanged(int)), this, SLOT(realtimeUpdatesSlot(int)));
|
|
|
|
addWidget(ui->realTimeUpdates_6);
|
|
|
|
connect(ui->realTimeUpdates_8, SIGNAL(stateChanged(int)), this, SLOT(realtimeUpdatesSlot(int)));
|
|
|
|
addWidget(ui->realTimeUpdates_8);
|
|
|
|
|
|
|
|
connect(ui->checkBox_7, SIGNAL(stateChanged(int)), this, SLOT(linkCheckBoxes(int)));
|
|
|
|
addWidget(ui->checkBox_7);
|
|
|
|
connect(ui->checkBox_2, SIGNAL(stateChanged(int)), this, SLOT(linkCheckBoxes(int)));
|
|
|
|
addWidget(ui->checkBox_2);
|
|
|
|
connect(ui->checkBox_8, SIGNAL(stateChanged(int)), this, SLOT(linkCheckBoxes(int)));
|
|
|
|
addWidget(ui->checkBox_8);
|
|
|
|
connect(ui->checkBox_3, SIGNAL(stateChanged(int)), this, SLOT(linkCheckBoxes(int)));
|
|
|
|
addWidget(ui->checkBox_3);
|
|
|
|
|
|
|
|
addWidget(ui->pushButton_2);
|
|
|
|
addWidget(ui->pushButton_3);
|
|
|
|
addWidget(ui->pushButton_4);
|
|
|
|
addWidget(ui->pushButton_5);
|
|
|
|
addWidget(ui->pushButton_6);
|
|
|
|
addWidget(ui->pushButton_9);
|
|
|
|
addWidget(ui->pushButton_20);
|
|
|
|
addWidget(ui->pushButton_22);
|
|
|
|
addWidget(ui->pushButton_23);
|
2012-04-19 13:00:20 -04:00
|
|
|
|
2013-05-01 12:59:07 +02:00
|
|
|
connect(this, SIGNAL(widgetContentsChanged(QWidget*)), this, SLOT(processLinkedWidgets(QWidget*)));
|
2012-05-26 09:55:04 -05:00
|
|
|
|
2013-05-01 12:59:07 +02:00
|
|
|
// Link by default
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->checkBox_7->setChecked(true);
|
|
|
|
ui->checkBox_8->setChecked(true);
|
2012-07-21 10:58:05 -07:00
|
|
|
|
2013-05-01 12:59:07 +02:00
|
|
|
disableMouseWheelEvents();
|
2013-05-04 00:13:15 +02:00
|
|
|
updateEnableControls();
|
2011-02-22 22:03:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ConfigStabilizationWidget::~ConfigStabilizationWidget()
|
|
|
|
{
|
2012-02-10 16:34:07 +00:00
|
|
|
// Do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigStabilizationWidget::realtimeUpdatesSlot(int value)
|
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->realTimeUpdates_6->setCheckState((Qt::CheckState)value);
|
|
|
|
ui->realTimeUpdates_8->setCheckState((Qt::CheckState)value);
|
2013-05-01 12:59:07 +02:00
|
|
|
|
|
|
|
if(value == Qt::Checked && !realtimeUpdates->isActive()) {
|
2012-02-10 16:34:07 +00:00
|
|
|
realtimeUpdates->start(300);
|
2013-05-01 12:59:07 +02:00
|
|
|
}
|
|
|
|
else if(value == Qt::Unchecked) {
|
2012-02-10 16:34:07 +00:00
|
|
|
realtimeUpdates->stop();
|
2013-05-01 12:59:07 +02:00
|
|
|
}
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigStabilizationWidget::linkCheckBoxes(int value)
|
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
if(sender() == ui->checkBox_7) {
|
|
|
|
ui->checkBox_3->setCheckState((Qt::CheckState)value);
|
2013-05-01 12:59:07 +02:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(sender() == ui->checkBox_3) {
|
|
|
|
ui->checkBox_7->setCheckState((Qt::CheckState)value);
|
2013-05-01 12:59:07 +02:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(sender( )== ui->checkBox_8) {
|
|
|
|
ui->checkBox_2->setCheckState((Qt::CheckState)value);
|
2013-05-01 12:59:07 +02:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(sender() == ui->checkBox_2) {
|
|
|
|
ui->checkBox_8->setCheckState((Qt::CheckState)value);
|
2013-05-01 12:59:07 +02:00
|
|
|
}
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigStabilizationWidget::processLinkedWidgets(QWidget * widget)
|
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
if(ui->checkBox_7->checkState()==Qt::Checked)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
if(widget== ui->RateRollKp_2)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->RatePitchKp->setValue(ui->RateRollKp_2->value());
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(widget== ui->RateRollKi_2)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->RatePitchKi->setValue(ui->RateRollKi_2->value());
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(widget== ui->RateRollILimit_2)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->RatePitchILimit->setValue(ui->RateRollILimit_2->value());
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(widget== ui->RatePitchKp)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->RateRollKp_2->setValue(ui->RatePitchKp->value());
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(widget== ui->RatePitchKi)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->RateRollKi_2->setValue(ui->RatePitchKi->value());
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(widget== ui->RatePitchILimit)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->RateRollILimit_2->setValue(ui->RatePitchILimit->value());
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(widget== ui->RollRateKd)
|
2012-07-27 11:55:01 +01:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->PitchRateKd->setValue(ui->RollRateKd->value());
|
2012-07-27 11:55:01 +01:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(widget== ui->PitchRateKd)
|
2012-07-27 11:55:01 +01:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->RollRateKd->setValue(ui->PitchRateKd->value());
|
2012-07-27 11:55:01 +01:00
|
|
|
}
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
if(ui->checkBox_8->checkState()==Qt::Checked)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
if(widget== ui->AttitudeRollKp)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->AttitudePitchKp_2->setValue(ui->AttitudeRollKp->value());
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(widget== ui->AttitudeRollKi)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->AttitudePitchKi_2->setValue(ui->AttitudeRollKi->value());
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(widget== ui->AttitudeRollILimit)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->AttitudePitchILimit_2->setValue(ui->AttitudeRollILimit->value());
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(widget== ui->AttitudePitchKp_2)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->AttitudeRollKp->setValue(ui->AttitudePitchKp_2->value());
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(widget== ui->AttitudePitchKi_2)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->AttitudeRollKi->setValue(ui->AttitudePitchKi_2->value());
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
else if(widget== ui->AttitudePitchILimit_2)
|
2012-02-10 16:34:07 +00:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->AttitudeRollILimit->setValue(ui->AttitudePitchILimit_2->value());
|
2012-02-10 16:34:07 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-22 22:03:32 +00:00
|
|
|
}
|
|
|
|
|
2011-05-31 00:16:01 -07:00
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
|