1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-03 11:24:10 +01:00

Make revo calibration UI use teh configtaskwidget system

This commit is contained in:
James Cotton 2012-06-13 13:08:04 -05:00
parent 7c8700b4e5
commit 7f15e87890
3 changed files with 22 additions and 57 deletions

View File

@ -71,11 +71,14 @@ public:
ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) : ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
ConfigTaskWidget(parent), ConfigTaskWidget(parent),
collectingData(false), collectingData(false),
position(-1), position(-1)
m_ui(new Ui_RevoSensorsWidget())
{ {
m_ui = new Ui_RevoSensorsWidget();
m_ui->setupUi(this); m_ui->setupUi(this);
addUAVObject("RevoCalibration");
autoLoadWidgets();
// Initialization of the Paper plane widget // Initialization of the Paper plane widget
m_ui->sixPointsHelp->setScene(new QGraphicsScene(this)); m_ui->sixPointsHelp->setScene(new QGraphicsScene(this));
@ -209,10 +212,6 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
// Connect the signals // Connect the signals
connect(m_ui->accelBiasStart, SIGNAL(clicked()), this, SLOT(launchAccelBiasCalibration())); connect(m_ui->accelBiasStart, SIGNAL(clicked()), this, SLOT(launchAccelBiasCalibration()));
RevoCalibration * revoCalibration = RevoCalibration::GetInstance(getObjectManager());
Q_ASSERT(revoCalibration);
connect(revoCalibration, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(refreshValues()));
connect(m_ui->revoCalSettingsSaveRAM, SIGNAL(clicked()), this, SLOT(SettingsToRAM())); connect(m_ui->revoCalSettingsSaveRAM, SIGNAL(clicked()), this, SLOT(SettingsToRAM()));
connect(m_ui->revoCalSettingsSaveSD, SIGNAL(clicked()), this, SLOT(SettingsToFlash())); connect(m_ui->revoCalSettingsSaveSD, SIGNAL(clicked()), this, SLOT(SettingsToFlash()));
connect(m_ui->sixPointsStart, SIGNAL(clicked()), this, SLOT(sixPointCalibrationMode())); connect(m_ui->sixPointsStart, SIGNAL(clicked()), this, SLOT(sixPointCalibrationMode()));
@ -221,16 +220,7 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
// Leave this timer permanently connected. The timer itself is started and stopped. // Leave this timer permanently connected. The timer itself is started and stopped.
connect(&progressBarTimer, SIGNAL(timeout()), this, SLOT(incrementProgress())); connect(&progressBarTimer, SIGNAL(timeout()), this, SLOT(incrementProgress()));
// Order is important: 1st request the settings (it will also enable the controls)
// then explicitely disable them. They will be re-enabled right afterwards by the
// configgadgetwidget if the autopilot is actually connected.
refreshValues();
// when the AHRS Widget is instanciated, the autopilot is always connected // enableControls(false);
connect(parent, SIGNAL(autopilotConnected()),this, SLOT(onAutopilotConnect()));
connect(parent, SIGNAL(autopilotDisconnected()), this, SLOT(onAutopilotDisconnect()));
// Connect the help button // Connect the help button
connect(m_ui->Help, SIGNAL(clicked()), this, SLOT(openHelp()));
} }
ConfigRevoWidget::~ConfigRevoWidget() ConfigRevoWidget::~ConfigRevoWidget()
@ -257,12 +247,6 @@ void ConfigRevoWidget::resizeEvent(QResizeEvent *event)
} }
void ConfigRevoWidget::enableControls(bool enable)
{
//m_ui->ahrsSettingsSaveRAM->setEnabled(enable);
m_ui->ahrsSettingsSaveSD->setEnabled(enable);
}
/** /**
Starts an accelerometer bias calibration. Starts an accelerometer bias calibration.
*/ */
@ -752,9 +736,10 @@ void ConfigRevoWidget::drawVariancesGraph()
} }
/** /**
Request current settings from the AHRS * Called by the ConfigTaskWidget parent when RevoCalibration is updated
* to update the UI
*/ */
void ConfigRevoWidget::refreshValues() void ConfigRevoWidget::refreshWidgetsValues(UAVObject *)
{ {
drawVariancesGraph(); drawVariancesGraph();
@ -766,34 +751,6 @@ void ConfigRevoWidget::refreshValues()
m_ui->calibInstructions->setText(QString("Press \"Start\" above to calibrate.")); m_ui->calibInstructions->setText(QString("Press \"Start\" above to calibrate."));
} }
/**
Save current settings to RAM
*/
void ConfigRevoWidget::SettingsToRAM()
{
RevoCalibration * revoCalibration = RevoCalibration::GetInstance(getObjectManager());
Q_ASSERT(revoCalibration);
revoCalibration->updated();
}
/**
Save Revo calibration settings to flash
*/
void ConfigRevoWidget::SettingsToFlash()
{
SettingsToRAM();
RevoCalibration * revoCalibration = RevoCalibration::GetInstance(getObjectManager());
Q_ASSERT(revoCalibration);
saveObjectToSD(revoCalibration);
}
void ConfigRevoWidget::openHelp()
{
QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/Revo+Configuration", QUrl::StrictMode) );
}
/** /**
@} @}
@} @}

View File

@ -54,11 +54,10 @@ public:
private: private:
void drawVariancesGraph(); void drawVariancesGraph();
void displayPlane(QString elementID); void displayPlane(QString elementID);
virtual void enableControls(bool enable);
Ui_RevoSensorsWidget *m_ui; Ui_RevoSensorsWidget *m_ui;
QGraphicsSvgItem *paperplane; QGraphicsSvgItem *paperplane;
QGraphicsSvgItem *ahrsbargraph; QGraphicsSvgItem *sensorsBargraph;
QGraphicsSvgItem *accel_x; QGraphicsSvgItem *accel_x;
QGraphicsSvgItem *accel_y; QGraphicsSvgItem *accel_y;
QGraphicsSvgItem *accel_z; QGraphicsSvgItem *accel_z;
@ -95,13 +94,10 @@ private:
int position; int position;
private slots: private slots:
void openHelp();
void launchAccelBiasCalibration(); void launchAccelBiasCalibration();
void incrementProgress(); void incrementProgress();
virtual void refreshValues(); virtual void refreshWidgetsValues(UAVObject * obj=NULL);
void SettingsToRAM();
void SettingsToFlash();
void savePositionData(); void savePositionData();
void computeScaleBias(); void computeScaleBias();
void sixPointCalibrationMode(); void sixPointCalibrationMode();

View File

@ -670,6 +670,12 @@ new home location unless it is in indoor mode.</string>
<property name="flat"> <property name="flat">
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="objrelation" stdset="0">
<stringlist>
<string>button:help</string>
<string>url:http://wiki.openpilot.org/display/Doc/Revo+Configuration</string>
</stringlist>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -683,6 +689,9 @@ specific calibration button on top of the screen.</string>
<property name="text"> <property name="text">
<string>Apply</string> <string>Apply</string>
</property> </property>
<property name="objrelation" stdset="0">
<string>button:apply</string>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -696,6 +705,9 @@ specific calibration button on top of the screen.</string>
<property name="checked"> <property name="checked">
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="objrelation" stdset="0">
<string>button:save</string>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>