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

OP-1351 cleaned up instruction handling code (less hacky)

This commit is contained in:
Philippe Renon 2014-05-25 20:14:26 +02:00
parent 48558f75e6
commit 0f72ca05e9
9 changed files with 30 additions and 26 deletions

View File

@ -71,7 +71,7 @@ void GyroBiasCalibrationModel::start()
attitudeSettings->updated(); attitudeSettings->updated();
displayVisualHelp(CALIBRATION_HELPER_PLANE_PREFIX + CALIBRATION_HELPER_IMAGE_NED); displayVisualHelp(CALIBRATION_HELPER_PLANE_PREFIX + CALIBRATION_HELPER_IMAGE_NED);
displayInstructions(tr("Calibrating the gyroscopes. Keep the copter/plane steady..."), WizardModel::Notice, true); displayInstructions(tr("Calibrating the gyroscopes. Keep the copter/plane steady..."), WizardModel::Notice);
gyro_accum_x.clear(); gyro_accum_x.clear();
gyro_accum_y.clear(); gyro_accum_y.clear();

View File

@ -47,7 +47,7 @@ public:
signals: signals:
void displayVisualHelp(QString elementID); void displayVisualHelp(QString elementID);
void displayInstructions(QString text, WizardModel::MessageType type = WizardModel::Info, bool clear = false); void displayInstructions(QString text, WizardModel::MessageType type = WizardModel::Info);
void started(); void started();
void stopped(); void stopped();
void storeAndClearBoardRotation(); void storeAndClearBoardRotation();

View File

@ -40,7 +40,6 @@ LevelCalibrationModel::LevelCalibrationModel(QObject *parent) :
{} {}
/******* Level calibration *******/
/** /**
* Starts an accelerometer bias calibration. * Starts an accelerometer bias calibration.
*/ */
@ -64,7 +63,7 @@ void LevelCalibrationModel::start()
attitudeState->setMetadata(mdata); attitudeState->setMetadata(mdata);
/* Show instructions and enable controls */ /* Show instructions and enable controls */
displayInstructions(tr("Place horizontally and click Save Position button..."), WizardModel::Info, true); displayInstructions(tr("Place horizontally and click Save Position button..."), WizardModel::Info);
displayVisualHelp(CALIBRATION_HELPER_PLANE_PREFIX + CALIBRATION_HELPER_IMAGE_NED); displayVisualHelp(CALIBRATION_HELPER_PLANE_PREFIX + CALIBRATION_HELPER_IMAGE_NED);
savePositionEnabledChanged(true); savePositionEnabledChanged(true);
position = 0; position = 0;
@ -134,8 +133,6 @@ void LevelCalibrationModel::getSample(UAVObject *obj)
displayInstructions(tr("Leave horizontally, rotate 180° along yaw axis and click Save Position button...")); displayInstructions(tr("Leave horizontally, rotate 180° along yaw axis and click Save Position button..."));
displayVisualHelp(CALIBRATION_HELPER_PLANE_PREFIX + CALIBRATION_HELPER_IMAGE_SWD); displayVisualHelp(CALIBRATION_HELPER_PLANE_PREFIX + CALIBRATION_HELPER_IMAGE_SWD);
started();
savePositionEnabledChanged(true); savePositionEnabledChanged(true);
break; break;
case 2: case 2:
@ -145,13 +142,13 @@ void LevelCalibrationModel::getSample(UAVObject *obj)
rot_data_roll /= 2; rot_data_roll /= 2;
attitudeState->setMetadata(initialAttitudeStateMdata); attitudeState->setMetadata(initialAttitudeStateMdata);
compute(); compute();
stopped();
displayVisualHelp(CALIBRATION_HELPER_IMAGE_EMPTY); displayVisualHelp(CALIBRATION_HELPER_IMAGE_EMPTY);
displayInstructions(tr("Board leveling completed successfully.")); displayInstructions(tr("Board leveling completed successfully."));
break; break;
} }
} }
} }
void LevelCalibrationModel::compute() void LevelCalibrationModel::compute()
{ {
stopped(); stopped();
@ -168,6 +165,7 @@ void LevelCalibrationModel::compute()
attitudeSettings->setData(attitudeSettingsData); attitudeSettings->setData(attitudeSettingsData);
attitudeSettings->updated(); attitudeSettings->updated();
} }
UAVObjectManager *LevelCalibrationModel::getObjectManager() UAVObjectManager *LevelCalibrationModel::getObjectManager()
{ {
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
@ -176,4 +174,5 @@ UAVObjectManager *LevelCalibrationModel::getObjectManager()
Q_ASSERT(objMngr); Q_ASSERT(objMngr);
return objMngr; return objMngr;
} }
} }

View File

@ -50,7 +50,7 @@ public:
signals: signals:
void displayVisualHelp(QString elementID); void displayVisualHelp(QString elementID);
void displayInstructions(QString text, WizardModel::MessageType type = WizardModel::Info, bool clear = false); void displayInstructions(QString text, WizardModel::MessageType type = WizardModel::Info);
void started(); void started();
void stopped(); void stopped();
void savePositionEnabledChanged(bool state); void savePositionEnabledChanged(bool state);

View File

@ -198,11 +198,11 @@ void SixPointCalibrationModel::start(bool calibrateAccel, bool calibrateMag)
mag->setMetadata(mdata); mag->setMetadata(mdata);
} }
/* Show instructions and enable controls */
displayInstructions((*currentSteps)[0].instructions, WizardModel::Info, true);
showHelp((*currentSteps)[0].visualHelp);
started(); started();
// Show instructions and enable controls
displayInstructions((*currentSteps)[0].instructions, WizardModel::Info);
showHelp((*currentSteps)[0].visualHelp);
savePositionEnabledChanged(true); savePositionEnabledChanged(true);
position = 0; position = 0;
mag_fit_x.clear(); mag_fit_x.clear();
@ -492,7 +492,8 @@ void SixPointCalibrationModel::compute(bool mag, bool accel)
} else { } else {
displayInstructions(tr("Bad calibration. Please review the instructions and repeat."), WizardModel::Error); displayInstructions(tr("Bad calibration. Please review the instructions and repeat."), WizardModel::Error);
} }
position = -1; // set to run again // set to run again
position = -1;
} }
UAVObjectManager *SixPointCalibrationModel::getObjectManager() UAVObjectManager *SixPointCalibrationModel::getObjectManager()
{ {

View File

@ -66,7 +66,7 @@ public:
signals: signals:
void displayVisualHelp(QString elementID); void displayVisualHelp(QString elementID);
void displayInstructions(QString text, WizardModel::MessageType type = WizardModel::Info, bool clear = false); void displayInstructions(QString text, WizardModel::MessageType type = WizardModel::Info);
void started(); void started();
void stopped(); void stopped();
void storeAndClearBoardRotation(); void storeAndClearBoardRotation();

View File

@ -66,7 +66,7 @@ private:
QString m_instructions; QString m_instructions;
signals: signals:
void displayInstructions(QString text, WizardModel::MessageType type = WizardModel::Info, bool clear = false); void displayInstructions(QString text, WizardModel::MessageType type = WizardModel::Info);
void currentStateChanged(WizardState *status); void currentStateChanged(WizardState *status);
}; };

View File

@ -125,8 +125,8 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
connect(m_sixPointCalibrationModel, SIGNAL(stopped()), this, SLOT(enableAllCalibrations())); connect(m_sixPointCalibrationModel, SIGNAL(stopped()), this, SLOT(enableAllCalibrations()));
connect(m_sixPointCalibrationModel, SIGNAL(storeAndClearBoardRotation()), this, SLOT(storeAndClearBoardRotation())); connect(m_sixPointCalibrationModel, SIGNAL(storeAndClearBoardRotation()), this, SLOT(storeAndClearBoardRotation()));
connect(m_sixPointCalibrationModel, SIGNAL(recallBoardRotation()), this, SLOT(recallBoardRotation())); connect(m_sixPointCalibrationModel, SIGNAL(recallBoardRotation()), this, SLOT(recallBoardRotation()));
connect(m_sixPointCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType, bool)), connect(m_sixPointCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType)),
this, SLOT(displayInstructions(QString, WizardModel::MessageType, bool))); this, SLOT(displayInstructions(QString, WizardModel::MessageType)));
connect(m_sixPointCalibrationModel, SIGNAL(displayVisualHelp(QString)), this, SLOT(displayVisualHelp(QString))); connect(m_sixPointCalibrationModel, SIGNAL(displayVisualHelp(QString)), this, SLOT(displayVisualHelp(QString)));
connect(m_sixPointCalibrationModel, SIGNAL(savePositionEnabledChanged(bool)), this->m_ui->sixPointsSave, SLOT(setEnabled(bool))); connect(m_sixPointCalibrationModel, SIGNAL(savePositionEnabledChanged(bool)), this->m_ui->sixPointsSave, SLOT(setEnabled(bool)));
@ -137,8 +137,8 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
connect(m_levelCalibrationModel, SIGNAL(started()), this, SLOT(disableAllCalibrations())); connect(m_levelCalibrationModel, SIGNAL(started()), this, SLOT(disableAllCalibrations()));
connect(m_levelCalibrationModel, SIGNAL(stopped()), this, SLOT(enableAllCalibrations())); connect(m_levelCalibrationModel, SIGNAL(stopped()), this, SLOT(enableAllCalibrations()));
connect(m_levelCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType, bool)), connect(m_levelCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType)),
this, SLOT(displayInstructions(QString, WizardModel::MessageType, bool))); this, SLOT(displayInstructions(QString, WizardModel::MessageType)));
connect(m_levelCalibrationModel, SIGNAL(displayVisualHelp(QString)), this, SLOT(displayVisualHelp(QString))); connect(m_levelCalibrationModel, SIGNAL(displayVisualHelp(QString)), this, SLOT(displayVisualHelp(QString)));
connect(m_levelCalibrationModel, SIGNAL(savePositionEnabledChanged(bool)), this->m_ui->boardLevelSavePos, SLOT(setEnabled(bool))); connect(m_levelCalibrationModel, SIGNAL(savePositionEnabledChanged(bool)), this->m_ui->boardLevelSavePos, SLOT(setEnabled(bool)));
connect(m_levelCalibrationModel, SIGNAL(progressChanged(int)), this->m_ui->boardLevelProgress, SLOT(setValue(int))); connect(m_levelCalibrationModel, SIGNAL(progressChanged(int)), this->m_ui->boardLevelProgress, SLOT(setValue(int)));
@ -153,8 +153,8 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
connect(m_gyroBiasCalibrationModel, SIGNAL(stopped()), this, SLOT(enableAllCalibrations())); connect(m_gyroBiasCalibrationModel, SIGNAL(stopped()), this, SLOT(enableAllCalibrations()));
connect(m_gyroBiasCalibrationModel, SIGNAL(storeAndClearBoardRotation()), this, SLOT(storeAndClearBoardRotation())); connect(m_gyroBiasCalibrationModel, SIGNAL(storeAndClearBoardRotation()), this, SLOT(storeAndClearBoardRotation()));
connect(m_gyroBiasCalibrationModel, SIGNAL(recallBoardRotation()), this, SLOT(recallBoardRotation())); connect(m_gyroBiasCalibrationModel, SIGNAL(recallBoardRotation()), this, SLOT(recallBoardRotation()));
connect(m_gyroBiasCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType, bool)), connect(m_gyroBiasCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType)),
this, SLOT(displayInstructions(QString, WizardModel::MessageType, bool))); this, SLOT(displayInstructions(QString, WizardModel::MessageType)));
connect(m_gyroBiasCalibrationModel, SIGNAL(displayVisualHelp(QString)), this, SLOT(displayVisualHelp(QString))); connect(m_gyroBiasCalibrationModel, SIGNAL(displayVisualHelp(QString)), this, SLOT(displayVisualHelp(QString)));
connect(m_ui->hlClearButton, SIGNAL(clicked()), this, SLOT(clearHomeLocation())); connect(m_ui->hlClearButton, SIGNAL(clicked()), this, SLOT(clearHomeLocation()));
@ -242,11 +242,13 @@ void ConfigRevoWidget::displayVisualHelp(QString elementID)
updateVisualHelp(); updateVisualHelp();
} }
void ConfigRevoWidget::displayInstructions(QString text, WizardModel::MessageType type, bool clear) void ConfigRevoWidget::clearInstructions()
{ {
if (clear || text.isNull()) {
m_ui->calibrationInstructions->clear(); m_ui->calibrationInstructions->clear();
} }
void ConfigRevoWidget::displayInstructions(QString text, WizardModel::MessageType type)
{
if (!text.isNull()) { if (!text.isNull()) {
switch(type) { switch(type) {
case WizardModel::Error: case WizardModel::Error:
@ -314,6 +316,7 @@ void ConfigRevoWidget::clearHomeLocation()
void ConfigRevoWidget::disableAllCalibrations() void ConfigRevoWidget::disableAllCalibrations()
{ {
clearInstructions();
m_ui->sixPointsStartAccel->setEnabled(false); m_ui->sixPointsStartAccel->setEnabled(false);
m_ui->sixPointsStartMag->setEnabled(false); m_ui->sixPointsStartMag->setEnabled(false);
m_ui->boardLevelStart->setEnabled(false); m_ui->boardLevelStart->setEnabled(false);

View File

@ -68,7 +68,8 @@ private slots:
void storeAndClearBoardRotation(); void storeAndClearBoardRotation();
void recallBoardRotation(); void recallBoardRotation();
void displayVisualHelp(QString elementID); void displayVisualHelp(QString elementID);
void displayInstructions(QString instructions, WizardModel::MessageType type = WizardModel::Info, bool clear = false); void clearInstructions();
void displayInstructions(QString instructions, WizardModel::MessageType type = WizardModel::Info);
void displayTemperature(float temp); void displayTemperature(float temp);
void displayTemperatureGradient(float tempGradient); void displayTemperatureGradient(float tempGradient);