mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-19 04:52:12 +01:00
Add files to the .pro
This commit is contained in:
parent
f487ed3852
commit
c643abf4fb
@ -25,18 +25,16 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
|
||||
#include "esccalibrationpage.h"
|
||||
#include "ui_esccalibrationpage.h"
|
||||
#include "setupwizard.h"
|
||||
|
||||
EscCalibrationPage::EscCalibrationPage(SetupWizard *wizard, QWidget *parent) :
|
||||
AbstractWizardPage(wizard, parent),
|
||||
ui(new Ui::EscCalibrationPage), m_calibrationUtil(0)
|
||||
ui(new Ui::EscCalibrationPage)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
connect(ui->levelButton, SIGNAL(clicked()), this, SLOT(performCalibration()));
|
||||
}
|
||||
|
||||
EscCalibrationPage::~EscCalibrationPage()
|
||||
@ -48,84 +46,3 @@ bool EscCalibrationPage::validatePage()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool EscCalibrationPage::isComplete() const
|
||||
{
|
||||
return ui->levelButton->isEnabled();
|
||||
}
|
||||
|
||||
void EscCalibrationPage::enableButtons(bool enable)
|
||||
{
|
||||
ui->levelButton->setEnabled(enable);
|
||||
getWizard()->button(QWizard::NextButton)->setEnabled(enable);
|
||||
getWizard()->button(QWizard::CancelButton)->setEnabled(enable);
|
||||
getWizard()->button(QWizard::BackButton)->setEnabled(enable);
|
||||
getWizard()->button(QWizard::CustomButton1)->setEnabled(enable);
|
||||
QApplication::processEvents();
|
||||
}
|
||||
|
||||
void EscCalibrationPage::performCalibration()
|
||||
{
|
||||
if (!getWizard()->getConnectionManager()->isConnected()) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(tr("An OpenPilot controller must be connected to your computer to perform bias "
|
||||
"calculations.\nPlease connect your OpenPilot controller to your computer and try again."));
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
enableButtons(false);
|
||||
ui->progressLabel->setText(QString(tr("Retrieving data...")));
|
||||
|
||||
|
||||
if (!m_calibrationUtil) {
|
||||
m_calibrationUtil = new BiasCalibrationUtil(BIAS_CYCLES, BIAS_RATE);
|
||||
}
|
||||
|
||||
connect(m_calibrationUtil, SIGNAL(progress(long, long)), this, SLOT(calibrationProgress(long, long)));
|
||||
connect(m_calibrationUtil, SIGNAL(done(accelGyroBias)), this, SLOT(calibrationDone(accelGyroBias)));
|
||||
connect(m_calibrationUtil, SIGNAL(timeout(QString)), this, SLOT(calibrationTimeout(QString)));
|
||||
|
||||
m_calibrationUtil->start();
|
||||
}
|
||||
|
||||
void EscCalibrationPage::calibrationProgress(long current, long total)
|
||||
{
|
||||
if (ui->levellinProgressBar->maximum() != (int)total) {
|
||||
ui->levellinProgressBar->setMaximum((int)total);
|
||||
}
|
||||
if (ui->levellinProgressBar->value() != (int)current) {
|
||||
ui->levellinProgressBar->setValue((int)current);
|
||||
}
|
||||
}
|
||||
|
||||
void EscCalibrationPage::calibrationDone(accelGyroBias bias)
|
||||
{
|
||||
stopCalibration();
|
||||
getWizard()->setLevellingBias(bias);
|
||||
emit completeChanged();
|
||||
}
|
||||
|
||||
void EscCalibrationPage::calibrationTimeout(QString message)
|
||||
{
|
||||
stopCalibration();
|
||||
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(message);
|
||||
msgBox.setStandardButtons(QMessageBox::Ok);
|
||||
msgBox.setDefaultButton(QMessageBox::Ok);
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
void EscCalibrationPage::stopCalibration()
|
||||
{
|
||||
if (m_calibrationUtil) {
|
||||
disconnect(m_calibrationUtil, SIGNAL(progress(long, long)), this, SLOT(calibrationProgress(long, long)));
|
||||
disconnect(m_calibrationUtil, SIGNAL(done(accelGyroBias)), this, SLOT(calibrationDone(accelGyroBias)));
|
||||
disconnect(m_calibrationUtil, SIGNAL(timeout(QString)), this, SLOT(calibrationTimeout(QString)));
|
||||
ui->progressLabel->setText(QString(tr("<font color='green'>Done!</font>")));
|
||||
enableButtons(true);
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifndef ESCCALIBRATIONPAGE_H
|
||||
#define ESCCALIBRATIONPAGE_H
|
||||
|
||||
@ -41,23 +43,9 @@ public:
|
||||
explicit EscCalibrationPage(SetupWizard *wizard, QWidget *parent = 0);
|
||||
~EscCalibrationPage();
|
||||
bool validatePage();
|
||||
bool isComplete() const;
|
||||
|
||||
private slots:
|
||||
void performCalibration();
|
||||
void calibrationProgress(long current, long total);
|
||||
void calibrationDone(accelGyroBias bias);
|
||||
void calibrationTimeout(QString message);
|
||||
|
||||
private:
|
||||
static const int BIAS_CYCLES = 200;
|
||||
static const int BIAS_RATE = 50;
|
||||
|
||||
Ui::EscCalibrationPage *ui;
|
||||
BiasCalibrationUtil *m_calibrationUtil;
|
||||
|
||||
void stopCalibration();
|
||||
void enableButtons(bool enable);
|
||||
};
|
||||
|
||||
#endif // ESCCALIBRATIONPAGE_H
|
||||
|
@ -36,6 +36,7 @@ HEADERS += setupwizardplugin.h \
|
||||
pages/autoupdatepage.h \
|
||||
pages/revocalibrationpage.h \
|
||||
biascalibrationutil.h \
|
||||
pages/esccalibrationpage.h \
|
||||
pages/biascalibrationpage.h \
|
||||
pages/escpage.h \
|
||||
pages/servopage.h \
|
||||
@ -70,6 +71,7 @@ SOURCES += setupwizardplugin.cpp \
|
||||
pages/revocalibrationpage.cpp \
|
||||
biascalibrationutil.cpp \
|
||||
pages/biascalibrationpage.cpp \
|
||||
pages/esccalibrationpage.cpp \
|
||||
pages/escpage.cpp \
|
||||
pages/servopage.cpp \
|
||||
pages/selectionpage.cpp \
|
||||
@ -95,6 +97,7 @@ FORMS += \
|
||||
pages/autoupdatepage.ui \
|
||||
pages/revocalibrationpage.ui \
|
||||
pages/biascalibrationpage.ui \
|
||||
pages/esccalibrationpage.ui \
|
||||
pages/escpage.ui \
|
||||
pages/servopage.ui \
|
||||
pages/selectionpage.ui \
|
||||
|
Loading…
x
Reference in New Issue
Block a user