2011-02-08 17:49:33 +01:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
2011-08-20 20:10:28 +02:00
|
|
|
* @file configinputwidget.cpp
|
2011-08-10 16:24:35 +02:00
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
2011-02-08 17:49:33 +01:00
|
|
|
* @addtogroup GCSPlugins GCS Plugins
|
|
|
|
* @{
|
|
|
|
* @addtogroup ConfigPlugin Config Plugin
|
|
|
|
* @{
|
|
|
|
* @brief Servo input/output configuration panel for the config gadget
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* 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-02-27 20:20:43 +01:00
|
|
|
|
2011-03-28 17:39:22 +02:00
|
|
|
#include "configinputwidget.h"
|
2011-02-08 17:49:33 +01:00
|
|
|
|
2011-02-27 20:20:43 +01:00
|
|
|
#include "uavtalk/telemetrymanager.h"
|
|
|
|
|
2011-02-08 17:49:33 +01:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QtGui/QWidget>
|
|
|
|
#include <QtGui/QTextEdit>
|
|
|
|
#include <QtGui/QVBoxLayout>
|
|
|
|
#include <QtGui/QPushButton>
|
2011-05-31 09:16:01 +02:00
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QUrl>
|
2011-06-13 12:14:40 +02:00
|
|
|
#include <QMessageBox>
|
2011-08-16 17:06:18 +02:00
|
|
|
#include <utils/stylehelper.h>
|
2011-08-20 20:10:28 +02:00
|
|
|
#include <QMessageBox>
|
2011-02-08 17:49:33 +01:00
|
|
|
|
2012-09-16 15:14:47 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
#include <coreplugin/generalsettings.h>
|
|
|
|
|
2012-01-24 23:29:08 +01:00
|
|
|
#define ACCESS_MIN_MOVE -3
|
|
|
|
#define ACCESS_MAX_MOVE 3
|
2011-08-16 17:06:18 +02:00
|
|
|
#define STICK_MIN_MOVE -8
|
|
|
|
#define STICK_MAX_MOVE 8
|
2011-06-08 00:35:21 +02:00
|
|
|
|
2012-10-19 12:00:42 +02:00
|
|
|
ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
|
|
|
|
ConfigTaskWidget(parent),
|
|
|
|
wizardStep(wizardNone),
|
|
|
|
// not currently stored in the settings UAVO
|
|
|
|
transmitterMode(mode2),
|
|
|
|
transmitterType(acro),
|
|
|
|
//
|
|
|
|
loop(NULL),
|
|
|
|
skipflag(false)
|
2011-02-08 17:49:33 +01:00
|
|
|
{
|
2011-08-10 16:24:35 +02:00
|
|
|
manualCommandObj = ManualControlCommand::GetInstance(getObjectManager());
|
|
|
|
manualSettingsObj = ManualControlSettings::GetInstance(getObjectManager());
|
2012-09-16 15:14:47 +02:00
|
|
|
flightStatusObj = FlightStatus::GetInstance(getObjectManager());
|
2011-08-10 16:24:35 +02:00
|
|
|
receiverActivityObj=ReceiverActivity::GetInstance(getObjectManager());
|
2013-05-04 00:13:15 +02:00
|
|
|
ui = new Ui_InputWidget();
|
|
|
|
ui->setupUi(this);
|
2012-09-16 15:14:47 +02:00
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
addApplySaveButtons(ui->saveRCInputToRAM,ui->saveRCInputToSD);
|
2011-02-08 17:49:33 +01:00
|
|
|
|
2012-09-16 15:14:47 +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->saveRCInputToRAM->setVisible(false);
|
2012-09-16 15:14:47 +02:00
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
addApplySaveButtons(ui->saveRCInputToRAM,ui->saveRCInputToSD);
|
2011-08-04 17:58:41 +02:00
|
|
|
|
2012-03-26 17:49:10 +02:00
|
|
|
//Generate the rows of buttons in the input channel form GUI
|
2011-09-11 18:14:09 +02:00
|
|
|
unsigned int index=0;
|
2012-11-17 11:58:16 +01:00
|
|
|
unsigned int indexRT = 0;
|
2012-01-14 20:23:26 +01:00
|
|
|
foreach (QString name, manualSettingsObj->getField("ChannelNumber")->getElementNames())
|
2011-08-04 17:58:41 +02:00
|
|
|
{
|
2011-09-07 01:26:47 +02:00
|
|
|
Q_ASSERT(index < ManualControlSettings::CHANNELGROUPS_NUMELEM);
|
2012-03-26 17:49:10 +02:00
|
|
|
inputChannelForm * inpForm=new inputChannelForm(this,index==0);
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->channelSettings->layout()->addWidget(inpForm); //Add the row to the UI
|
2012-03-26 17:49:10 +02:00
|
|
|
inpForm->setName(name);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelGroups",inpForm->ui->channelGroup,index);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelNumber",inpForm->ui->channelNumber,index);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelMin",inpForm->ui->channelMin,index);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelNeutral",inpForm->ui->channelNeutral,index);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelMax",inpForm->ui->channelMax,index);
|
2013-05-04 00:13:15 +02:00
|
|
|
addWidget(inpForm->ui->channelNumberDropdown);
|
|
|
|
addWidget(inpForm->ui->channelRev);
|
|
|
|
addWidget(inpForm->ui->channelResponseTime);
|
2012-11-17 11:58:16 +01:00
|
|
|
|
|
|
|
// Input filter response time fields supported for some channels only
|
|
|
|
switch (index) {
|
|
|
|
case ManualControlSettings::CHANNELGROUPS_ROLL:
|
|
|
|
case ManualControlSettings::CHANNELGROUPS_PITCH:
|
|
|
|
case ManualControlSettings::CHANNELGROUPS_YAW:
|
|
|
|
case ManualControlSettings::CHANNELGROUPS_ACCESSORY0:
|
|
|
|
case ManualControlSettings::CHANNELGROUPS_ACCESSORY1:
|
|
|
|
case ManualControlSettings::CHANNELGROUPS_ACCESSORY2:
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "ResponseTime", inpForm->ui->channelResponseTime, indexRT);
|
|
|
|
++indexRT;
|
|
|
|
break;
|
2012-12-02 12:50:03 +01:00
|
|
|
case ManualControlSettings::CHANNELGROUPS_THROTTLE:
|
2012-11-17 11:58:16 +01:00
|
|
|
case ManualControlSettings::CHANNELGROUPS_FLIGHTMODE:
|
|
|
|
case ManualControlSettings::CHANNELGROUPS_COLLECTIVE:
|
|
|
|
inpForm->ui->channelResponseTime->setEnabled(false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Q_ASSERT(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-04 17:58:41 +02:00
|
|
|
++index;
|
|
|
|
}
|
2011-09-07 00:48:45 +02:00
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "Deadband", ui->deadband, 0, 0.01f);
|
|
|
|
|
|
|
|
connect(ui->configurationWizard,SIGNAL(clicked()),this,SLOT(goToWizard()));
|
|
|
|
connect(ui->stackedWidget,SIGNAL(currentChanged(int)),this,SLOT(disableWizardButton(int)));
|
|
|
|
connect(ui->runCalibration,SIGNAL(toggled(bool)),this, SLOT(simpleCalibration(bool)));
|
|
|
|
|
|
|
|
connect(ui->wzNext,SIGNAL(clicked()),this,SLOT(wzNext()));
|
|
|
|
connect(ui->wzCancel,SIGNAL(clicked()),this,SLOT(wzCancel()));
|
|
|
|
connect(ui->wzBack,SIGNAL(clicked()),this,SLOT(wzBack()));
|
|
|
|
|
|
|
|
ui->stackedWidget->setCurrentIndex(0);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos1, 0, 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos2, 1, 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos3, 2, 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos4, 3, 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos5, 4, 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModePosition", ui->fmsModePos6, 5, 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "FlightModeNumber", ui->fmsPosNum);
|
|
|
|
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization1Settings", ui->fmsSsPos1Roll, "Roll", 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization2Settings", ui->fmsSsPos2Roll, "Roll", 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization3Settings", ui->fmsSsPos3Roll, "Roll", 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization1Settings", ui->fmsSsPos1Pitch, "Pitch", 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization2Settings", ui->fmsSsPos2Pitch, "Pitch", 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization3Settings", ui->fmsSsPos3Pitch, "Pitch", 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization1Settings", ui->fmsSsPos1Yaw, "Yaw", 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization2Settings", ui->fmsSsPos2Yaw, "Yaw", 1, true);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings", "Stabilization3Settings", ui->fmsSsPos3Yaw, "Yaw", 1, true);
|
|
|
|
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings","Arming",ui->armControl);
|
|
|
|
addUAVObjectToWidgetRelation("ManualControlSettings","ArmedTimeout",ui->armTimeout,0,1000);
|
2011-08-23 12:25:28 +02:00
|
|
|
connect( ManualControlCommand::GetInstance(getObjectManager()),SIGNAL(objectUpdated(UAVObject*)),this,SLOT(moveFMSlider()));
|
2012-06-23 16:14:59 +02:00
|
|
|
connect( ManualControlSettings::GetInstance(getObjectManager()),SIGNAL(objectUpdated(UAVObject*)),this,SLOT(updatePositionSlider()));
|
2013-05-04 00:13:15 +02:00
|
|
|
|
|
|
|
addWidget(ui->configurationWizard);
|
|
|
|
addWidget(ui->runCalibration);
|
2011-08-16 17:06:18 +02:00
|
|
|
|
2011-08-04 17:58:41 +02:00
|
|
|
populateWidgets();
|
|
|
|
refreshWidgetsValues();
|
2011-05-31 09:16:01 +02:00
|
|
|
// Connect the help button
|
2013-05-04 00:13:15 +02:00
|
|
|
connect(ui->inputHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
|
2011-08-16 17:06:18 +02:00
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->graphicsView->setScene(new QGraphicsScene(this));
|
|
|
|
ui->graphicsView->setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
|
2011-08-16 17:06:18 +02:00
|
|
|
m_renderer = new QSvgRenderer();
|
2013-05-04 00:13:15 +02:00
|
|
|
QGraphicsScene *l_scene = ui->graphicsView->scene();
|
|
|
|
ui->graphicsView->setBackgroundBrush(QBrush(Utils::StyleHelper::baseColor()));
|
2012-01-24 23:29:08 +01:00
|
|
|
if (QFile::exists(":/configgadget/images/TX2.svg") && m_renderer->load(QString(":/configgadget/images/TX2.svg")) && m_renderer->isValid())
|
2011-08-16 17:06:18 +02:00
|
|
|
{
|
|
|
|
l_scene->clear(); // Deletes all items contained in the scene as well.
|
|
|
|
|
|
|
|
m_txBackground = new QGraphicsSvgItem();
|
|
|
|
// All other items will be clipped to the shape of the background
|
|
|
|
m_txBackground->setFlags(QGraphicsItem::ItemClipsChildrenToShape|
|
|
|
|
QGraphicsItem::ItemClipsToShape);
|
|
|
|
m_txBackground->setSharedRenderer(m_renderer);
|
|
|
|
m_txBackground->setElementId("background");
|
|
|
|
l_scene->addItem(m_txBackground);
|
|
|
|
|
|
|
|
m_txMainBody = new QGraphicsSvgItem();
|
|
|
|
m_txMainBody->setParentItem(m_txBackground);
|
|
|
|
m_txMainBody->setSharedRenderer(m_renderer);
|
|
|
|
m_txMainBody->setElementId("body");
|
|
|
|
l_scene->addItem(m_txMainBody);
|
|
|
|
|
|
|
|
m_txLeftStick = new QGraphicsSvgItem();
|
|
|
|
m_txLeftStick->setParentItem(m_txBackground);
|
|
|
|
m_txLeftStick->setSharedRenderer(m_renderer);
|
|
|
|
m_txLeftStick->setElementId("ljoy");
|
|
|
|
|
|
|
|
m_txRightStick = new QGraphicsSvgItem();
|
|
|
|
m_txRightStick->setParentItem(m_txBackground);
|
|
|
|
m_txRightStick->setSharedRenderer(m_renderer);
|
|
|
|
m_txRightStick->setElementId("rjoy");
|
|
|
|
|
|
|
|
m_txAccess0 = new QGraphicsSvgItem();
|
|
|
|
m_txAccess0->setParentItem(m_txBackground);
|
|
|
|
m_txAccess0->setSharedRenderer(m_renderer);
|
|
|
|
m_txAccess0->setElementId("access0");
|
|
|
|
|
|
|
|
m_txAccess1 = new QGraphicsSvgItem();
|
|
|
|
m_txAccess1->setParentItem(m_txBackground);
|
|
|
|
m_txAccess1->setSharedRenderer(m_renderer);
|
|
|
|
m_txAccess1->setElementId("access1");
|
|
|
|
|
|
|
|
m_txAccess2 = new QGraphicsSvgItem();
|
|
|
|
m_txAccess2->setParentItem(m_txBackground);
|
|
|
|
m_txAccess2->setSharedRenderer(m_renderer);
|
|
|
|
m_txAccess2->setElementId("access2");
|
|
|
|
|
|
|
|
m_txFlightMode = new QGraphicsSvgItem();
|
|
|
|
m_txFlightMode->setParentItem(m_txBackground);
|
|
|
|
m_txFlightMode->setSharedRenderer(m_renderer);
|
|
|
|
m_txFlightMode->setElementId("flightModeCenter");
|
|
|
|
m_txFlightMode->setZValue(-10);
|
|
|
|
|
|
|
|
m_txArrows = new QGraphicsSvgItem();
|
|
|
|
m_txArrows->setParentItem(m_txBackground);
|
|
|
|
m_txArrows->setSharedRenderer(m_renderer);
|
|
|
|
m_txArrows->setElementId("arrows");
|
|
|
|
m_txArrows->setVisible(false);
|
|
|
|
|
|
|
|
QRectF orig=m_renderer->boundsOnElement("ljoy");
|
|
|
|
QMatrix Matrix = m_renderer->matrixForElement("ljoy");
|
|
|
|
orig=Matrix.mapRect(orig);
|
|
|
|
m_txLeftStickOrig.translate(orig.x(),orig.y());
|
|
|
|
m_txLeftStick->setTransform(m_txLeftStickOrig,false);
|
|
|
|
|
|
|
|
orig=m_renderer->boundsOnElement("arrows");
|
|
|
|
Matrix = m_renderer->matrixForElement("arrows");
|
|
|
|
orig=Matrix.mapRect(orig);
|
|
|
|
m_txArrowsOrig.translate(orig.x(),orig.y());
|
|
|
|
m_txArrows->setTransform(m_txArrowsOrig,false);
|
|
|
|
|
|
|
|
orig=m_renderer->boundsOnElement("body");
|
|
|
|
Matrix = m_renderer->matrixForElement("body");
|
|
|
|
orig=Matrix.mapRect(orig);
|
|
|
|
m_txMainBodyOrig.translate(orig.x(),orig.y());
|
|
|
|
m_txMainBody->setTransform(m_txMainBodyOrig,false);
|
|
|
|
|
|
|
|
orig=m_renderer->boundsOnElement("flightModeCenter");
|
|
|
|
Matrix = m_renderer->matrixForElement("flightModeCenter");
|
|
|
|
orig=Matrix.mapRect(orig);
|
|
|
|
m_txFlightModeCOrig.translate(orig.x(),orig.y());
|
|
|
|
m_txFlightMode->setTransform(m_txFlightModeCOrig,false);
|
|
|
|
|
|
|
|
orig=m_renderer->boundsOnElement("flightModeLeft");
|
|
|
|
Matrix = m_renderer->matrixForElement("flightModeLeft");
|
|
|
|
orig=Matrix.mapRect(orig);
|
|
|
|
m_txFlightModeLOrig.translate(orig.x(),orig.y());
|
|
|
|
orig=m_renderer->boundsOnElement("flightModeRight");
|
|
|
|
Matrix = m_renderer->matrixForElement("flightModeRight");
|
|
|
|
orig=Matrix.mapRect(orig);
|
|
|
|
m_txFlightModeROrig.translate(orig.x(),orig.y());
|
|
|
|
|
|
|
|
orig=m_renderer->boundsOnElement("rjoy");
|
|
|
|
Matrix = m_renderer->matrixForElement("rjoy");
|
|
|
|
orig=Matrix.mapRect(orig);
|
|
|
|
m_txRightStickOrig.translate(orig.x(),orig.y());
|
|
|
|
m_txRightStick->setTransform(m_txRightStickOrig,false);
|
|
|
|
|
|
|
|
orig=m_renderer->boundsOnElement("access0");
|
|
|
|
Matrix = m_renderer->matrixForElement("access0");
|
|
|
|
orig=Matrix.mapRect(orig);
|
|
|
|
m_txAccess0Orig.translate(orig.x(),orig.y());
|
|
|
|
m_txAccess0->setTransform(m_txAccess0Orig,false);
|
|
|
|
|
|
|
|
orig=m_renderer->boundsOnElement("access1");
|
|
|
|
Matrix = m_renderer->matrixForElement("access1");
|
|
|
|
orig=Matrix.mapRect(orig);
|
|
|
|
m_txAccess1Orig.translate(orig.x(),orig.y());
|
|
|
|
m_txAccess1->setTransform(m_txAccess1Orig,false);
|
|
|
|
|
|
|
|
orig=m_renderer->boundsOnElement("access2");
|
|
|
|
Matrix = m_renderer->matrixForElement("access2");
|
|
|
|
orig=Matrix.mapRect(orig);
|
|
|
|
m_txAccess2Orig.translate(orig.x(),orig.y());
|
|
|
|
m_txAccess2->setTransform(m_txAccess2Orig,true);
|
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->graphicsView->fitInView(m_txMainBody, Qt::KeepAspectRatio );
|
2011-08-16 17:06:18 +02:00
|
|
|
animate=new QTimer(this);
|
|
|
|
connect(animate,SIGNAL(timeout()),this,SLOT(moveTxControls()));
|
2011-09-11 18:14:09 +02:00
|
|
|
|
|
|
|
heliChannelOrder << ManualControlSettings::CHANNELGROUPS_COLLECTIVE <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_THROTTLE <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_ROLL <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_PITCH <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_YAW <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_FLIGHTMODE <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_ACCESSORY0 <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_ACCESSORY1 <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_ACCESSORY2;
|
|
|
|
|
|
|
|
acroChannelOrder << ManualControlSettings::CHANNELGROUPS_THROTTLE <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_ROLL <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_PITCH <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_YAW <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_FLIGHTMODE <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_ACCESSORY0 <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_ACCESSORY1 <<
|
|
|
|
ManualControlSettings::CHANNELGROUPS_ACCESSORY2;
|
2013-05-04 00:13:15 +02:00
|
|
|
|
|
|
|
updateEnableControls();
|
2011-08-16 17:06:18 +02:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
|
2011-08-16 17:06:18 +02:00
|
|
|
void ConfigInputWidget::resetTxControls()
|
|
|
|
{
|
|
|
|
|
|
|
|
m_txLeftStick->setTransform(m_txLeftStickOrig,false);
|
|
|
|
m_txRightStick->setTransform(m_txRightStickOrig,false);
|
|
|
|
m_txAccess0->setTransform(m_txAccess0Orig,false);
|
|
|
|
m_txAccess1->setTransform(m_txAccess1Orig,false);
|
|
|
|
m_txAccess2->setTransform(m_txAccess2Orig,false);
|
|
|
|
m_txFlightMode->setElementId("flightModeCenter");
|
|
|
|
m_txFlightMode->setTransform(m_txFlightModeCOrig,false);
|
|
|
|
m_txArrows->setVisible(false);
|
2011-02-08 17:49:33 +01:00
|
|
|
}
|
|
|
|
|
2011-03-28 17:39:22 +02:00
|
|
|
ConfigInputWidget::~ConfigInputWidget()
|
2011-02-08 17:49:33 +01:00
|
|
|
{
|
2011-08-10 16:24:35 +02:00
|
|
|
|
2011-02-28 17:44:04 +01:00
|
|
|
}
|
2011-05-31 09:16:01 +02:00
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
void ConfigInputWidget::enableControls(bool enable)
|
|
|
|
{
|
|
|
|
ConfigTaskWidget::enableControls(enable);
|
|
|
|
|
|
|
|
if(enable) {
|
|
|
|
updatePositionSlider();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-16 17:06:18 +02:00
|
|
|
void ConfigInputWidget::resizeEvent(QResizeEvent *event)
|
|
|
|
{
|
|
|
|
QWidget::resizeEvent(event);
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->graphicsView->fitInView(m_txBackground, Qt::KeepAspectRatio );
|
2011-08-16 17:06:18 +02:00
|
|
|
}
|
|
|
|
|
2011-05-31 09:16:01 +02:00
|
|
|
void ConfigInputWidget::openHelp()
|
|
|
|
{
|
2012-09-16 15:14:47 +02:00
|
|
|
QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/x/04Cf", QUrl::StrictMode) );
|
2011-05-31 09:16:01 +02:00
|
|
|
}
|
2012-10-01 21:50:00 +02:00
|
|
|
|
2011-08-10 16:24:35 +02:00
|
|
|
void ConfigInputWidget::goToWizard()
|
|
|
|
{
|
2011-08-20 20:10:28 +02:00
|
|
|
QMessageBox msgBox;
|
2012-10-19 12:00:42 +02:00
|
|
|
msgBox.setText(tr("Arming Settings are now set to 'Always Disarmed' for your safety."));
|
2012-09-30 17:27:20 +02:00
|
|
|
msgBox.setDetailedText(tr("You will have to reconfigure the arming settings manually "
|
|
|
|
"when the wizard is finished. After the last step of the "
|
|
|
|
"wizard you will be taken to the Arming Settings screen."));
|
2011-08-20 20:10:28 +02:00
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
|
|
msgBox.exec();
|
2012-09-30 14:19:31 +02:00
|
|
|
|
2012-09-30 14:24:54 +02:00
|
|
|
// Set correct tab visible before starting wizard.
|
2013-05-04 00:13:15 +02:00
|
|
|
if(ui->tabWidget->currentIndex() != 0) {
|
|
|
|
ui->tabWidget->setCurrentIndex(0);
|
2012-09-30 14:24:54 +02:00
|
|
|
}
|
2012-10-19 12:00:42 +02:00
|
|
|
|
|
|
|
// Stash current manual settings data in case the wizard is
|
|
|
|
// cancelled or the user proceeds far enough into the wizard such
|
|
|
|
// that the UAVO is changed, but then backs out to the start and
|
|
|
|
// chooses a different TX type (which could otherwise result in
|
|
|
|
// unexpected TX channels being enabled)
|
|
|
|
manualSettingsData=manualSettingsObj->getData();
|
|
|
|
previousManualSettingsData = manualSettingsData;
|
|
|
|
manualSettingsData.Arming=ManualControlSettings::ARMING_ALWAYSDISARMED;
|
|
|
|
manualSettingsObj->setData(manualSettingsData);
|
|
|
|
|
|
|
|
// start the wizard
|
2011-09-11 18:14:09 +02:00
|
|
|
wizardSetUpStep(wizardWelcome);
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->graphicsView->fitInView(m_txBackground, Qt::KeepAspectRatio);
|
2011-08-10 16:24:35 +02:00
|
|
|
}
|
|
|
|
|
2012-09-16 15:14:47 +02:00
|
|
|
void ConfigInputWidget::disableWizardButton(int value)
|
|
|
|
{
|
|
|
|
if(value!=0)
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->groupBox_3->setVisible(false);
|
2012-09-16 15:14:47 +02:00
|
|
|
else
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->groupBox_3->setVisible(true);
|
2012-09-16 15:14:47 +02:00
|
|
|
}
|
|
|
|
|
2011-08-10 16:24:35 +02:00
|
|
|
void ConfigInputWidget::wzCancel()
|
|
|
|
{
|
2011-08-17 13:43:08 +02:00
|
|
|
dimOtherControls(false);
|
2011-08-16 17:06:18 +02:00
|
|
|
manualCommandObj->setMetadata(manualCommandObj->getDefaultMetadata());
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->stackedWidget->setCurrentIndex(0);
|
2011-09-11 18:14:09 +02:00
|
|
|
|
|
|
|
if(wizardStep != wizardNone)
|
|
|
|
wizardTearDownStep(wizardStep);
|
|
|
|
wizardStep=wizardNone;
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->stackedWidget->setCurrentIndex(0);
|
2011-09-11 18:14:09 +02:00
|
|
|
|
|
|
|
// Load settings back from beginning of wizard
|
|
|
|
manualSettingsObj->setData(previousManualSettingsData);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigInputWidget::wzNext()
|
|
|
|
{
|
|
|
|
// In identify sticks mode the next button can indicate
|
|
|
|
// channel advance
|
|
|
|
if(wizardStep != wizardNone &&
|
|
|
|
wizardStep != wizardIdentifySticks)
|
|
|
|
wizardTearDownStep(wizardStep);
|
|
|
|
|
|
|
|
// State transitions for next button
|
|
|
|
switch(wizardStep) {
|
2011-08-10 16:24:35 +02:00
|
|
|
case wizardWelcome:
|
2011-09-11 18:14:09 +02:00
|
|
|
wizardSetUpStep(wizardChooseType);
|
|
|
|
break;
|
2011-09-07 16:09:41 +02:00
|
|
|
case wizardChooseType:
|
2012-10-19 12:00:42 +02:00
|
|
|
wizardSetUpStep(wizardChooseMode);
|
|
|
|
break;
|
|
|
|
case wizardChooseMode:
|
2011-09-11 18:14:09 +02:00
|
|
|
wizardSetUpStep(wizardIdentifySticks);
|
2011-08-10 16:24:35 +02:00
|
|
|
break;
|
|
|
|
case wizardIdentifySticks:
|
2011-09-11 18:14:09 +02:00
|
|
|
nextChannel();
|
|
|
|
if(currentChannelNum==-1) { // Gone through all channels
|
|
|
|
wizardTearDownStep(wizardIdentifySticks);
|
|
|
|
wizardSetUpStep(wizardIdentifyCenter);
|
|
|
|
}
|
2011-08-10 16:24:35 +02:00
|
|
|
break;
|
|
|
|
case wizardIdentifyCenter:
|
2011-09-11 18:14:09 +02:00
|
|
|
wizardSetUpStep(wizardIdentifyLimits);
|
2011-08-10 16:24:35 +02:00
|
|
|
break;
|
|
|
|
case wizardIdentifyLimits:
|
2011-09-11 18:14:09 +02:00
|
|
|
wizardSetUpStep(wizardIdentifyInverted);
|
2011-08-10 16:24:35 +02:00
|
|
|
break;
|
|
|
|
case wizardIdentifyInverted:
|
2011-09-11 18:14:09 +02:00
|
|
|
wizardSetUpStep(wizardFinish);
|
2011-08-10 16:24:35 +02:00
|
|
|
break;
|
|
|
|
case wizardFinish:
|
2011-09-11 18:14:09 +02:00
|
|
|
wizardStep=wizardNone;
|
2012-10-19 12:00:42 +02:00
|
|
|
// Leave setting the throttle neutral until the final Next press,
|
|
|
|
// else the throttle scaling causes the graphical stick movement to not
|
|
|
|
// match the tx stick
|
|
|
|
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_THROTTLE]=
|
|
|
|
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE]+
|
|
|
|
((manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_THROTTLE]-
|
|
|
|
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE])*0.02);
|
|
|
|
if((abs(manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE] -
|
|
|
|
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE])<100) ||
|
|
|
|
(abs(manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE] -
|
|
|
|
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE])<100))
|
|
|
|
{
|
|
|
|
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE]=
|
|
|
|
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE]+
|
|
|
|
(manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE] -
|
|
|
|
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE])/2;
|
|
|
|
}
|
|
|
|
manualSettingsObj->setData(manualSettingsData);
|
|
|
|
// move to Arming Settings tab
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->stackedWidget->setCurrentIndex(0);
|
|
|
|
ui->tabWidget->setCurrentIndex(2);
|
2011-08-10 16:24:35 +02:00
|
|
|
break;
|
|
|
|
default:
|
2011-09-11 18:14:09 +02:00
|
|
|
Q_ASSERT(0);
|
2011-08-10 16:24:35 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigInputWidget::wzBack()
|
|
|
|
{
|
2011-09-11 18:14:09 +02:00
|
|
|
if(wizardStep != wizardNone &&
|
|
|
|
wizardStep != wizardIdentifySticks)
|
|
|
|
wizardTearDownStep(wizardStep);
|
|
|
|
|
|
|
|
// State transitions for next button
|
|
|
|
switch(wizardStep) {
|
2012-10-19 12:00:42 +02:00
|
|
|
case wizardChooseType:
|
2011-09-11 18:14:09 +02:00
|
|
|
wizardSetUpStep(wizardWelcome);
|
|
|
|
break;
|
2012-10-19 12:00:42 +02:00
|
|
|
case wizardChooseMode:
|
|
|
|
wizardSetUpStep(wizardChooseType);
|
2011-09-11 18:14:09 +02:00
|
|
|
break;
|
|
|
|
case wizardIdentifySticks:
|
|
|
|
prevChannel();
|
|
|
|
if(currentChannelNum == -1) {
|
|
|
|
wizardTearDownStep(wizardIdentifySticks);
|
2012-10-19 12:00:42 +02:00
|
|
|
wizardSetUpStep(wizardChooseMode);
|
2011-09-11 18:14:09 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case wizardIdentifyCenter:
|
|
|
|
wizardSetUpStep(wizardIdentifySticks);
|
|
|
|
break;
|
|
|
|
case wizardIdentifyLimits:
|
|
|
|
wizardSetUpStep(wizardIdentifyCenter);
|
|
|
|
break;
|
|
|
|
case wizardIdentifyInverted:
|
|
|
|
wizardSetUpStep(wizardIdentifyLimits);
|
|
|
|
break;
|
|
|
|
case wizardFinish:
|
|
|
|
wizardSetUpStep(wizardIdentifyInverted);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Q_ASSERT(0);
|
|
|
|
}
|
2011-08-10 16:24:35 +02:00
|
|
|
}
|
|
|
|
|
2011-09-11 18:14:09 +02:00
|
|
|
void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
|
2011-08-10 16:24:35 +02:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText2->clear();
|
2012-10-19 12:00:42 +02:00
|
|
|
|
2011-09-11 18:14:09 +02:00
|
|
|
switch(step) {
|
|
|
|
case wizardWelcome:
|
2012-09-16 15:14:47 +02:00
|
|
|
foreach(QPointer<QWidget> wd,extraWidgets)
|
|
|
|
{
|
|
|
|
if(!wd.isNull())
|
|
|
|
delete wd;
|
|
|
|
}
|
|
|
|
extraWidgets.clear();
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->graphicsView->setVisible(false);
|
2011-08-16 17:06:18 +02:00
|
|
|
setTxMovement(nothing);
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText->setText(tr("Welcome to the inputs configuration wizard.\n\n"
|
2011-08-20 20:10:28 +02:00
|
|
|
"Please follow the instructions on the screen and only move your controls when asked to.\n"
|
2012-10-19 12:00:42 +02:00
|
|
|
"Make sure you already configured your hardware settings on the proper tab and restarted your board.\n\n"
|
|
|
|
"You can press 'back' at any time to return to the previous screen or press 'Cancel' to quit the wizard.\n"));
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->stackedWidget->setCurrentIndex(1);
|
|
|
|
ui->wzBack->setEnabled(false);
|
2011-09-11 18:14:09 +02:00
|
|
|
break;
|
2012-10-19 12:00:42 +02:00
|
|
|
case wizardChooseType:
|
2011-08-10 16:24:35 +02:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->graphicsView->setVisible(true);
|
|
|
|
ui->graphicsView->fitInView(m_txBackground, Qt::KeepAspectRatio);
|
2011-08-16 17:06:18 +02:00
|
|
|
setTxMovement(nothing);
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText->setText(tr("Please choose your transmitter type:"));
|
|
|
|
ui->wzBack->setEnabled(true);
|
2012-10-19 12:00:42 +02:00
|
|
|
QRadioButton * typeAcro=new QRadioButton(tr("Acro: normal transmitter for fixed-wing or quad"),this);
|
|
|
|
QRadioButton * typeHeli=new QRadioButton(tr("Helicopter: has collective pitch and throttle input"),this);
|
|
|
|
if (transmitterType == heli) {
|
|
|
|
typeHeli->setChecked(true);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
typeAcro->setChecked(true);
|
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText2->setText(tr("If selecting the Helicopter option, please engage throttle hold now."));
|
2012-10-19 12:00:42 +02:00
|
|
|
|
2011-08-10 16:24:35 +02:00
|
|
|
extraWidgets.clear();
|
2012-10-19 12:00:42 +02:00
|
|
|
extraWidgets.append(typeAcro);
|
|
|
|
extraWidgets.append(typeHeli);
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->radioButtonsLayout->layout()->addWidget(typeAcro);
|
|
|
|
ui->radioButtonsLayout->layout()->addWidget(typeHeli);
|
2011-08-10 16:24:35 +02:00
|
|
|
}
|
2011-09-11 18:14:09 +02:00
|
|
|
break;
|
2012-10-19 12:00:42 +02:00
|
|
|
case wizardChooseMode:
|
2011-08-10 16:24:35 +02:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzBack->setEnabled(true);
|
2011-09-07 16:09:41 +02:00
|
|
|
extraWidgets.clear();
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText->setText(tr("Please choose your transmitter mode:"));
|
2012-10-19 12:00:42 +02:00
|
|
|
for (int i = 0; i <= mode4; ++i) {
|
|
|
|
QString label;
|
|
|
|
txMode mode = static_cast<txMode>(i);
|
|
|
|
if (transmitterType == heli) {
|
|
|
|
switch (mode) {
|
|
|
|
case mode1: label = tr("Mode 1: Fore/Aft Cyclic and Yaw on the left, Throttle/Collective and Left/Right Cyclic on the right"); break;
|
|
|
|
case mode2: label = tr("Mode 2: Throttle/Collective and Yaw on the left, Cyclic on the right"); break;
|
|
|
|
case mode3: label = tr("Mode 3: Cyclic on the left, Throttle/Collective and Yaw on the right"); break;
|
|
|
|
case mode4: label = tr("Mode 4: Throttle/Collective and Left/Right Cyclic on the left, Fore/Aft Cyclic and Yaw on the right"); break;
|
|
|
|
default: Q_ASSERT(0); break;
|
|
|
|
} }
|
|
|
|
else {
|
|
|
|
switch (mode) {
|
|
|
|
case mode1: label = tr("Mode 1: Elevator and Rudder on the left, Throttle and Ailerons on the right"); break;
|
|
|
|
case mode2: label = tr("Mode 2: Throttle and Rudder on the left, Elevator and Ailerons on the right"); break;
|
|
|
|
case mode3: label = tr("Mode 3: Elevator and Ailerons on the left, Throttle and Rudder on the right"); break;
|
|
|
|
case mode4: label = tr("Mode 4: Throttle and Ailerons on the left, Elevator and Rudder on the right"); break;
|
|
|
|
default: Q_ASSERT(0); break;
|
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText2->setText(tr("For a Quad: Elevator is Pitch, Ailerons are Roll, and Rudder is Yaw."));
|
2012-10-19 12:00:42 +02:00
|
|
|
}
|
|
|
|
QRadioButton * modeButton = new QRadioButton(label, this);
|
|
|
|
if (transmitterMode == mode) {
|
|
|
|
modeButton->setChecked(true);
|
|
|
|
}
|
|
|
|
extraWidgets.append(modeButton);
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->radioButtonsLayout->layout()->addWidget(modeButton);
|
2012-10-19 12:00:42 +02:00
|
|
|
}
|
2011-09-11 18:14:09 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case wizardIdentifySticks:
|
2011-09-07 16:09:41 +02:00
|
|
|
usedChannels.clear();
|
2011-09-11 18:14:09 +02:00
|
|
|
currentChannelNum=-1;
|
|
|
|
nextChannel();
|
2011-08-10 16:24:35 +02:00
|
|
|
manualSettingsData=manualSettingsObj->getData();
|
|
|
|
connect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzNext->setEnabled(false);
|
2011-09-11 18:14:09 +02:00
|
|
|
break;
|
|
|
|
case wizardIdentifyCenter:
|
2011-08-16 17:06:18 +02:00
|
|
|
setTxMovement(centerAll);
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText->setText(QString(tr("Please center all controls and trims and press Next when ready.\n\n"
|
2012-10-19 12:00:42 +02:00
|
|
|
"If your FlightMode switch has only two positions, leave it in either position.")));
|
2011-09-11 18:14:09 +02:00
|
|
|
break;
|
|
|
|
case wizardIdentifyLimits:
|
2011-08-10 16:24:35 +02:00
|
|
|
{
|
2012-09-16 15:14:47 +02:00
|
|
|
accessoryDesiredObj0 = AccessoryDesired::GetInstance(getObjectManager(),0);
|
|
|
|
accessoryDesiredObj1 = AccessoryDesired::GetInstance(getObjectManager(),1);
|
|
|
|
accessoryDesiredObj2 = AccessoryDesired::GetInstance(getObjectManager(),2);
|
2011-10-27 05:04:24 +02:00
|
|
|
setTxMovement(nothing);
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText->setText(QString(tr("Please move all controls to their maximum extents on both directions.\n\nPress Next when ready.")));
|
2011-09-11 18:14:09 +02:00
|
|
|
fastMdata();
|
2011-08-10 16:24:35 +02:00
|
|
|
manualSettingsData=manualSettingsObj->getData();
|
2011-08-23 12:25:28 +02:00
|
|
|
for(uint i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
|
2011-08-10 16:24:35 +02:00
|
|
|
{
|
2011-11-25 19:30:17 +01:00
|
|
|
// Preserve the inverted status
|
|
|
|
if(manualSettingsData.ChannelMin[i] <= manualSettingsData.ChannelMax[i]) {
|
|
|
|
manualSettingsData.ChannelMin[i]=manualSettingsData.ChannelNeutral[i];
|
|
|
|
manualSettingsData.ChannelMax[i]=manualSettingsData.ChannelNeutral[i];
|
|
|
|
} else {
|
|
|
|
// Make this detect as still inverted
|
|
|
|
manualSettingsData.ChannelMin[i]=manualSettingsData.ChannelNeutral[i] + 1;
|
|
|
|
manualSettingsData.ChannelMax[i]=manualSettingsData.ChannelNeutral[i];
|
|
|
|
}
|
2011-08-10 16:24:35 +02:00
|
|
|
}
|
|
|
|
connect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyLimits()));
|
2011-10-27 05:04:24 +02:00
|
|
|
connect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
2012-09-16 15:14:47 +02:00
|
|
|
connect(flightStatusObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
|
|
|
connect(accessoryDesiredObj0, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
2011-08-10 16:24:35 +02:00
|
|
|
}
|
2011-09-11 18:14:09 +02:00
|
|
|
break;
|
|
|
|
case wizardIdentifyInverted:
|
2011-08-17 13:43:08 +02:00
|
|
|
dimOtherControls(true);
|
2011-08-16 17:06:18 +02:00
|
|
|
setTxMovement(nothing);
|
2011-08-10 16:24:35 +02:00
|
|
|
extraWidgets.clear();
|
2011-11-25 19:30:17 +01:00
|
|
|
for (int index = 0; index < manualSettingsObj->getField("ChannelMax")->getElementNames().length(); index++)
|
2011-08-10 16:24:35 +02:00
|
|
|
{
|
2011-11-25 19:30:17 +01:00
|
|
|
QString name = manualSettingsObj->getField("ChannelMax")->getElementNames().at(index);
|
2012-10-19 12:00:42 +02:00
|
|
|
if(!name.contains("Access") && !name.contains("Flight") &&
|
|
|
|
(!name.contains("Collective") || transmitterType == heli))
|
2011-08-16 17:06:18 +02:00
|
|
|
{
|
|
|
|
QCheckBox * cb=new QCheckBox(name,this);
|
2011-11-25 19:30:17 +01:00
|
|
|
// Make sure checked status matches current one
|
|
|
|
cb->setChecked(manualSettingsData.ChannelMax[index] < manualSettingsData.ChannelMin[index]);
|
2013-05-04 00:13:15 +02:00
|
|
|
dynamic_cast<QGridLayout*>(ui->checkBoxesLayout->layout())->addWidget(cb, extraWidgets.size()/4, extraWidgets.size()%4);
|
2011-08-16 17:06:18 +02:00
|
|
|
extraWidgets.append(cb);
|
2011-08-20 20:10:28 +02:00
|
|
|
connect(cb,SIGNAL(toggled(bool)),this,SLOT(invertControls()));
|
2011-08-16 17:06:18 +02:00
|
|
|
}
|
2011-08-10 16:24:35 +02:00
|
|
|
}
|
2011-08-16 17:06:18 +02:00
|
|
|
connect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText->setText(QString(tr("Please check the picture below and correct all the sticks which show an inverted movement. Press Next when ready.")));
|
2011-09-11 18:14:09 +02:00
|
|
|
fastMdata();
|
|
|
|
break;
|
|
|
|
case wizardFinish:
|
2012-09-16 15:14:47 +02:00
|
|
|
dimOtherControls(false);
|
2011-09-11 18:14:09 +02:00
|
|
|
connect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
2012-09-16 15:14:47 +02:00
|
|
|
connect(flightStatusObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
|
|
|
connect(accessoryDesiredObj0, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText->setText(QString(tr("You have completed this wizard, please check below if the picture mimics your sticks movement.\n\n"
|
2012-10-19 12:00:42 +02:00
|
|
|
"IMPORTANT: These new settings have not been saved to the board yet. After pressing Next you will go to the Arming Settings "
|
|
|
|
"tab where you can set your desired arming sequence and save the configuration.")));
|
2011-09-11 18:14:09 +02:00
|
|
|
fastMdata();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Q_ASSERT(0);
|
|
|
|
}
|
|
|
|
wizardStep = step;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigInputWidget::wizardTearDownStep(enum wizardSteps step)
|
|
|
|
{
|
|
|
|
QRadioButton * mode, * type;
|
|
|
|
Q_ASSERT(step == wizardStep);
|
|
|
|
switch(step) {
|
|
|
|
case wizardWelcome:
|
|
|
|
break;
|
2012-10-19 12:00:42 +02:00
|
|
|
case wizardChooseType:
|
2011-09-11 18:14:09 +02:00
|
|
|
type=qobject_cast<QRadioButton *>(extraWidgets.at(0));
|
|
|
|
if(type->isChecked())
|
|
|
|
transmitterType=acro;
|
|
|
|
else
|
|
|
|
transmitterType=heli;
|
|
|
|
delete extraWidgets.at(0);
|
|
|
|
delete extraWidgets.at(1);
|
|
|
|
extraWidgets.clear();
|
|
|
|
break;
|
2012-10-19 12:00:42 +02:00
|
|
|
case wizardChooseMode:
|
|
|
|
for (int i = mode1; i <= mode4; ++i) {
|
|
|
|
mode=qobject_cast<QRadioButton *>(extraWidgets.first());
|
|
|
|
if(mode->isChecked()) {
|
|
|
|
transmitterMode=static_cast<txMode>(i);
|
|
|
|
}
|
|
|
|
delete mode;
|
|
|
|
extraWidgets.removeFirst();
|
|
|
|
}
|
|
|
|
break;
|
2011-09-11 18:14:09 +02:00
|
|
|
case wizardIdentifySticks:
|
|
|
|
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyControls()));
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzNext->setEnabled(true);
|
2011-11-25 18:23:56 +01:00
|
|
|
setTxMovement(nothing);
|
2011-09-11 18:14:09 +02:00
|
|
|
break;
|
|
|
|
case wizardIdentifyCenter:
|
|
|
|
manualCommandData=manualCommandObj->getData();
|
|
|
|
manualSettingsData=manualSettingsObj->getData();
|
|
|
|
for(unsigned int i=0;i<ManualControlCommand::CHANNEL_NUMELEM;++i)
|
|
|
|
{
|
|
|
|
manualSettingsData.ChannelNeutral[i]=manualCommandData.Channel[i];
|
|
|
|
}
|
|
|
|
manualSettingsObj->setData(manualSettingsData);
|
2011-11-25 18:23:56 +01:00
|
|
|
setTxMovement(nothing);
|
2011-09-11 18:14:09 +02:00
|
|
|
break;
|
|
|
|
case wizardIdentifyLimits:
|
|
|
|
disconnect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(identifyLimits()));
|
2011-10-27 05:04:24 +02:00
|
|
|
disconnect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
2012-09-16 15:14:47 +02:00
|
|
|
disconnect(flightStatusObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
|
|
|
disconnect(accessoryDesiredObj0, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
2011-09-11 18:14:09 +02:00
|
|
|
manualSettingsObj->setData(manualSettingsData);
|
|
|
|
restoreMdata();
|
2011-11-25 18:23:56 +01:00
|
|
|
setTxMovement(nothing);
|
2011-09-11 18:14:09 +02:00
|
|
|
break;
|
|
|
|
case wizardIdentifyInverted:
|
2011-11-25 18:23:56 +01:00
|
|
|
dimOtherControls(false);
|
2011-09-11 18:14:09 +02:00
|
|
|
foreach(QWidget * wd,extraWidgets)
|
|
|
|
{
|
|
|
|
QCheckBox * cb=qobject_cast<QCheckBox *>(wd);
|
|
|
|
if(cb)
|
|
|
|
{
|
|
|
|
disconnect(cb,SIGNAL(toggled(bool)),this,SLOT(invertControls()));
|
|
|
|
delete cb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
extraWidgets.clear();
|
|
|
|
disconnect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
|
|
|
restoreMdata();
|
|
|
|
break;
|
|
|
|
case wizardFinish:
|
2011-11-25 18:23:56 +01:00
|
|
|
dimOtherControls(false);
|
2011-09-11 18:14:09 +02:00
|
|
|
setTxMovement(nothing);
|
|
|
|
disconnect(manualCommandObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
2012-09-16 15:14:47 +02:00
|
|
|
disconnect(flightStatusObj, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
|
|
|
disconnect(accessoryDesiredObj0, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(moveSticks()));
|
2011-09-11 18:14:09 +02:00
|
|
|
restoreMdata();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Q_ASSERT(0);
|
2011-08-10 16:24:35 +02:00
|
|
|
}
|
2011-09-11 18:14:09 +02:00
|
|
|
}
|
2011-08-10 16:24:35 +02:00
|
|
|
|
2011-09-11 18:14:09 +02:00
|
|
|
/**
|
|
|
|
* Set manual control command to fast updates
|
|
|
|
*/
|
|
|
|
void ConfigInputWidget::fastMdata()
|
|
|
|
{
|
|
|
|
manualControlMdata = manualCommandObj->getMetadata();
|
|
|
|
UAVObject::Metadata mdata = manualControlMdata;
|
2012-03-31 16:59:44 +02:00
|
|
|
UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_PERIODIC);
|
2011-09-11 18:14:09 +02:00
|
|
|
mdata.flightTelemetryUpdatePeriod = 150;
|
|
|
|
manualCommandObj->setMetadata(mdata);
|
2011-08-10 16:24:35 +02:00
|
|
|
}
|
|
|
|
|
2011-09-07 16:09:41 +02:00
|
|
|
/**
|
2011-09-11 18:14:09 +02:00
|
|
|
* Restore previous update settings for manual control data
|
2011-09-07 16:09:41 +02:00
|
|
|
*/
|
2011-09-11 18:14:09 +02:00
|
|
|
void ConfigInputWidget::restoreMdata()
|
2011-09-07 16:09:41 +02:00
|
|
|
{
|
2011-09-11 18:14:09 +02:00
|
|
|
manualCommandObj->setMetadata(manualControlMdata);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the display to indicate which channel the person should move
|
|
|
|
*/
|
|
|
|
void ConfigInputWidget::setChannel(int newChan)
|
|
|
|
{
|
|
|
|
if(newChan == ManualControlSettings::CHANNELGROUPS_COLLECTIVE)
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText->setText(QString(tr("Please enable throttle hold mode.\n\nMove the Collective Pitch stick.")));
|
2011-09-11 18:14:09 +02:00
|
|
|
else if (newChan == ManualControlSettings::CHANNELGROUPS_FLIGHTMODE)
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText->setText(QString(tr("Please toggle the Flight Mode switch.\n\nFor switches you may have to repeat this rapidly.")));
|
2012-01-04 18:13:54 +01:00
|
|
|
else if((transmitterType == heli) && (newChan == ManualControlSettings::CHANNELGROUPS_THROTTLE))
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText->setText(QString(tr("Please disable throttle hold mode.\n\nMove the Throttle stick.")));
|
2011-09-07 16:09:41 +02:00
|
|
|
else
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzText->setText(QString(tr("Please move each control one at a time according to the instructions and picture below.\n\n"
|
2012-10-19 12:00:42 +02:00
|
|
|
"Move the %1 stick.")).arg(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan)));
|
2011-09-11 18:14:09 +02:00
|
|
|
|
2012-06-25 00:52:06 +02:00
|
|
|
if(manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan).contains("Accessory") ||
|
|
|
|
manualSettingsObj->getField("ChannelGroups")->getElementNames().at(newChan).contains("FlightMode")) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzNext->setEnabled(true);
|
|
|
|
ui->wzText->setText(ui->wzText->text() + tr(" Alternatively, click Next to skip this channel."));
|
2011-10-20 15:26:46 +02:00
|
|
|
} else
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->wzNext->setEnabled(false);
|
2011-09-11 18:14:09 +02:00
|
|
|
|
|
|
|
setMoveFromCommand(newChan);
|
|
|
|
|
|
|
|
currentChannelNum = newChan;
|
2011-10-20 15:26:46 +02:00
|
|
|
channelDetected = false;
|
2011-09-11 18:14:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unfortunately order of channel should be different in different conditions. Selects
|
|
|
|
* next channel based on heli or acro mode
|
|
|
|
*/
|
|
|
|
void ConfigInputWidget::nextChannel()
|
|
|
|
{
|
|
|
|
QList <int> order = (transmitterType == heli) ? heliChannelOrder : acroChannelOrder;
|
2011-09-07 16:09:41 +02:00
|
|
|
|
2011-09-11 18:14:09 +02:00
|
|
|
if(currentChannelNum == -1) {
|
|
|
|
setChannel(order[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < order.length() - 1; i++) {
|
|
|
|
if(order[i] == currentChannelNum) {
|
|
|
|
setChannel(order[i+1]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
currentChannelNum = -1; // hit end of list
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unfortunately order of channel should be different in different conditions. Selects
|
|
|
|
* previous channel based on heli or acro mode
|
|
|
|
*/
|
|
|
|
void ConfigInputWidget::prevChannel()
|
|
|
|
{
|
|
|
|
QList <int> order = transmitterType == heli ? heliChannelOrder : acroChannelOrder;
|
|
|
|
|
|
|
|
// No previous from unset channel or next state
|
|
|
|
if(currentChannelNum == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (int i = 1; i < order.length(); i++) {
|
|
|
|
if(order[i] == currentChannelNum) {
|
2012-10-19 12:00:42 +02:00
|
|
|
if (!usedChannels.isEmpty() &&
|
|
|
|
usedChannels.back().channelIndex == currentChannelNum) {
|
|
|
|
usedChannels.removeLast();
|
|
|
|
}
|
2011-09-11 18:14:09 +02:00
|
|
|
setChannel(order[i-1]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
currentChannelNum = -1; // hit end of list
|
2011-09-07 16:09:41 +02:00
|
|
|
}
|
|
|
|
|
2011-08-10 16:24:35 +02:00
|
|
|
void ConfigInputWidget::identifyControls()
|
|
|
|
{
|
|
|
|
static int debounce=0;
|
2011-09-07 16:09:41 +02:00
|
|
|
|
2011-08-10 16:24:35 +02:00
|
|
|
receiverActivityData=receiverActivityObj->getData();
|
|
|
|
if(receiverActivityData.ActiveChannel==255)
|
|
|
|
return;
|
2011-10-20 15:26:46 +02:00
|
|
|
if(channelDetected)
|
|
|
|
return;
|
2011-08-10 16:24:35 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
receiverActivityData=receiverActivityObj->getData();
|
|
|
|
currentChannel.group=receiverActivityData.ActiveGroup;
|
|
|
|
currentChannel.number=receiverActivityData.ActiveChannel;
|
|
|
|
if(currentChannel==lastChannel)
|
|
|
|
++debounce;
|
|
|
|
lastChannel.group= currentChannel.group;
|
|
|
|
lastChannel.number=currentChannel.number;
|
2012-10-19 12:00:42 +02:00
|
|
|
lastChannel.channelIndex = currentChannelNum;
|
2011-08-24 14:49:34 +02:00
|
|
|
if(!usedChannels.contains(lastChannel) && debounce>1)
|
2011-08-10 16:24:35 +02:00
|
|
|
{
|
2011-10-20 15:26:46 +02:00
|
|
|
channelDetected = true;
|
2011-08-10 16:24:35 +02:00
|
|
|
debounce=0;
|
|
|
|
usedChannels.append(lastChannel);
|
|
|
|
manualSettingsData=manualSettingsObj->getData();
|
2011-09-11 18:14:09 +02:00
|
|
|
manualSettingsData.ChannelGroups[currentChannelNum]=currentChannel.group;
|
|
|
|
manualSettingsData.ChannelNumber[currentChannelNum]=currentChannel.number;
|
2011-08-10 16:24:35 +02:00
|
|
|
manualSettingsObj->setData(manualSettingsData);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
2011-09-11 18:14:09 +02:00
|
|
|
|
2012-10-19 12:00:42 +02:00
|
|
|
//m_config->wzText->clear();
|
2011-09-11 18:14:09 +02:00
|
|
|
setTxMovement(nothing);
|
|
|
|
|
2012-01-31 18:24:19 +01:00
|
|
|
QTimer::singleShot(2500, this, SLOT(wzNext()));
|
2011-08-10 16:24:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigInputWidget::identifyLimits()
|
|
|
|
{
|
|
|
|
manualCommandData=manualCommandObj->getData();
|
2011-08-23 12:25:28 +02:00
|
|
|
for(uint i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
|
2011-08-10 16:24:35 +02:00
|
|
|
{
|
2011-11-25 19:30:17 +01:00
|
|
|
if(manualSettingsData.ChannelMin[i] <= manualSettingsData.ChannelMax[i]) {
|
|
|
|
// Non inverted channel
|
|
|
|
if(manualSettingsData.ChannelMin[i]>manualCommandData.Channel[i])
|
|
|
|
manualSettingsData.ChannelMin[i]=manualCommandData.Channel[i];
|
|
|
|
if(manualSettingsData.ChannelMax[i]<manualCommandData.Channel[i])
|
|
|
|
manualSettingsData.ChannelMax[i]=manualCommandData.Channel[i];
|
|
|
|
} else {
|
|
|
|
// Inverted channel
|
|
|
|
if(manualSettingsData.ChannelMax[i]>manualCommandData.Channel[i])
|
|
|
|
manualSettingsData.ChannelMax[i]=manualCommandData.Channel[i];
|
|
|
|
if(manualSettingsData.ChannelMin[i]<manualCommandData.Channel[i])
|
|
|
|
manualSettingsData.ChannelMin[i]=manualCommandData.Channel[i];
|
|
|
|
}
|
2011-08-10 16:24:35 +02:00
|
|
|
}
|
2011-10-27 05:04:24 +02:00
|
|
|
manualSettingsObj->setData(manualSettingsData);
|
2011-08-10 16:24:35 +02:00
|
|
|
}
|
2011-08-16 17:06:18 +02:00
|
|
|
void ConfigInputWidget::setMoveFromCommand(int command)
|
|
|
|
{
|
2012-10-19 12:00:42 +02:00
|
|
|
// ManualControlSettings::ChannelNumberElem:
|
|
|
|
// CHANNELNUMBER_ROLL=0,
|
|
|
|
// CHANNELNUMBER_PITCH=1,
|
|
|
|
// CHANNELNUMBER_YAW=2,
|
|
|
|
// CHANNELNUMBER_THROTTLE=3,
|
|
|
|
// CHANNELNUMBER_FLIGHTMODE=4,
|
|
|
|
// CHANNELNUMBER_ACCESSORY0=5,
|
|
|
|
// CHANNELNUMBER_ACCESSORY1=6,
|
|
|
|
// CHANNELNUMBER_ACCESSORY2=7
|
|
|
|
|
|
|
|
txMovements movement;
|
|
|
|
|
|
|
|
switch (command) {
|
|
|
|
case ManualControlSettings::CHANNELNUMBER_ROLL:
|
|
|
|
movement = ((transmitterMode == mode3 || transmitterMode == mode4) ?
|
|
|
|
moveLeftHorizontalStick: moveRightHorizontalStick);
|
|
|
|
break;
|
|
|
|
case ManualControlSettings::CHANNELNUMBER_PITCH:
|
|
|
|
movement = (transmitterMode == mode1 || transmitterMode == mode3) ?
|
|
|
|
moveLeftVerticalStick: moveRightVerticalStick;
|
|
|
|
break;
|
|
|
|
case ManualControlSettings::CHANNELNUMBER_YAW:
|
|
|
|
movement = ((transmitterMode == mode1 || transmitterMode == mode2) ?
|
|
|
|
moveLeftHorizontalStick: moveRightHorizontalStick);
|
|
|
|
break;
|
|
|
|
case ManualControlSettings::CHANNELNUMBER_THROTTLE:
|
|
|
|
movement = (transmitterMode == mode2 || transmitterMode == mode4) ?
|
|
|
|
moveLeftVerticalStick: moveRightVerticalStick;
|
|
|
|
break;
|
|
|
|
case ManualControlSettings::CHANNELNUMBER_COLLECTIVE:
|
|
|
|
movement = (transmitterMode == mode2 || transmitterMode == mode4) ?
|
|
|
|
moveLeftVerticalStick: moveRightVerticalStick;
|
|
|
|
break;
|
|
|
|
case ManualControlSettings::CHANNELNUMBER_FLIGHTMODE:
|
|
|
|
movement = moveFlightMode;
|
|
|
|
break;
|
|
|
|
case ManualControlSettings::CHANNELNUMBER_ACCESSORY0:
|
|
|
|
movement = moveAccess0;
|
|
|
|
break;
|
|
|
|
case ManualControlSettings::CHANNELNUMBER_ACCESSORY1:
|
|
|
|
movement = moveAccess1;
|
|
|
|
break;
|
|
|
|
case ManualControlSettings::CHANNELNUMBER_ACCESSORY2:
|
|
|
|
movement = moveAccess2;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Q_ASSERT(0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
setTxMovement(movement);
|
2011-08-16 17:06:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigInputWidget::setTxMovement(txMovements movement)
|
|
|
|
{
|
|
|
|
resetTxControls();
|
|
|
|
switch(movement)
|
|
|
|
{
|
|
|
|
case moveLeftVerticalStick:
|
|
|
|
movePos=0;
|
|
|
|
growing=true;
|
|
|
|
currentMovement=moveLeftVerticalStick;
|
|
|
|
animate->start(100);
|
|
|
|
break;
|
|
|
|
case moveRightVerticalStick:
|
|
|
|
movePos=0;
|
|
|
|
growing=true;
|
|
|
|
currentMovement=moveRightVerticalStick;
|
|
|
|
animate->start(100);
|
|
|
|
break;
|
|
|
|
case moveLeftHorizontalStick:
|
|
|
|
movePos=0;
|
|
|
|
growing=true;
|
|
|
|
currentMovement=moveLeftHorizontalStick;
|
|
|
|
animate->start(100);
|
|
|
|
break;
|
|
|
|
case moveRightHorizontalStick:
|
|
|
|
movePos=0;
|
|
|
|
growing=true;
|
|
|
|
currentMovement=moveRightHorizontalStick;
|
|
|
|
animate->start(100);
|
|
|
|
break;
|
|
|
|
case moveAccess0:
|
|
|
|
movePos=0;
|
|
|
|
growing=true;
|
|
|
|
currentMovement=moveAccess0;
|
|
|
|
animate->start(100);
|
|
|
|
break;
|
|
|
|
case moveAccess1:
|
|
|
|
movePos=0;
|
|
|
|
growing=true;
|
|
|
|
currentMovement=moveAccess1;
|
|
|
|
animate->start(100);
|
|
|
|
break;
|
|
|
|
case moveAccess2:
|
|
|
|
movePos=0;
|
|
|
|
growing=true;
|
|
|
|
currentMovement=moveAccess2;
|
|
|
|
animate->start(100);
|
|
|
|
break;
|
|
|
|
case moveFlightMode:
|
|
|
|
movePos=0;
|
|
|
|
growing=true;
|
|
|
|
currentMovement=moveFlightMode;
|
|
|
|
animate->start(1000);
|
|
|
|
break;
|
|
|
|
case centerAll:
|
|
|
|
movePos=0;
|
|
|
|
currentMovement=centerAll;
|
|
|
|
animate->start(1000);
|
|
|
|
break;
|
|
|
|
case moveAll:
|
|
|
|
movePos=0;
|
|
|
|
growing=true;
|
|
|
|
currentMovement=moveAll;
|
|
|
|
animate->start(50);
|
|
|
|
break;
|
|
|
|
case nothing:
|
2011-08-17 13:43:08 +02:00
|
|
|
movePos=0;
|
2011-08-16 17:06:18 +02:00
|
|
|
animate->stop();
|
|
|
|
break;
|
|
|
|
default:
|
2012-10-19 12:00:42 +02:00
|
|
|
Q_ASSERT(0);
|
2011-08-16 17:06:18 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigInputWidget::moveTxControls()
|
|
|
|
{
|
|
|
|
QTransform trans;
|
|
|
|
QGraphicsItem * item;
|
|
|
|
txMovementType move;
|
|
|
|
int limitMax;
|
|
|
|
int limitMin;
|
|
|
|
static bool auxFlag=false;
|
|
|
|
switch(currentMovement)
|
|
|
|
{
|
|
|
|
case moveLeftVerticalStick:
|
|
|
|
item=m_txLeftStick;
|
|
|
|
trans=m_txLeftStickOrig;
|
|
|
|
limitMax=STICK_MAX_MOVE;
|
|
|
|
limitMin=STICK_MIN_MOVE;
|
|
|
|
move=vertical;
|
|
|
|
break;
|
|
|
|
case moveRightVerticalStick:
|
|
|
|
item=m_txRightStick;
|
|
|
|
trans=m_txRightStickOrig;
|
|
|
|
limitMax=STICK_MAX_MOVE;
|
|
|
|
limitMin=STICK_MIN_MOVE;
|
|
|
|
move=vertical;
|
|
|
|
break;
|
|
|
|
case moveLeftHorizontalStick:
|
|
|
|
item=m_txLeftStick;
|
|
|
|
trans=m_txLeftStickOrig;
|
|
|
|
limitMax=STICK_MAX_MOVE;
|
|
|
|
limitMin=STICK_MIN_MOVE;
|
|
|
|
move=horizontal;
|
|
|
|
break;
|
|
|
|
case moveRightHorizontalStick:
|
|
|
|
item=m_txRightStick;
|
|
|
|
trans=m_txRightStickOrig;
|
|
|
|
limitMax=STICK_MAX_MOVE;
|
|
|
|
limitMin=STICK_MIN_MOVE;
|
|
|
|
move=horizontal;
|
|
|
|
break;
|
|
|
|
case moveAccess0:
|
|
|
|
item=m_txAccess0;
|
|
|
|
trans=m_txAccess0Orig;
|
|
|
|
limitMax=ACCESS_MAX_MOVE;
|
|
|
|
limitMin=ACCESS_MIN_MOVE;
|
|
|
|
move=horizontal;
|
|
|
|
break;
|
|
|
|
case moveAccess1:
|
|
|
|
item=m_txAccess1;
|
|
|
|
trans=m_txAccess1Orig;
|
|
|
|
limitMax=ACCESS_MAX_MOVE;
|
|
|
|
limitMin=ACCESS_MIN_MOVE;
|
|
|
|
move=horizontal;
|
|
|
|
break;
|
|
|
|
case moveAccess2:
|
|
|
|
item=m_txAccess2;
|
|
|
|
trans=m_txAccess2Orig;
|
|
|
|
limitMax=ACCESS_MAX_MOVE;
|
|
|
|
limitMin=ACCESS_MIN_MOVE;
|
|
|
|
move=horizontal;
|
|
|
|
break;
|
|
|
|
case moveFlightMode:
|
|
|
|
item=m_txFlightMode;
|
|
|
|
move=jump;
|
|
|
|
break;
|
|
|
|
case centerAll:
|
|
|
|
item=m_txArrows;
|
|
|
|
move=jump;
|
|
|
|
break;
|
|
|
|
case moveAll:
|
|
|
|
limitMax=STICK_MAX_MOVE;
|
|
|
|
limitMin=STICK_MIN_MOVE;
|
|
|
|
move=mix;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(move==vertical)
|
|
|
|
item->setTransform(trans.translate(0,movePos*10),false);
|
|
|
|
else if(move==horizontal)
|
|
|
|
item->setTransform(trans.translate(movePos*10,0),false);
|
|
|
|
else if(move==jump)
|
|
|
|
{
|
|
|
|
if(item==m_txArrows)
|
|
|
|
{
|
|
|
|
m_txArrows->setVisible(!m_txArrows->isVisible());
|
|
|
|
}
|
|
|
|
else if(item==m_txFlightMode)
|
|
|
|
{
|
|
|
|
QGraphicsSvgItem * svg;
|
|
|
|
svg=(QGraphicsSvgItem *)item;
|
|
|
|
if (svg)
|
|
|
|
{
|
|
|
|
if(svg->elementId()=="flightModeCenter")
|
|
|
|
{
|
|
|
|
if(growing)
|
|
|
|
{
|
|
|
|
svg->setElementId("flightModeRight");
|
|
|
|
m_txFlightMode->setTransform(m_txFlightModeROrig,false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
svg->setElementId("flightModeLeft");
|
|
|
|
m_txFlightMode->setTransform(m_txFlightModeLOrig,false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(svg->elementId()=="flightModeRight")
|
|
|
|
{
|
|
|
|
growing=false;
|
|
|
|
svg->setElementId("flightModeCenter");
|
|
|
|
m_txFlightMode->setTransform(m_txFlightModeCOrig,false);
|
|
|
|
}
|
|
|
|
else if(svg->elementId()=="flightModeLeft")
|
|
|
|
{
|
|
|
|
growing=true;
|
|
|
|
svg->setElementId("flightModeCenter");
|
|
|
|
m_txFlightMode->setTransform(m_txFlightModeCOrig,false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(move==mix)
|
|
|
|
{
|
|
|
|
trans=m_txAccess0Orig;
|
|
|
|
m_txAccess0->setTransform(trans.translate(movePos*10*ACCESS_MAX_MOVE/STICK_MAX_MOVE,0),false);
|
|
|
|
trans=m_txAccess1Orig;
|
|
|
|
m_txAccess1->setTransform(trans.translate(movePos*10*ACCESS_MAX_MOVE/STICK_MAX_MOVE,0),false);
|
|
|
|
trans=m_txAccess2Orig;
|
|
|
|
m_txAccess2->setTransform(trans.translate(movePos*10*ACCESS_MAX_MOVE/STICK_MAX_MOVE,0),false);
|
|
|
|
|
|
|
|
if(auxFlag)
|
|
|
|
{
|
|
|
|
trans=m_txLeftStickOrig;
|
|
|
|
m_txLeftStick->setTransform(trans.translate(0,movePos*10),false);
|
|
|
|
trans=m_txRightStickOrig;
|
|
|
|
m_txRightStick->setTransform(trans.translate(0,movePos*10),false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
trans=m_txLeftStickOrig;
|
|
|
|
m_txLeftStick->setTransform(trans.translate(movePos*10,0),false);
|
|
|
|
trans=m_txRightStickOrig;
|
|
|
|
m_txRightStick->setTransform(trans.translate(movePos*10,0),false);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(movePos==0)
|
|
|
|
{
|
|
|
|
m_txFlightMode->setElementId("flightModeCenter");
|
|
|
|
m_txFlightMode->setTransform(m_txFlightModeCOrig,false);
|
|
|
|
}
|
|
|
|
else if(movePos==ACCESS_MAX_MOVE/2)
|
|
|
|
{
|
|
|
|
m_txFlightMode->setElementId("flightModeRight");
|
|
|
|
m_txFlightMode->setTransform(m_txFlightModeROrig,false);
|
|
|
|
}
|
|
|
|
else if(movePos==ACCESS_MIN_MOVE/2)
|
|
|
|
{
|
|
|
|
m_txFlightMode->setElementId("flightModeLeft");
|
|
|
|
m_txFlightMode->setTransform(m_txFlightModeLOrig,false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(move==horizontal || move==vertical ||move==mix)
|
|
|
|
{
|
|
|
|
if(movePos==0 && growing)
|
|
|
|
auxFlag=!auxFlag;
|
|
|
|
if(growing)
|
|
|
|
++movePos;
|
|
|
|
else
|
|
|
|
--movePos;
|
|
|
|
if(movePos>limitMax)
|
|
|
|
{
|
|
|
|
movePos=movePos-2;
|
|
|
|
growing=false;
|
|
|
|
}
|
|
|
|
if(movePos<limitMin)
|
|
|
|
{
|
|
|
|
movePos=movePos+2;
|
|
|
|
growing=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigInputWidget::moveSticks()
|
|
|
|
{
|
|
|
|
QTransform trans;
|
|
|
|
manualCommandData=manualCommandObj->getData();
|
2012-09-16 15:14:47 +02:00
|
|
|
flightStatusData=flightStatusObj->getData();
|
|
|
|
accessoryDesiredData0=accessoryDesiredObj0->getData();
|
|
|
|
accessoryDesiredData1=accessoryDesiredObj1->getData();
|
|
|
|
accessoryDesiredData2=accessoryDesiredObj2->getData();
|
|
|
|
|
2012-10-19 12:00:42 +02:00
|
|
|
switch (transmitterMode) {
|
|
|
|
case mode1:
|
|
|
|
trans=m_txLeftStickOrig;
|
|
|
|
m_txLeftStick->setTransform(trans.translate(manualCommandData.Yaw*STICK_MAX_MOVE*10,manualCommandData.Pitch*STICK_MAX_MOVE*10),false);
|
|
|
|
trans=m_txRightStickOrig;
|
|
|
|
m_txRightStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,-manualCommandData.Throttle*STICK_MAX_MOVE*10),false);
|
|
|
|
break;
|
|
|
|
case mode2:
|
|
|
|
trans=m_txLeftStickOrig;
|
|
|
|
m_txLeftStick->setTransform(trans.translate(manualCommandData.Yaw*STICK_MAX_MOVE*10,-manualCommandData.Throttle*STICK_MAX_MOVE*10),false);
|
|
|
|
trans=m_txRightStickOrig;
|
|
|
|
m_txRightStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,manualCommandData.Pitch*STICK_MAX_MOVE*10),false);
|
|
|
|
break;
|
|
|
|
case mode3:
|
|
|
|
trans=m_txLeftStickOrig;
|
|
|
|
m_txLeftStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,manualCommandData.Pitch*STICK_MAX_MOVE*10),false);
|
|
|
|
trans=m_txRightStickOrig;
|
|
|
|
m_txRightStick->setTransform(trans.translate(manualCommandData.Yaw*STICK_MAX_MOVE*10,-manualCommandData.Throttle*STICK_MAX_MOVE*10),false);
|
|
|
|
break;
|
|
|
|
case mode4:
|
|
|
|
trans=m_txLeftStickOrig;
|
|
|
|
m_txLeftStick->setTransform(trans.translate(manualCommandData.Roll*STICK_MAX_MOVE*10,-manualCommandData.Throttle*STICK_MAX_MOVE*10),false);
|
|
|
|
trans=m_txRightStickOrig;
|
|
|
|
m_txRightStick->setTransform(trans.translate(manualCommandData.Yaw*STICK_MAX_MOVE*10,manualCommandData.Pitch*STICK_MAX_MOVE*10),false);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Q_ASSERT(0);
|
|
|
|
break;
|
2011-08-16 17:06:18 +02:00
|
|
|
}
|
2012-09-16 15:14:47 +02:00
|
|
|
if(flightStatusData.FlightMode==manualSettingsData.FlightModePosition[0])
|
|
|
|
{
|
|
|
|
m_txFlightMode->setElementId("flightModeLeft");
|
|
|
|
m_txFlightMode->setTransform(m_txFlightModeLOrig,false);
|
|
|
|
}
|
|
|
|
else if (flightStatusData.FlightMode==manualSettingsData.FlightModePosition[1])
|
|
|
|
{
|
|
|
|
m_txFlightMode->setElementId("flightModeCenter");
|
|
|
|
m_txFlightMode->setTransform(m_txFlightModeCOrig,false);
|
|
|
|
}
|
|
|
|
else if (flightStatusData.FlightMode==manualSettingsData.FlightModePosition[2])
|
|
|
|
{
|
|
|
|
m_txFlightMode->setElementId("flightModeRight");
|
|
|
|
m_txFlightMode->setTransform(m_txFlightModeROrig,false);
|
|
|
|
}
|
|
|
|
m_txAccess0->setTransform(QTransform(m_txAccess0Orig).translate(accessoryDesiredData0.AccessoryVal*ACCESS_MAX_MOVE*10,0),false);
|
|
|
|
m_txAccess1->setTransform(QTransform(m_txAccess1Orig).translate(accessoryDesiredData1.AccessoryVal*ACCESS_MAX_MOVE*10,0),false);
|
|
|
|
m_txAccess2->setTransform(QTransform(m_txAccess2Orig).translate(accessoryDesiredData2.AccessoryVal*ACCESS_MAX_MOVE*10,0),false);
|
2011-08-16 17:06:18 +02:00
|
|
|
}
|
2011-06-20 15:28:16 +02:00
|
|
|
|
2011-08-17 13:43:08 +02:00
|
|
|
void ConfigInputWidget::dimOtherControls(bool value)
|
|
|
|
{
|
|
|
|
qreal opac;
|
|
|
|
if(value)
|
|
|
|
opac=0.1;
|
|
|
|
else
|
|
|
|
opac=1;
|
|
|
|
m_txAccess0->setOpacity(opac);
|
|
|
|
m_txAccess1->setOpacity(opac);
|
|
|
|
m_txAccess2->setOpacity(opac);
|
|
|
|
m_txFlightMode->setOpacity(opac);
|
|
|
|
}
|
|
|
|
|
2011-08-20 20:10:28 +02:00
|
|
|
void ConfigInputWidget::invertControls()
|
|
|
|
{
|
|
|
|
manualSettingsData=manualSettingsObj->getData();
|
|
|
|
foreach(QWidget * wd,extraWidgets)
|
|
|
|
{
|
|
|
|
QCheckBox * cb=qobject_cast<QCheckBox *>(wd);
|
|
|
|
if(cb)
|
|
|
|
{
|
2012-01-14 20:23:26 +01:00
|
|
|
int index = manualSettingsObj->getField("ChannelNumber")->getElementNames().indexOf(cb->text());
|
2011-08-23 12:25:28 +02:00
|
|
|
if((cb->isChecked() && (manualSettingsData.ChannelMax[index]>manualSettingsData.ChannelMin[index])) ||
|
|
|
|
(!cb->isChecked() && (manualSettingsData.ChannelMax[index]<manualSettingsData.ChannelMin[index])))
|
2011-08-20 20:10:28 +02:00
|
|
|
{
|
|
|
|
qint16 aux;
|
|
|
|
aux=manualSettingsData.ChannelMax[index];
|
|
|
|
manualSettingsData.ChannelMax[index]=manualSettingsData.ChannelMin[index];
|
|
|
|
manualSettingsData.ChannelMin[index]=aux;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
manualSettingsObj->setData(manualSettingsData);
|
|
|
|
}
|
2012-06-23 16:14:59 +02:00
|
|
|
|
2011-08-23 12:25:28 +02:00
|
|
|
void ConfigInputWidget::moveFMSlider()
|
2011-08-20 20:10:28 +02:00
|
|
|
{
|
2011-08-23 12:25:28 +02:00
|
|
|
ManualControlSettings::DataFields manualSettingsDataPriv = manualSettingsObj->getData();
|
2012-07-03 16:20:10 +02:00
|
|
|
ManualControlCommand::DataFields manualCommandDataPriv = manualCommandObj->getData();
|
2011-08-20 20:10:28 +02:00
|
|
|
|
2011-09-13 05:27:11 +02:00
|
|
|
float valueScaled;
|
|
|
|
int chMin = manualSettingsDataPriv.ChannelMin[ManualControlSettings::CHANNELMIN_FLIGHTMODE];
|
|
|
|
int chMax = manualSettingsDataPriv.ChannelMax[ManualControlSettings::CHANNELMAX_FLIGHTMODE];
|
|
|
|
int chNeutral = manualSettingsDataPriv.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_FLIGHTMODE];
|
2011-08-20 20:10:28 +02:00
|
|
|
|
2011-09-13 05:27:11 +02:00
|
|
|
int value = manualCommandDataPriv.Channel[ManualControlSettings::CHANNELMIN_FLIGHTMODE];
|
|
|
|
if ((chMax > chMin && value >= chNeutral) || (chMin > chMax && value <= chNeutral))
|
|
|
|
{
|
|
|
|
if (chMax != chNeutral)
|
|
|
|
valueScaled = (float)(value - chNeutral) / (float)(chMax - chNeutral);
|
2011-08-20 20:10:28 +02:00
|
|
|
else
|
2011-09-13 05:27:11 +02:00
|
|
|
valueScaled = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (chMin != chNeutral)
|
|
|
|
valueScaled = (float)(value - chNeutral) / (float)(chNeutral - chMin);
|
2011-08-20 20:10:28 +02:00
|
|
|
else
|
2011-09-13 05:27:11 +02:00
|
|
|
valueScaled = 0;
|
2011-08-20 20:10:28 +02:00
|
|
|
}
|
2011-09-13 05:27:11 +02:00
|
|
|
|
2012-06-23 16:14:59 +02:00
|
|
|
// Bound and scale FlightMode from [-1..+1] to [0..1] range
|
|
|
|
if (valueScaled < -1.0)
|
|
|
|
valueScaled = -1.0;
|
2012-06-24 23:30:42 +02:00
|
|
|
else
|
2012-06-23 16:14:59 +02:00
|
|
|
if (valueScaled > 1.0)
|
|
|
|
valueScaled = 1.0;
|
|
|
|
|
2012-06-24 23:30:42 +02:00
|
|
|
// Convert flightMode value into the switch position in the range [0..N-1]
|
2012-06-25 10:41:42 +02:00
|
|
|
// This uses the same optimized computation as flight code to be consistent
|
|
|
|
uint8_t pos = ((int16_t)(valueScaled * 256) + 256) * manualSettingsDataPriv.FlightModeNumber >> 9;
|
2012-06-24 23:30:42 +02:00
|
|
|
if (pos >= manualSettingsDataPriv.FlightModeNumber)
|
|
|
|
pos = manualSettingsDataPriv.FlightModeNumber - 1;
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->fmsSlider->setValue(pos);
|
2012-06-23 16:14:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigInputWidget::updatePositionSlider()
|
|
|
|
{
|
|
|
|
ManualControlSettings::DataFields manualSettingsDataPriv = manualSettingsObj->getData();
|
|
|
|
|
|
|
|
switch(manualSettingsDataPriv.FlightModeNumber) {
|
|
|
|
default:
|
|
|
|
case 6:
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->fmsModePos6->setEnabled(true);
|
2012-06-23 16:14:59 +02:00
|
|
|
// pass through
|
|
|
|
case 5:
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->fmsModePos5->setEnabled(true);
|
2012-06-23 16:14:59 +02:00
|
|
|
// pass through
|
|
|
|
case 4:
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->fmsModePos4->setEnabled(true);
|
2012-06-23 16:14:59 +02:00
|
|
|
// pass through
|
|
|
|
case 3:
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->fmsModePos3->setEnabled(true);
|
2012-06-23 16:14:59 +02:00
|
|
|
// pass through
|
|
|
|
case 2:
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->fmsModePos2->setEnabled(true);
|
2012-06-23 16:14:59 +02:00
|
|
|
// pass through
|
|
|
|
case 1:
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->fmsModePos1->setEnabled(true);
|
2012-06-23 16:14:59 +02:00
|
|
|
// pass through
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(manualSettingsDataPriv.FlightModeNumber) {
|
|
|
|
case 0:
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->fmsModePos1->setEnabled(false);
|
2012-06-23 16:14:59 +02:00
|
|
|
// pass through
|
|
|
|
case 1:
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->fmsModePos2->setEnabled(false);
|
2012-06-23 16:14:59 +02:00
|
|
|
// pass through
|
|
|
|
case 2:
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->fmsModePos3->setEnabled(false);
|
2012-06-23 16:14:59 +02:00
|
|
|
// pass through
|
|
|
|
case 3:
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->fmsModePos4->setEnabled(false);
|
2012-06-23 16:14:59 +02:00
|
|
|
// pass through
|
|
|
|
case 4:
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->fmsModePos5->setEnabled(false);
|
2012-06-23 16:14:59 +02:00
|
|
|
// pass through
|
|
|
|
case 5:
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->fmsModePos6->setEnabled(false);
|
2012-06-23 16:14:59 +02:00
|
|
|
// pass through
|
|
|
|
case 6:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-08-20 20:10:28 +02:00
|
|
|
}
|
2011-09-07 01:26:47 +02:00
|
|
|
|
|
|
|
void ConfigInputWidget::updateCalibration()
|
|
|
|
{
|
|
|
|
manualCommandData=manualCommandObj->getData();
|
|
|
|
for(uint i=0;i<ManualControlSettings::CHANNELMAX_NUMELEM;++i)
|
|
|
|
{
|
2011-09-09 07:54:47 +02:00
|
|
|
if((!reverse[i] && manualSettingsData.ChannelMin[i]>manualCommandData.Channel[i]) ||
|
|
|
|
(reverse[i] && manualSettingsData.ChannelMin[i]<manualCommandData.Channel[i]))
|
2011-09-07 01:26:47 +02:00
|
|
|
manualSettingsData.ChannelMin[i]=manualCommandData.Channel[i];
|
2011-09-09 07:54:47 +02:00
|
|
|
if((!reverse[i] && manualSettingsData.ChannelMax[i]<manualCommandData.Channel[i]) ||
|
|
|
|
(reverse[i] && manualSettingsData.ChannelMax[i]>manualCommandData.Channel[i]))
|
2011-09-07 01:26:47 +02:00
|
|
|
manualSettingsData.ChannelMax[i]=manualCommandData.Channel[i];
|
|
|
|
manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i];
|
|
|
|
}
|
|
|
|
|
|
|
|
manualSettingsObj->setData(manualSettingsData);
|
|
|
|
manualSettingsObj->updated();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ConfigInputWidget::simpleCalibration(bool enable)
|
|
|
|
{
|
|
|
|
if (enable) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->configurationWizard->setEnabled(false);
|
2011-10-20 15:31:58 +02:00
|
|
|
|
2011-09-07 01:26:47 +02:00
|
|
|
QMessageBox msgBox;
|
2012-10-19 12:00:42 +02:00
|
|
|
msgBox.setText(tr("Arming Settings are now set to 'Always Disarmed' for your safety."));
|
2012-09-22 10:58:55 +02:00
|
|
|
msgBox.setDetailedText(tr("You will have to reconfigure the arming settings manually when the wizard is finished."));
|
2011-09-07 01:26:47 +02:00
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
|
|
msgBox.exec();
|
|
|
|
|
|
|
|
manualCommandData = manualCommandObj->getData();
|
|
|
|
|
|
|
|
manualSettingsData=manualSettingsObj->getData();
|
|
|
|
manualSettingsData.Arming=ManualControlSettings::ARMING_ALWAYSDISARMED;
|
|
|
|
manualSettingsObj->setData(manualSettingsData);
|
|
|
|
|
2011-09-07 08:47:10 +02:00
|
|
|
for (unsigned int i = 0; i < ManualControlCommand::CHANNEL_NUMELEM; i++) {
|
2011-09-09 07:54:47 +02:00
|
|
|
reverse[i] = manualSettingsData.ChannelMax[i] < manualSettingsData.ChannelMin[i];
|
2011-09-07 01:26:47 +02:00
|
|
|
manualSettingsData.ChannelMin[i] = manualCommandData.Channel[i];
|
|
|
|
manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i];
|
|
|
|
manualSettingsData.ChannelMax[i] = manualCommandData.Channel[i];
|
|
|
|
}
|
|
|
|
|
2011-09-11 18:14:09 +02:00
|
|
|
fastMdata();
|
2011-09-07 01:26:47 +02:00
|
|
|
|
|
|
|
connect(manualCommandObj, SIGNAL(objectUnpacked(UAVObject*)), this, SLOT(updateCalibration()));
|
|
|
|
} else {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->configurationWizard->setEnabled(true);
|
2011-10-20 15:31:58 +02:00
|
|
|
|
2011-09-07 01:26:47 +02:00
|
|
|
manualCommandData = manualCommandObj->getData();
|
|
|
|
manualSettingsData = manualSettingsObj->getData();
|
|
|
|
|
2011-09-11 18:14:09 +02:00
|
|
|
restoreMdata();
|
2011-09-07 01:26:47 +02:00
|
|
|
|
2012-10-19 12:00:42 +02:00
|
|
|
for (unsigned int i = 0; i < ManualControlCommand::CHANNEL_NUMELEM; i++)
|
2011-09-07 01:26:47 +02:00
|
|
|
manualSettingsData.ChannelNeutral[i] = manualCommandData.Channel[i];
|
|
|
|
|
|
|
|
// Force flight mode neutral to middle
|
|
|
|
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNUMBER_FLIGHTMODE] =
|
|
|
|
(manualSettingsData.ChannelMax[ManualControlSettings::CHANNELNUMBER_FLIGHTMODE] +
|
|
|
|
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELNUMBER_FLIGHTMODE]) / 2;
|
|
|
|
|
|
|
|
// Force throttle to be near min
|
|
|
|
manualSettingsData.ChannelNeutral[ManualControlSettings::CHANNELNEUTRAL_THROTTLE]=
|
|
|
|
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE]+
|
|
|
|
((manualSettingsData.ChannelMax[ManualControlSettings::CHANNELMAX_THROTTLE]-
|
|
|
|
manualSettingsData.ChannelMin[ManualControlSettings::CHANNELMIN_THROTTLE])*0.02);
|
|
|
|
|
|
|
|
manualSettingsObj->setData(manualSettingsData);
|
|
|
|
|
|
|
|
disconnect(manualCommandObj, SIGNAL(objectUnpacked(UAVObject*)), this, SLOT(updateCalibration()));
|
|
|
|
}
|
|
|
|
}
|