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

OP-1222 Added reversed for servos. Beautification of fixed wing page.

This commit is contained in:
m_thread 2014-08-26 01:22:35 +02:00
parent 73ca58ce0f
commit a9dad6f4df
2 changed files with 37 additions and 21 deletions

View File

@ -49,11 +49,11 @@ p, li { white-space: pre-wrap; }
</property>
<item>
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>125</width>
<height>36</height>
</size>
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
@ -69,6 +69,12 @@ p, li { white-space: pre-wrap; }
</item>
<item>
<widget class="QComboBox" name="typeCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>125</width>
@ -82,7 +88,7 @@ p, li { white-space: pre-wrap; }
<item>
<widget class="QTextEdit" name="typeDescription">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

View File

@ -45,16 +45,6 @@ OutputCalibrationPage::OutputCalibrationPage(SetupWizard *wizard, QWidget *paren
// move the code that was here to setupVehicle() so we can determine which image to use.
m_vehicleScene = new QGraphicsScene(this);
ui->vehicleView->setScene(m_vehicleScene);
connect(ui->motorNeutralButton, SIGNAL(toggled(bool)), this, SLOT(on_motorNeutralButton_toggled(bool)));
connect(ui->motorNeutralSlider, SIGNAL(valueChanged(int)), this, SLOT(on_motorNeutralSlider_valueChanged(int)));
connect(ui->servoButton, SIGNAL(toggled(bool)), this, SLOT(on_servoButton_toggled(bool)));
connect(ui->servoMinAngleSlider, SIGNAL(valueChanged(int)), this, SLOT(on_servoMinAngleSlider_valueChanged(int)));
connect(ui->servoCenterAngleSlider, SIGNAL(valueChanged(int)), this, SLOT(on_servoCenterAngleSlider_valueChanged(int)));
connect(ui->servoMaxAngleSlider, SIGNAL(valueChanged(int)), this, SLOT(on_servoMaxAngleSlider_valueChanged(int)));
connect(ui->reverseCheckbox, SIGNAL(toggled(bool)), this, SLOT(on_reverseCheckbox_toggled(bool)));
}
OutputCalibrationPage::~OutputCalibrationPage()
@ -292,6 +282,12 @@ void OutputCalibrationPage::setWizardPage()
if (currentPageIndex == 1) {
ui->motorNeutralSlider->setValue(m_actuatorSettings[currentChannel].channelNeutral);
} else if (currentPageIndex == 2) {
if (m_actuatorSettings[currentChannel].channelMax < m_actuatorSettings[currentChannel].channelMin &&
!ui->reverseCheckbox->isChecked()) {
ui->reverseCheckbox->setChecked(true);
} else {
ui->reverseCheckbox->setChecked(false);
}
enableServoSliders(false);
if (ui->reverseCheckbox->isChecked()) {
ui->servoMaxAngleSlider->setValue(m_actuatorSettings[currentChannel].channelMax);
@ -403,8 +399,7 @@ void OutputCalibrationPage::enableServoSliders(bool enabled)
ui->servoCenterAngleSlider->setEnabled(enabled);
ui->servoMinAngleSlider->setEnabled(enabled);
ui->servoMaxAngleSlider->setEnabled(enabled);
//ui->reverseCheckbox->setEnabled(!enabled);
ui->reverseCheckbox->setEnabled(false);
ui->reverseCheckbox->setEnabled(!enabled);
}
bool OutputCalibrationPage::checkAlarms()
@ -547,14 +542,29 @@ void OutputCalibrationPage::on_servoMaxAngleSlider_valueChanged(int position)
void OutputCalibrationPage::on_reverseCheckbox_toggled(bool checked)
{
if (m_actuatorSettings[getCurrentChannel()].channelMax > m_actuatorSettings[getCurrentChannel()].channelMin) {
if (checked && m_actuatorSettings[getCurrentChannel()].channelMax > m_actuatorSettings[getCurrentChannel()].channelMin) {
quint16 oldMax = m_actuatorSettings[getCurrentChannel()].channelMax;
m_actuatorSettings[getCurrentChannel()].channelMax = m_actuatorSettings[getCurrentChannel()].channelMin;
m_actuatorSettings[getCurrentChannel()].channelMin = oldMax;
} else if (m_actuatorSettings[getCurrentChannel()].channelMax < m_actuatorSettings[getCurrentChannel()].channelMin) {
} else if (!checked && m_actuatorSettings[getCurrentChannel()].channelMax < m_actuatorSettings[getCurrentChannel()].channelMin) {
quint16 oldMax = m_actuatorSettings[getCurrentChannel()].channelMax;
m_actuatorSettings[getCurrentChannel()].channelMax = m_actuatorSettings[getCurrentChannel()].channelMin;
m_actuatorSettings[getCurrentChannel()].channelMin = oldMax;
}
setWizardPage();
ui->servoCenterAngleSlider->setInvertedAppearance(checked);
ui->servoCenterAngleSlider->setInvertedControls(checked);
ui->servoMinAngleSlider->setInvertedAppearance(checked);
ui->servoMinAngleSlider->setInvertedControls(checked);
ui->servoMaxAngleSlider->setInvertedAppearance(checked);
ui->servoMaxAngleSlider->setInvertedControls(checked);
if (ui->reverseCheckbox->isChecked()) {
ui->servoMaxAngleSlider->setValue(m_actuatorSettings[getCurrentChannel()].channelMax);
ui->servoCenterAngleSlider->setValue(m_actuatorSettings[getCurrentChannel()].channelNeutral);
ui->servoMinAngleSlider->setValue(m_actuatorSettings[getCurrentChannel()].channelMin);
} else {
ui->servoMinAngleSlider->setValue(m_actuatorSettings[getCurrentChannel()].channelMin);
ui->servoCenterAngleSlider->setValue(m_actuatorSettings[getCurrentChannel()].channelNeutral);
ui->servoMaxAngleSlider->setValue(m_actuatorSettings[getCurrentChannel()].channelMax);
}
}