2011-08-04 17:58:41 +02:00
|
|
|
#include "inputchannelform.h"
|
|
|
|
#include "ui_inputchannelform.h"
|
|
|
|
|
2011-09-07 08:47:10 +02:00
|
|
|
#include "manualcontrolsettings.h"
|
2012-03-10 03:00:00 +01:00
|
|
|
#include "gcsreceiver.h"
|
2011-09-07 08:47:10 +02:00
|
|
|
|
2014-05-12 22:30:50 +02:00
|
|
|
InputChannelForm::InputChannelForm(const int index, QWidget *parent) :
|
|
|
|
ChannelForm(index, parent), ui(new Ui::InputChannelForm)
|
2011-08-04 17:58:41 +02:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2013-05-05 12:45:35 +02:00
|
|
|
|
2014-05-10 20:40:14 +02:00
|
|
|
connect(ui->channelMin, SIGNAL(valueChanged(int)), this, SLOT(minMaxUpdated()));
|
|
|
|
connect(ui->channelMax, SIGNAL(valueChanged(int)), this, SLOT(minMaxUpdated()));
|
|
|
|
connect(ui->neutralValue, SIGNAL(valueChanged(int)), this, SLOT(neutralUpdated()));
|
|
|
|
connect(ui->channelGroup, SIGNAL(currentIndexChanged(int)), this, SLOT(groupUpdated()));
|
|
|
|
connect(ui->channelRev, SIGNAL(toggled(bool)), this, SLOT(reversedUpdated()));
|
|
|
|
|
|
|
|
disableMouseWheelEvents();
|
|
|
|
}
|
|
|
|
|
|
|
|
InputChannelForm::~InputChannelForm()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2014-05-12 22:30:50 +02:00
|
|
|
QString InputChannelForm::name()
|
2014-05-10 20:40:14 +02:00
|
|
|
{
|
2014-05-12 22:30:50 +02:00
|
|
|
return ui->channelName->text();
|
2011-08-04 17:58:41 +02:00
|
|
|
}
|
2012-04-19 19:00:20 +02:00
|
|
|
|
2014-05-12 22:30:50 +02:00
|
|
|
/**
|
|
|
|
* Set the channel assignment label.
|
|
|
|
*/
|
|
|
|
void InputChannelForm::setName(const QString &name)
|
2012-02-18 21:37:30 +01:00
|
|
|
{
|
|
|
|
ui->channelName->setText(name);
|
|
|
|
}
|
2011-09-07 08:47:10 +02:00
|
|
|
|
2011-09-09 07:54:47 +02:00
|
|
|
/**
|
2013-05-05 12:45:35 +02:00
|
|
|
* Update the direction of the slider and boundaries
|
|
|
|
*/
|
2014-01-21 00:06:20 +01:00
|
|
|
void InputChannelForm::minMaxUpdated()
|
2011-09-07 08:47:10 +02:00
|
|
|
{
|
2011-09-09 07:54:47 +02:00
|
|
|
bool reverse = ui->channelMin->value() > ui->channelMax->value();
|
2013-05-05 12:45:35 +02:00
|
|
|
|
|
|
|
if (reverse) {
|
2011-09-09 07:54:47 +02:00
|
|
|
ui->channelNeutral->setMinimum(ui->channelMax->value());
|
|
|
|
ui->channelNeutral->setMaximum(ui->channelMin->value());
|
|
|
|
} else {
|
|
|
|
ui->channelNeutral->setMinimum(ui->channelMin->value());
|
|
|
|
ui->channelNeutral->setMaximum(ui->channelMax->value());
|
|
|
|
}
|
|
|
|
ui->channelRev->setChecked(reverse);
|
|
|
|
ui->channelNeutral->setInvertedAppearance(reverse);
|
|
|
|
ui->channelNeutral->setInvertedControls(reverse);
|
2011-09-07 08:47:10 +02:00
|
|
|
}
|
|
|
|
|
2014-01-21 00:49:46 +01:00
|
|
|
void InputChannelForm::neutralUpdated()
|
2011-09-07 08:47:10 +02:00
|
|
|
{
|
2014-01-21 00:49:46 +01:00
|
|
|
int neutralValue = ui->neutralValue->value();
|
2014-01-22 18:30:30 +01:00
|
|
|
|
|
|
|
if (ui->channelRev->isChecked()) {
|
|
|
|
if (neutralValue > ui->channelMin->value()) {
|
2014-01-21 00:49:46 +01:00
|
|
|
ui->channelMin->setValue(neutralValue);
|
2014-01-22 18:30:30 +01:00
|
|
|
} else if (neutralValue < ui->channelMax->value()) {
|
2014-01-21 00:49:46 +01:00
|
|
|
ui->channelMax->setValue(neutralValue);
|
|
|
|
}
|
|
|
|
} else {
|
2014-01-22 18:30:30 +01:00
|
|
|
if (neutralValue < ui->channelMin->value()) {
|
2014-01-21 00:49:46 +01:00
|
|
|
ui->channelMin->setValue(neutralValue);
|
2014-01-22 18:30:30 +01:00
|
|
|
} else if (neutralValue > ui->channelMax->value()) {
|
2014-01-21 00:49:46 +01:00
|
|
|
ui->channelMax->setValue(neutralValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void InputChannelForm::reversedUpdated()
|
|
|
|
{
|
|
|
|
int value = ui->channelNeutral->value();
|
2014-01-22 18:30:30 +01:00
|
|
|
int min = ui->channelMin->value();
|
|
|
|
int max = ui->channelMax->value();
|
2014-01-21 00:49:46 +01:00
|
|
|
|
2014-01-22 18:30:30 +01:00
|
|
|
if (ui->channelRev->isChecked()) {
|
|
|
|
if (min < max) {
|
2014-01-21 00:49:46 +01:00
|
|
|
ui->channelMax->setValue(min);
|
|
|
|
ui->channelMin->setValue(max);
|
|
|
|
ui->channelNeutral->setValue(value);
|
|
|
|
}
|
|
|
|
} else {
|
2014-01-22 18:30:30 +01:00
|
|
|
if (min > max) {
|
2014-01-21 00:49:46 +01:00
|
|
|
ui->channelMax->setValue(min);
|
|
|
|
ui->channelMin->setValue(max);
|
|
|
|
ui->channelNeutral->setValue(value);
|
|
|
|
}
|
|
|
|
}
|
2011-09-07 08:47:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-05-05 12:45:35 +02:00
|
|
|
* Update the channel options based on the selected receiver type
|
|
|
|
*
|
|
|
|
* I fully admit this is terrible practice to embed data within UI
|
|
|
|
* like this. Open to suggestions. JC 2011-09-07
|
|
|
|
*/
|
2014-01-21 00:06:20 +01:00
|
|
|
void InputChannelForm::groupUpdated()
|
2011-09-07 08:47:10 +02:00
|
|
|
{
|
2014-05-10 20:40:14 +02:00
|
|
|
ui->channelNumber->clear();
|
|
|
|
ui->channelNumber->addItem("Disabled");
|
2011-09-07 08:47:10 +02:00
|
|
|
|
|
|
|
quint8 count = 0;
|
|
|
|
|
2013-05-05 12:45:35 +02:00
|
|
|
switch (ui->channelGroup->currentIndex()) {
|
2011-09-07 08:47:10 +02:00
|
|
|
case -1: // Nothing selected
|
|
|
|
count = 0;
|
|
|
|
break;
|
|
|
|
case ManualControlSettings::CHANNELGROUPS_PWM:
|
|
|
|
count = 8; // Need to make this 6 for CC
|
|
|
|
break;
|
|
|
|
case ManualControlSettings::CHANNELGROUPS_PPM:
|
2012-12-14 05:07:19 +01:00
|
|
|
case ManualControlSettings::CHANNELGROUPS_OPLINK:
|
2011-10-30 18:29:03 +01:00
|
|
|
case ManualControlSettings::CHANNELGROUPS_DSMMAINPORT:
|
|
|
|
case ManualControlSettings::CHANNELGROUPS_DSMFLEXIPORT:
|
2011-09-07 08:47:10 +02:00
|
|
|
count = 12;
|
|
|
|
break;
|
2011-09-11 21:04:03 +02:00
|
|
|
case ManualControlSettings::CHANNELGROUPS_SBUS:
|
|
|
|
count = 18;
|
|
|
|
break;
|
2011-09-07 08:47:10 +02:00
|
|
|
case ManualControlSettings::CHANNELGROUPS_GCS:
|
2012-03-10 03:00:00 +01:00
|
|
|
count = GCSReceiver::CHANNEL_NUMELEM;
|
2011-12-05 05:33:27 +01:00
|
|
|
break;
|
2011-09-07 08:47:10 +02:00
|
|
|
case ManualControlSettings::CHANNELGROUPS_NONE:
|
|
|
|
count = 0;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Q_ASSERT(0);
|
|
|
|
}
|
|
|
|
|
2013-05-05 12:45:35 +02:00
|
|
|
for (int i = 0; i < count; i++) {
|
2014-05-10 20:40:14 +02:00
|
|
|
ui->channelNumber->addItem(QString(tr("Chan %1").arg(i + 1)));
|
2013-05-05 12:45:35 +02:00
|
|
|
}
|
2011-09-07 08:47:10 +02:00
|
|
|
}
|