1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

LP-551 Really disable all UI in Output tab while calibrating inputs

This commit is contained in:
Laurent Lalanne 2018-01-14 19:14:44 +01:00
parent 5f72771b3c
commit f93ebd4891
3 changed files with 52 additions and 12 deletions

View File

@ -778,8 +778,18 @@ QString ConfigOutputWidget::bankModeName(int index)
void ConfigOutputWidget::inputCalibrationStatus(bool started)
{
// Disable controls if a input calibration is started
// Disable UI when a input calibration is started
// so user cannot manipulate settings.
enableControls(!started);
// Disable every channel form
for (unsigned int i = 0; i < ActuatorCommand::CHANNEL_NUMELEM; i++) {
OutputChannelForm *form = getOutputChannelForm(i);
form->ui->actuatorRev->setChecked(false);
form->ui->actuatorLink->setChecked(false);
form->inputCalibrationStatus(started);
form->enableControls(!started);
}
}
OutputBankControls::OutputBankControls(MixerSettings *mixer, QLabel *label, QColor color, QComboBox *rateCombo, QComboBox *modeCombo) :

View File

@ -31,7 +31,7 @@
#include <QDebug>
OutputChannelForm::OutputChannelForm(const int index, QWidget *parent) :
ChannelForm(index, parent), ui(new Ui::outputChannelForm), m_inChannelTest(false)
ChannelForm(index, parent), ui(new Ui::outputChannelForm), m_inChannelTest(false), m_isCalibratingInput(false)
{
ui->setupUi(this);
@ -120,6 +120,17 @@ void OutputChannelForm::enableChannelTest(bool state)
}
}
/**
* Update the input calibration status
*/
void OutputChannelForm::inputCalibrationStatus(bool state)
{
if (m_isCalibratingInput == state) {
return;
}
m_isCalibratingInput = state;
}
/**
* Toggles the channel linked state for use in testing mode
*/
@ -242,21 +253,18 @@ void OutputChannelForm::setChannelRange()
setLimits(1000, 1000, 1000, 1000);
ui->actuatorMin->setValue(1000);
ui->actuatorMax->setValue(1000);
ui->actuatorMin->setEnabled(false);
ui->actuatorMax->setEnabled(false);
ui->actuatorRev->setEnabled(false);
ui->actuatorLink->setEnabled(false);
ui->actuatorValue->setEnabled(false);
ui->actuatorRev->setChecked(false);
ui->actuatorLink->setChecked(false);
enableControls(false);
return;
}
ui->actuatorMin->setEnabled(true);
ui->actuatorMax->setEnabled(true);
ui->actuatorNeutral->setEnabled(true);
ui->actuatorValue->setEnabled(true);
ui->actuatorLink->setEnabled(true);
if (m_isCalibratingInput) {
// Nothing to do here
return;
}
enableControls(true);
int minValue = ui->actuatorMin->value();
int maxValue = ui->actuatorMax->value();
@ -323,6 +331,25 @@ void OutputChannelForm::reverseChannel(bool state)
}
}
/**
* Enable/Disable all UI controls
*/
void OutputChannelForm::enableControls(bool state)
{
ui->actuatorMin->setEnabled(state);
ui->actuatorMax->setEnabled(state);
ui->actuatorValue->setEnabled(state);
ui->actuatorLink->setEnabled(state);
// Reverse checkbox will be never checked
// or enabled for normal motor
if (isNormalMotor()) {
ui->actuatorRev->setChecked(false);
ui->actuatorRev->setEnabled(false);
} else {
ui->actuatorRev->setEnabled(state);
}
}
/**
* Emits the channel value which will be send to the UAV to move the servo.
* Returns immediately if we are not in testing mode.

View File

@ -61,6 +61,8 @@ public slots:
void setNeutral(int value);
void setRange(int minimum, int maximum);
void enableChannelTest(bool state);
void inputCalibrationStatus(bool state);
void enableControls(bool state);
QString outputMixerType();
void setLimits(int actuatorMinMinimum, int actuatorMinMaximum, int actuatorMaxMinimum, int actuatorMaxMaximum);
int neutralValue();
@ -75,6 +77,7 @@ signals:
private:
Ui::outputChannelForm *ui;
bool m_inChannelTest;
bool m_isCalibratingInput;
QString m_mixerType;
private slots: