1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

OP-1706 Disable checkboxes if no range - Enable only channels already set in mixer - Add limits

This commit is contained in:
Laurent Lalanne 2015-02-07 13:00:10 +01:00
parent 15afc979d5
commit 9c31d2fcb5

View File

@ -27,13 +27,16 @@
#include "outputchannelform.h"
#define MAXOUTPUT_VALUE 2100
#define MINOUTPUT_VALUE 900
OutputChannelForm::OutputChannelForm(const int index, QWidget *parent) :
ChannelForm(index, parent), ui(), m_inChannelTest(false)
{
ui.setupUi(this);
// The convention for OP is Channel 1 to Channel 10.
ui.actuatorNumber->setText(QString("%1:").arg(index + 1));
ui.actuatorNumber->setText(QString("%1").arg(index + 1));
// Register for ActuatorSettings changes:
connect(ui.actuatorMin, SIGNAL(editingFinished()), this, SLOT(setChannelRange()));
@ -45,6 +48,14 @@ OutputChannelForm::OutputChannelForm(const int index, QWidget *parent) :
ui.actuatorLink->setChecked(false);
connect(ui.actuatorLink, SIGNAL(toggled(bool)), this, SLOT(linkToggled(bool)));
// Set limits
ui.actuatorMin->setMaximum(MAXOUTPUT_VALUE);
ui.actuatorMax->setMaximum(MAXOUTPUT_VALUE);
ui.actuatorValue->setMaximum(MAXOUTPUT_VALUE);
ui.actuatorMin->setMinimum(MINOUTPUT_VALUE);
ui.actuatorMax->setMinimum(MINOUTPUT_VALUE);
ui.actuatorValue->setMinimum(MINOUTPUT_VALUE);
disableMouseWheelEvents();
}
@ -198,10 +209,12 @@ void OutputChannelForm::setRange(int minimum, int maximum)
void OutputChannelForm::setChannelRange()
{
int oldMini = ui.actuatorNeutral->minimum();
int minValue = ui.actuatorMin->value();
int maxValue = ui.actuatorMax->value();
// int oldMaxi = ui.actuatorNeutral->maximum();
if (ui.actuatorMin->value() < ui.actuatorMax->value()) {
if (minValue <= maxValue) {
ui.actuatorNeutral->setRange(ui.actuatorMin->value(), ui.actuatorMax->value());
ui.actuatorRev->setChecked(false);
} else {
@ -213,6 +226,33 @@ void OutputChannelForm::setChannelRange()
ui.actuatorNeutral->setValue(ui.actuatorNeutral->minimum());
}
// Enable only outputs already set in mixer
if (name() != "-") {
ui.actuatorMin->setEnabled(true);
ui.actuatorMax->setEnabled(true);
ui.actuatorNeutral->setEnabled(true);
ui.actuatorValue->setEnabled(true);
// Enable checkboxes Rev and Link if some range
if (minValue != maxValue) {
ui.actuatorRev->setEnabled(true);
ui.actuatorLink->setEnabled(true);
} else {
ui.actuatorRev->setEnabled(false);
ui.actuatorLink->setEnabled(false);
}
} else {
ui.actuatorMin->setEnabled(false);
ui.actuatorMax->setEnabled(false);
ui.actuatorRev->setEnabled(false);
ui.actuatorLink->setEnabled(false);
ui.actuatorMin->setValue(1000);
ui.actuatorMax->setValue(1000);
ui.actuatorNeutral->setRange(minValue, maxValue);
ui.actuatorNeutral->setEnabled(false);
ui.actuatorValue->setEnabled(false);
}
// if (ui.actuatorNeutral->value() == oldMaxi)
// this can be dangerous if it happens to be controlling a motor at the time!
// ui.actuatorNeutral->setValue(ui.actuatorNeutral->maximum());