2011-03-28 17:39:22 +02:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
2011-11-17 14:33:49 +01:00
|
|
|
* @file configoutputwidget.cpp
|
2011-03-28 17:39:22 +02:00
|
|
|
* @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* @addtogroup GCSPlugins GCS Plugins
|
|
|
|
* @{
|
|
|
|
* @addtogroup ConfigPlugin Config Plugin
|
|
|
|
* @{
|
2011-11-17 14:33:49 +01:00
|
|
|
* @brief Servo output configuration panel for the config gadget
|
2011-03-28 17:39:22 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
|
|
|
* 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 "configoutputwidget.h"
|
2011-11-09 19:35:53 +01:00
|
|
|
#include "outputchannelform.h"
|
2012-05-21 20:28:29 +02:00
|
|
|
#include "configvehicletypewidget.h"
|
2011-03-28 17:39:22 +02:00
|
|
|
|
2013-12-11 22:22:28 +01:00
|
|
|
#include "mixersettings.h"
|
|
|
|
#include "actuatorcommand.h"
|
|
|
|
#include "actuatorsettings.h"
|
|
|
|
#include "systemalarms.h"
|
|
|
|
#include "systemsettings.h"
|
|
|
|
#include "uavsettingsimportexport/uavsettingsimportexportfactory.h"
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
#include <coreplugin/generalsettings.h>
|
2011-03-28 17:39:22 +02:00
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QStringList>
|
2013-09-15 23:06:25 +02:00
|
|
|
#include <QWidget>
|
|
|
|
#include <QTextEdit>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QPushButton>
|
2011-03-29 02:15:56 +02:00
|
|
|
#include <QMessageBox>
|
2011-05-31 09:16:01 +02:00
|
|
|
#include <QDesktopServices>
|
|
|
|
#include <QUrl>
|
2012-07-21 19:07:47 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
ConfigOutputWidget::ConfigOutputWidget(QWidget *parent) : ConfigTaskWidget(parent), wasItMe(false)
|
2011-03-28 17:39:22 +02:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui = new Ui_OutputWidget();
|
|
|
|
ui->setupUi(this);
|
2013-05-19 16:37:30 +02:00
|
|
|
|
2013-03-12 07:35:20 +01:00
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
Core::Internal::GeneralSettings *settings = pm->getObject<Core::Internal::GeneralSettings>();
|
2013-05-19 16:37:30 +02:00
|
|
|
if (!settings->useExpertMode()) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->saveRCOutputToRAM->setVisible(false);
|
2013-03-12 07:35:20 +01:00
|
|
|
}
|
2011-03-28 17:39:22 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
UAVSettingsImportExportFactory *importexportplugin = pm->getObject<UAVSettingsImportExportFactory>();
|
2013-03-12 07:35:20 +01:00
|
|
|
connect(importexportplugin, SIGNAL(importAboutToBegin()), this, SLOT(stopTests()));
|
2011-10-15 22:16:34 +02:00
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
connect(ui->channelOutTest, SIGNAL(toggled(bool)), this, SLOT(runChannelTests(bool)));
|
2011-03-28 17:39:22 +02:00
|
|
|
|
2012-05-28 21:06:34 +02:00
|
|
|
// Configure the task widget
|
2011-05-31 09:16:01 +02:00
|
|
|
// Connect the help button
|
2013-05-04 00:13:15 +02:00
|
|
|
connect(ui->outputHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
|
2012-05-28 21:06:34 +02:00
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
addApplySaveButtons(ui->saveRCOutputToRAM, ui->saveRCOutputToSD);
|
2012-05-28 21:06:34 +02:00
|
|
|
|
|
|
|
// Track the ActuatorSettings object
|
|
|
|
addUAVObject("ActuatorSettings");
|
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
// NOTE: we have channel indices from 0 to 9, but the convention for OP is Channel 1 to Channel 10.
|
|
|
|
// Register for ActuatorSettings changes:
|
|
|
|
for (unsigned int i = 0; i < ActuatorCommand::CHANNEL_NUMELEM; i++) {
|
2014-05-10 20:40:14 +02:00
|
|
|
OutputChannelForm *form = new OutputChannelForm(i, this);
|
2014-05-12 22:30:50 +02:00
|
|
|
form->moveTo(*(ui->channelLayout));
|
2014-05-10 20:40:14 +02:00
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
connect(ui->channelOutTest, SIGNAL(toggled(bool)), form, SLOT(enableChannelTest(bool)));
|
2013-05-19 16:37:30 +02:00
|
|
|
connect(form, SIGNAL(channelChanged(int, int)), this, SLOT(sendChannelTest(int, int)));
|
2014-05-10 20:40:14 +02:00
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
addWidget(form->ui.actuatorMin);
|
|
|
|
addWidget(form->ui.actuatorNeutral);
|
|
|
|
addWidget(form->ui.actuatorMax);
|
|
|
|
addWidget(form->ui.actuatorRev);
|
|
|
|
addWidget(form->ui.actuatorLink);
|
|
|
|
}
|
|
|
|
|
2012-05-28 21:06:34 +02:00
|
|
|
// Associate the buttons with their UAVO fields
|
2013-05-04 00:13:15 +02:00
|
|
|
addWidget(ui->cb_outputRate6);
|
|
|
|
addWidget(ui->cb_outputRate5);
|
|
|
|
addWidget(ui->cb_outputRate4);
|
|
|
|
addWidget(ui->cb_outputRate3);
|
|
|
|
addWidget(ui->cb_outputRate2);
|
|
|
|
addWidget(ui->cb_outputRate1);
|
|
|
|
addWidget(ui->spinningArmed);
|
2011-10-16 01:57:59 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
disconnect(this, SLOT(refreshWidgetsValues(UAVObject *)));
|
2012-05-28 21:06:34 +02:00
|
|
|
|
2011-10-16 01:57:59 +02:00
|
|
|
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
2013-05-19 16:37:30 +02:00
|
|
|
UAVObject *obj = objManager->getObject(QString("ActuatorCommand"));
|
|
|
|
if (UAVObject::GetGcsTelemetryUpdateMode(obj->getMetadata()) == UAVObject::UPDATEMODE_ONCHANGE) {
|
2011-10-16 01:57:59 +02:00
|
|
|
this->setEnabled(false);
|
2013-03-12 07:35:20 +01:00
|
|
|
}
|
2013-05-19 16:37:30 +02:00
|
|
|
connect(obj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(disableIfNotMe(UAVObject *)));
|
2012-05-28 21:06:34 +02:00
|
|
|
|
|
|
|
refreshWidgetsValues();
|
2013-05-04 00:13:15 +02:00
|
|
|
updateEnableControls();
|
2011-03-28 17:39:22 +02:00
|
|
|
}
|
2013-03-12 07:35:20 +01:00
|
|
|
|
2013-06-21 09:39:06 +02:00
|
|
|
ConfigOutputWidget::~ConfigOutputWidget()
|
|
|
|
{
|
|
|
|
// Do nothing
|
|
|
|
}
|
|
|
|
|
2011-11-26 00:47:39 +01:00
|
|
|
void ConfigOutputWidget::enableControls(bool enable)
|
|
|
|
{
|
|
|
|
ConfigTaskWidget::enableControls(enable);
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
if (!enable) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->channelOutTest->setChecked(false);
|
2013-03-12 07:35:20 +01:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->channelOutTest->setEnabled(enable);
|
2011-11-26 00:47:39 +01:00
|
|
|
}
|
2011-03-28 17:39:22 +02:00
|
|
|
|
2014-08-23 15:45:16 +02:00
|
|
|
/**
|
|
|
|
Force update all channels with the values in the OutputChannelForms.
|
|
|
|
*/
|
|
|
|
void ConfigOutputWidget::sendAllChannelTests()
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < ActuatorCommand::CHANNEL_NUMELEM; i++) {
|
|
|
|
OutputChannelForm *form = getOutputChannelForm(i);
|
|
|
|
sendChannelTest(i, form->neutral());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-28 17:39:22 +02:00
|
|
|
/**
|
2013-05-19 16:37:30 +02:00
|
|
|
Toggles the channel testing mode by making the GCS take over
|
|
|
|
the ActuatorCommand objects
|
|
|
|
*/
|
2011-03-28 17:39:22 +02:00
|
|
|
void ConfigOutputWidget::runChannelTests(bool state)
|
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
SystemAlarms *systemAlarmsObj = SystemAlarms::GetInstance(getObjectManager());
|
2011-10-20 14:20:23 +02:00
|
|
|
SystemAlarms::DataFields systemAlarms = systemAlarmsObj->getData();
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
if (state && systemAlarms.Alarm[SystemAlarms::ALARM_ACTUATOR] != SystemAlarms::ALARM_OK) {
|
2011-10-20 14:20:23 +02:00
|
|
|
QMessageBox mbox;
|
2014-09-30 00:39:51 +02:00
|
|
|
mbox.setText(QString(tr("The actuator module is in an error state. This can also occur because there are no inputs. "
|
|
|
|
"Please fix these before testing outputs.")));
|
2011-10-20 14:20:23 +02:00
|
|
|
mbox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
mbox.exec();
|
|
|
|
|
|
|
|
// Unfortunately must cache this since callback will reoccur
|
|
|
|
accInitialData = ActuatorCommand::GetInstance(getObjectManager())->getMetadata();
|
|
|
|
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->channelOutTest->setChecked(false);
|
2011-10-20 14:20:23 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-03-29 02:15:56 +02:00
|
|
|
// Confirm this is definitely what they want
|
2013-05-19 16:37:30 +02:00
|
|
|
if (state) {
|
2011-03-29 02:15:56 +02:00
|
|
|
QMessageBox mbox;
|
2014-09-30 00:39:51 +02:00
|
|
|
mbox.setText(QString(tr("This option will start your motors by the amount selected on the sliders regardless of transmitter."
|
|
|
|
"It is recommended to remove any blades from motors. Are you sure you want to do this?")));
|
2011-03-29 02:15:56 +02:00
|
|
|
mbox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
|
|
|
|
int retval = mbox.exec();
|
2013-05-19 16:37:30 +02:00
|
|
|
if (retval != QMessageBox::Yes) {
|
2011-03-29 02:15:56 +02:00
|
|
|
state = false;
|
|
|
|
qDebug() << "Cancelled";
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->channelOutTest->setChecked(false);
|
2011-03-29 02:15:56 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
ActuatorCommand *obj = ActuatorCommand::GetInstance(getObjectManager());
|
2011-03-28 17:39:22 +02:00
|
|
|
UAVObject::Metadata mdata = obj->getMetadata();
|
2013-03-12 07:35:20 +01:00
|
|
|
if (state) {
|
|
|
|
wasItMe = true;
|
2011-03-28 17:39:22 +02:00
|
|
|
accInitialData = mdata;
|
2012-03-31 16:59:44 +02:00
|
|
|
UAVObject::SetFlightAccess(mdata, UAVObject::ACCESS_READONLY);
|
|
|
|
UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_ONCHANGE);
|
|
|
|
UAVObject::SetGcsTelemetryAcked(mdata, false);
|
|
|
|
UAVObject::SetGcsTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_ONCHANGE);
|
2011-03-28 17:39:22 +02:00
|
|
|
mdata.gcsTelemetryUpdatePeriod = 100;
|
2013-05-19 16:37:30 +02:00
|
|
|
} else {
|
2013-03-12 07:35:20 +01:00
|
|
|
wasItMe = false;
|
2013-05-19 16:37:30 +02:00
|
|
|
mdata = accInitialData; // Restore metadata
|
2011-03-28 17:39:22 +02:00
|
|
|
}
|
|
|
|
obj->setMetadata(mdata);
|
2011-10-16 01:57:59 +02:00
|
|
|
obj->updated();
|
2014-08-23 15:45:16 +02:00
|
|
|
|
|
|
|
// Setup the correct initial channel values when the channel testing mode is turned on.
|
|
|
|
if (state) {
|
|
|
|
sendAllChannelTests();
|
|
|
|
}
|
2011-03-28 17:39:22 +02:00
|
|
|
}
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
OutputChannelForm *ConfigOutputWidget::getOutputChannelForm(const int index) const
|
2011-11-09 19:35:53 +01:00
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
QList<OutputChannelForm *> outputChannelForms = findChildren<OutputChannelForm *>();
|
|
|
|
foreach(OutputChannelForm * outputChannelForm, outputChannelForms) {
|
|
|
|
if (outputChannelForm->index() == index) {
|
2011-11-09 19:35:53 +01:00
|
|
|
return outputChannelForm;
|
2013-03-12 07:35:20 +01:00
|
|
|
}
|
2011-11-09 19:35:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// no OutputChannelForm found with given index
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-03-28 17:39:22 +02:00
|
|
|
/**
|
2013-05-19 16:37:30 +02:00
|
|
|
* Set the label for a channel output assignement
|
|
|
|
*/
|
2014-05-12 22:30:50 +02:00
|
|
|
void ConfigOutputWidget::assignOutputChannel(UAVDataObject *obj, QString &str)
|
2011-03-28 17:39:22 +02:00
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
// FIXME: use signal/ slot approach
|
|
|
|
UAVObjectField *field = obj->getField(str);
|
|
|
|
QStringList options = field->getOptions();
|
2011-11-09 19:35:53 +01:00
|
|
|
int index = options.indexOf(field->getValue().toString());
|
|
|
|
|
|
|
|
OutputChannelForm *outputChannelForm = getOutputChannelForm(index);
|
2013-05-19 16:37:30 +02:00
|
|
|
|
|
|
|
if (outputChannelForm) {
|
2014-05-12 22:30:50 +02:00
|
|
|
outputChannelForm->setName(str);
|
2013-03-12 07:35:20 +01:00
|
|
|
}
|
2011-03-28 17:39:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-05-19 16:37:30 +02:00
|
|
|
Sends the channel value to the UAV to move the servo.
|
|
|
|
Returns immediately if we are not in testing mode
|
|
|
|
*/
|
2011-11-09 19:35:53 +01:00
|
|
|
void ConfigOutputWidget::sendChannelTest(int index, int value)
|
2011-03-28 17:39:22 +02:00
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
if (!ui->channelOutTest->isChecked()) {
|
2011-11-09 19:35:53 +01:00
|
|
|
return;
|
2013-03-12 07:35:20 +01:00
|
|
|
}
|
2011-11-09 19:35:53 +01:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
if (index < 0 || (unsigned)index >= ActuatorCommand::CHANNEL_NUMELEM) {
|
2011-11-09 19:35:53 +01:00
|
|
|
return;
|
2013-03-12 07:35:20 +01:00
|
|
|
}
|
2011-11-09 19:35:53 +01:00
|
|
|
|
2011-11-17 14:33:49 +01:00
|
|
|
ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(getObjectManager());
|
|
|
|
Q_ASSERT(actuatorCommand);
|
|
|
|
ActuatorCommand::DataFields actuatorCommandFields = actuatorCommand->getData();
|
|
|
|
actuatorCommandFields.Channel[index] = value;
|
|
|
|
actuatorCommand->setData(actuatorCommandFields);
|
2011-03-28 17:39:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/********************************
|
2013-05-19 16:37:30 +02:00
|
|
|
* Output settings
|
|
|
|
*******************************/
|
2011-03-28 17:39:22 +02:00
|
|
|
|
|
|
|
/**
|
2013-05-19 16:37:30 +02:00
|
|
|
Request the current config from the board (RC Output)
|
|
|
|
*/
|
|
|
|
void ConfigOutputWidget::refreshWidgetsValues(UAVObject *obj)
|
2011-03-28 17:39:22 +02:00
|
|
|
{
|
2012-06-06 17:58:18 +02:00
|
|
|
Q_UNUSED(obj);
|
|
|
|
|
2013-06-21 09:39:06 +02:00
|
|
|
bool dirty = isDirty();
|
|
|
|
|
2012-05-10 00:24:15 +02:00
|
|
|
// Get Actuator Settings
|
|
|
|
ActuatorSettings *actuatorSettings = ActuatorSettings::GetInstance(getObjectManager());
|
|
|
|
Q_ASSERT(actuatorSettings);
|
|
|
|
ActuatorSettings::DataFields actuatorSettingsData = actuatorSettings->getData();
|
|
|
|
|
2013-03-11 23:22:10 +01:00
|
|
|
// Get channel descriptions
|
2012-05-21 20:28:29 +02:00
|
|
|
QStringList ChannelDesc = ConfigVehicleTypeWidget::getChannelDescriptions();
|
2012-05-10 00:24:15 +02:00
|
|
|
|
|
|
|
// Initialize output forms
|
2013-05-19 16:37:30 +02:00
|
|
|
QList<OutputChannelForm *> outputChannelForms = findChildren<OutputChannelForm *>();
|
|
|
|
foreach(OutputChannelForm * outputChannelForm, outputChannelForms) {
|
2014-05-12 22:30:50 +02:00
|
|
|
outputChannelForm->setName(ChannelDesc[outputChannelForm->index()]);
|
2012-05-10 00:24:15 +02:00
|
|
|
|
|
|
|
// init min,max,neutral
|
|
|
|
int minValue = actuatorSettingsData.ChannelMin[outputChannelForm->index()];
|
|
|
|
int maxValue = actuatorSettingsData.ChannelMax[outputChannelForm->index()];
|
2014-05-12 22:30:50 +02:00
|
|
|
outputChannelForm->setRange(minValue, maxValue);
|
2012-05-10 00:24:15 +02:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
int neutral = actuatorSettingsData.ChannelNeutral[outputChannelForm->index()];
|
2014-05-12 22:30:50 +02:00
|
|
|
outputChannelForm->setNeutral(neutral);
|
2011-11-09 19:35:53 +01:00
|
|
|
}
|
2011-03-28 17:39:22 +02:00
|
|
|
|
2011-05-03 07:41:06 +02:00
|
|
|
// Get the SpinWhileArmed setting
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->spinningArmed->setChecked(actuatorSettingsData.MotorsSpinWhileArmed == ActuatorSettings::MOTORSSPINWHILEARMED_TRUE);
|
2011-05-03 07:41:06 +02:00
|
|
|
|
2013-03-11 23:22:10 +01:00
|
|
|
// Setup output rates for all banks
|
2013-05-19 16:37:30 +02:00
|
|
|
if (ui->cb_outputRate1->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[0])) == -1) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->cb_outputRate1->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[0]));
|
2011-11-29 18:01:02 +01:00
|
|
|
}
|
2013-05-19 16:37:30 +02:00
|
|
|
if (ui->cb_outputRate2->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[1])) == -1) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->cb_outputRate2->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[1]));
|
2011-11-29 18:01:02 +01:00
|
|
|
}
|
2013-05-19 16:37:30 +02:00
|
|
|
if (ui->cb_outputRate3->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[2])) == -1) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->cb_outputRate3->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[2]));
|
2013-03-11 23:22:10 +01:00
|
|
|
}
|
2013-05-19 16:37:30 +02:00
|
|
|
if (ui->cb_outputRate4->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[3])) == -1) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->cb_outputRate4->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[3]));
|
2013-03-11 23:22:10 +01:00
|
|
|
}
|
2013-05-19 16:37:30 +02:00
|
|
|
if (ui->cb_outputRate5->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[4])) == -1) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->cb_outputRate5->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[4]));
|
2013-03-11 23:22:10 +01:00
|
|
|
}
|
2013-05-19 16:37:30 +02:00
|
|
|
if (ui->cb_outputRate6->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[5])) == -1) {
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->cb_outputRate6->addItem(QString::number(actuatorSettingsData.ChannelUpdateFreq[5]));
|
2013-03-11 23:22:10 +01:00
|
|
|
}
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->cb_outputRate1->setCurrentIndex(ui->cb_outputRate1->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[0])));
|
|
|
|
ui->cb_outputRate2->setCurrentIndex(ui->cb_outputRate2->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[1])));
|
|
|
|
ui->cb_outputRate3->setCurrentIndex(ui->cb_outputRate3->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[2])));
|
|
|
|
ui->cb_outputRate4->setCurrentIndex(ui->cb_outputRate4->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[3])));
|
|
|
|
ui->cb_outputRate5->setCurrentIndex(ui->cb_outputRate5->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[4])));
|
|
|
|
ui->cb_outputRate6->setCurrentIndex(ui->cb_outputRate6->findText(QString::number(actuatorSettingsData.ChannelUpdateFreq[5])));
|
2013-03-11 23:22:10 +01:00
|
|
|
|
|
|
|
// Reset to all disabled
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->chBank1->setText("-");
|
|
|
|
ui->chBank2->setText("-");
|
|
|
|
ui->chBank3->setText("-");
|
|
|
|
ui->chBank4->setText("-");
|
|
|
|
ui->chBank5->setText("-");
|
|
|
|
ui->chBank6->setText("-");
|
|
|
|
ui->cb_outputRate1->setEnabled(false);
|
|
|
|
ui->cb_outputRate2->setEnabled(false);
|
|
|
|
ui->cb_outputRate3->setEnabled(false);
|
|
|
|
ui->cb_outputRate4->setEnabled(false);
|
|
|
|
ui->cb_outputRate5->setEnabled(false);
|
|
|
|
ui->cb_outputRate6->setEnabled(false);
|
2013-03-11 23:22:10 +01:00
|
|
|
|
|
|
|
// Get connected board model
|
2012-05-10 00:24:15 +02:00
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
Q_ASSERT(pm);
|
2013-05-19 16:37:30 +02:00
|
|
|
UAVObjectUtilManager *utilMngr = pm->getObject<UAVObjectUtilManager>();
|
2013-03-11 23:22:10 +01:00
|
|
|
Q_ASSERT(utilMngr);
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
if (utilMngr) {
|
2011-05-03 16:50:31 +02:00
|
|
|
int board = utilMngr->getBoardModel();
|
2013-03-11 23:22:10 +01:00
|
|
|
// Setup labels and combos for banks according to board type
|
|
|
|
if ((board & 0xff00) == 0x0400) {
|
|
|
|
// Coptercontrol family of boards 4 timer banks
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->chBank1->setText("1-3");
|
|
|
|
ui->chBank2->setText("4");
|
|
|
|
ui->chBank3->setText("5,7-8");
|
|
|
|
ui->chBank4->setText("6,9-10");
|
|
|
|
ui->cb_outputRate1->setEnabled(true);
|
|
|
|
ui->cb_outputRate2->setEnabled(true);
|
|
|
|
ui->cb_outputRate3->setEnabled(true);
|
|
|
|
ui->cb_outputRate4->setEnabled(true);
|
2013-05-19 16:37:30 +02:00
|
|
|
} else if ((board & 0xff00) == 0x0900) {
|
2013-03-11 23:22:10 +01:00
|
|
|
// Revolution family of boards 6 timer banks
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->chBank1->setText("1-2");
|
|
|
|
ui->chBank2->setText("3");
|
|
|
|
ui->chBank3->setText("4");
|
|
|
|
ui->chBank4->setText("5-6");
|
|
|
|
ui->chBank5->setText("7-8");
|
|
|
|
ui->chBank6->setText("9-10");
|
|
|
|
ui->cb_outputRate1->setEnabled(true);
|
|
|
|
ui->cb_outputRate2->setEnabled(true);
|
|
|
|
ui->cb_outputRate3->setEnabled(true);
|
|
|
|
ui->cb_outputRate4->setEnabled(true);
|
|
|
|
ui->cb_outputRate5->setEnabled(true);
|
|
|
|
ui->cb_outputRate6->setEnabled(true);
|
2011-05-03 16:50:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-28 17:39:22 +02:00
|
|
|
// Get Channel ranges:
|
2013-05-19 16:37:30 +02:00
|
|
|
foreach(OutputChannelForm * outputChannelForm, outputChannelForms) {
|
|
|
|
int minValue = actuatorSettingsData.ChannelMin[outputChannelForm->index()];
|
2011-11-17 14:33:49 +01:00
|
|
|
int maxValue = actuatorSettingsData.ChannelMax[outputChannelForm->index()];
|
2013-05-19 16:37:30 +02:00
|
|
|
|
2014-05-12 22:30:50 +02:00
|
|
|
outputChannelForm->setRange(minValue, maxValue);
|
2011-03-28 17:39:22 +02:00
|
|
|
|
2011-11-17 14:33:49 +01:00
|
|
|
int neutral = actuatorSettingsData.ChannelNeutral[outputChannelForm->index()];
|
2014-05-12 22:30:50 +02:00
|
|
|
outputChannelForm->setNeutral(neutral);
|
2011-03-28 17:39:22 +02:00
|
|
|
}
|
2013-06-21 09:39:06 +02:00
|
|
|
|
|
|
|
setDirty(dirty);
|
2011-03-28 17:39:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-05-19 16:37:30 +02:00
|
|
|
* Sends the config to the board, without saving to the SD card (RC Output)
|
|
|
|
*/
|
2011-08-02 18:06:17 +02:00
|
|
|
void ConfigOutputWidget::updateObjectsFromWidgets()
|
2011-03-28 17:39:22 +02:00
|
|
|
{
|
2012-05-28 17:40:35 +02:00
|
|
|
emit updateObjectsFromWidgetsRequested();
|
|
|
|
|
2011-11-17 14:33:49 +01:00
|
|
|
ActuatorSettings *actuatorSettings = ActuatorSettings::GetInstance(getObjectManager());
|
2013-05-19 16:37:30 +02:00
|
|
|
|
2011-11-17 14:33:49 +01:00
|
|
|
Q_ASSERT(actuatorSettings);
|
2013-05-19 16:37:30 +02:00
|
|
|
if (actuatorSettings) {
|
2012-05-28 17:40:35 +02:00
|
|
|
ActuatorSettings::DataFields actuatorSettingsData = actuatorSettings->getData();
|
|
|
|
|
|
|
|
// Set channel ranges
|
2013-05-19 16:37:30 +02:00
|
|
|
QList<OutputChannelForm *> outputChannelForms = findChildren<OutputChannelForm *>();
|
|
|
|
foreach(OutputChannelForm * outputChannelForm, outputChannelForms) {
|
|
|
|
actuatorSettingsData.ChannelMax[outputChannelForm->index()] = outputChannelForm->max();
|
|
|
|
actuatorSettingsData.ChannelMin[outputChannelForm->index()] = outputChannelForm->min();
|
2012-05-28 17:40:35 +02:00
|
|
|
actuatorSettingsData.ChannelNeutral[outputChannelForm->index()] = outputChannelForm->neutral();
|
|
|
|
}
|
2011-03-28 17:39:22 +02:00
|
|
|
|
2012-05-28 17:40:35 +02:00
|
|
|
// Set update rates
|
2013-05-04 00:13:15 +02:00
|
|
|
actuatorSettingsData.ChannelUpdateFreq[0] = ui->cb_outputRate1->currentText().toUInt();
|
|
|
|
actuatorSettingsData.ChannelUpdateFreq[1] = ui->cb_outputRate2->currentText().toUInt();
|
|
|
|
actuatorSettingsData.ChannelUpdateFreq[2] = ui->cb_outputRate3->currentText().toUInt();
|
|
|
|
actuatorSettingsData.ChannelUpdateFreq[3] = ui->cb_outputRate4->currentText().toUInt();
|
|
|
|
actuatorSettingsData.ChannelUpdateFreq[4] = ui->cb_outputRate5->currentText().toUInt();
|
|
|
|
actuatorSettingsData.ChannelUpdateFreq[5] = ui->cb_outputRate6->currentText().toUInt();
|
|
|
|
|
|
|
|
actuatorSettingsData.MotorsSpinWhileArmed = ui->spinningArmed->isChecked() ?
|
2013-05-19 16:37:30 +02:00
|
|
|
ActuatorSettings::MOTORSSPINWHILEARMED_TRUE :
|
|
|
|
ActuatorSettings::MOTORSSPINWHILEARMED_FALSE;
|
2012-05-28 17:40:35 +02:00
|
|
|
|
|
|
|
// Apply settings
|
|
|
|
actuatorSettings->setData(actuatorSettingsData);
|
|
|
|
}
|
2011-03-28 17:39:22 +02:00
|
|
|
}
|
|
|
|
|
2011-05-31 09:16:01 +02:00
|
|
|
void ConfigOutputWidget::openHelp()
|
|
|
|
{
|
2014-05-10 11:56:24 +02:00
|
|
|
QDesktopServices::openUrl(QUrl(tr("http://wiki.openpilot.org/x/WIGf"), QUrl::StrictMode));
|
2011-05-31 09:16:01 +02:00
|
|
|
}
|
2011-03-28 17:39:22 +02:00
|
|
|
|
2011-10-15 22:16:34 +02:00
|
|
|
void ConfigOutputWidget::stopTests()
|
|
|
|
{
|
2013-05-04 00:13:15 +02:00
|
|
|
ui->channelOutTest->setChecked(false);
|
2011-10-15 22:16:34 +02:00
|
|
|
}
|
2011-11-11 17:51:04 +01:00
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
void ConfigOutputWidget::disableIfNotMe(UAVObject *obj)
|
2011-10-16 01:57:59 +02:00
|
|
|
{
|
2013-05-19 16:37:30 +02:00
|
|
|
if (UAVObject::GetGcsTelemetryUpdateMode(obj->getMetadata()) == UAVObject::UPDATEMODE_ONCHANGE) {
|
|
|
|
if (!wasItMe) {
|
2011-10-16 01:57:59 +02:00
|
|
|
this->setEnabled(false);
|
2013-03-11 23:22:10 +01:00
|
|
|
}
|
2013-05-19 16:37:30 +02:00
|
|
|
} else {
|
2011-10-16 01:57:59 +02:00
|
|
|
this->setEnabled(true);
|
2013-03-11 23:22:10 +01:00
|
|
|
}
|
2011-10-16 01:57:59 +02:00
|
|
|
}
|