From c643abf4fb8da929e2b3ad42d0fd9ebb22409008 Mon Sep 17 00:00:00 2001 From: Fredrik Larson Date: Sun, 28 Sep 2014 15:11:40 +1000 Subject: [PATCH] Add files to the .pro --- .../setupwizard/pages/esccalibrationpage.cpp | 87 +------------------ .../setupwizard/pages/esccalibrationpage.h | 16 +--- .../src/plugins/setupwizard/setupwizard.pro | 3 + 3 files changed, 7 insertions(+), 99 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.cpp b/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.cpp index 766d1aa75..a2c6b29f0 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.cpp +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.cpp @@ -25,18 +25,16 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include -#include + #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("Done!"))); - enableButtons(true); - } -} diff --git a/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.h b/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.h index 5c1a55f11..c546270ba 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.h +++ b/ground/openpilotgcs/src/plugins/setupwizard/pages/esccalibrationpage.h @@ -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 diff --git a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro index d6990971b..6dee3e178 100644 --- a/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro +++ b/ground/openpilotgcs/src/plugins/setupwizard/setupwizard.pro @@ -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 \