29 #include <QMessageBox>
32 #include "ui_biascalibrationpage.h"
38 , m_calibrationUtil(nullptr)
41 connect(ui->levelButton, &QAbstractButton::clicked,
this,
42 &BiasCalibrationPage::performCalibration);
57 return ui->levelButton->isEnabled();
60 void BiasCalibrationPage::enableButtons(
bool enable)
62 ui->levelButton->setEnabled(enable);
63 getWizard()->button(QWizard::NextButton)->setEnabled(enable);
64 getWizard()->button(QWizard::CancelButton)->setEnabled(enable);
65 getWizard()->button(QWizard::BackButton)->setEnabled(enable);
66 getWizard()->button(QWizard::CustomButton1)->setEnabled(enable);
67 QApplication::processEvents();
70 void BiasCalibrationPage::performCalibration()
72 if (!
getWizard()->getConnectionManager()->isConnected()) {
73 QMessageBox msgBox(
this);
74 msgBox.setText(tr(
"A flight controller must be connected to your computer to perform bias "
75 "calculations.\nPlease connect your flight controller to your computer "
77 msgBox.setStandardButtons(QMessageBox::Ok);
78 msgBox.setDefaultButton(QMessageBox::Ok);
84 if (!m_calibrationUtil) {
87 Q_ASSERT(m_calibrationUtil);
88 if (!m_calibrationUtil)
93 ui->progressLabel->setText(QString(tr(
"Retrieving data...")));
95 QTimer *timer =
new QTimer(
this);
96 timer->setSingleShot(
true);
97 timer->setInterval(30000);
100 &BiasCalibrationPage::calibrationProgress);
102 &BiasCalibrationPage::calibrationDone);
104 connect(timer, &QTimer::timeout,
this, &BiasCalibrationPage::calibrationTimeout);
109 void BiasCalibrationPage::calibrationProgress(
int current)
111 const int total = 100;
112 if (ui->levellinProgressBar->maximum() != (int)total) {
113 ui->levellinProgressBar->setMaximum((
int)total);
115 if (ui->levellinProgressBar->value() != (int)current) {
116 ui->levellinProgressBar->setValue((
int)current);
120 void BiasCalibrationPage::calibrationDone()
122 disconnect(
this, SLOT(calibrationTimeout()));
124 emit completeChanged();
127 void BiasCalibrationPage::calibrationTimeout()
131 QMessageBox msgBox(
this);
132 msgBox.setText(tr(
"Calibration timed out"));
133 msgBox.setStandardButtons(QMessageBox::Ok);
134 msgBox.setDefaultButton(QMessageBox::Ok);
138 void BiasCalibrationPage::stopCalibration()
140 if (m_calibrationUtil) {
142 &BiasCalibrationPage::calibrationProgress);
144 &BiasCalibrationPage::calibrationDone);
145 ui->progressLabel->setText(QString(tr(
"<font color='green'>Done!</font>")));
The SetupWizard class is the main interface to the setup wizard. It provides selects the sequence of ...
void calibrationCompleted()
Indicate that a calibration process has successfully completed and the results saved to UAVO...
The Calibration class is a UI free algorithm that can be connected to any interfaces. As such it only communicates with the UI via signals and slots, but has no direct handles to any particular controls or widgets.
SetupWizard * getWizard() const
Core plugin system that manages the plugins, their life cycle and their registered objects...
BiasCalibrationPage(SetupWizard *wizard, QWidget *parent=nullptr)
void levelingProgressChanged(int)
Indicate what the progress is for leveling.
void doStartBiasAndLeveling()
Start collecting data while vehicle is level.