1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-15 07:29:15 +01:00

OP-1351 temperature (absolute and variance) are displayed again. cleaned up related code.

This commit is contained in:
Philippe Renon 2014-05-22 21:22:54 +02:00
parent 4feaa72998
commit 297671ae68
4 changed files with 92 additions and 34 deletions

View File

@ -45,8 +45,8 @@ class ThermalCalibrationModel : public WizardModel {
Q_PROPERTY(bool endEnable READ endEnabled NOTIFY endEnabledChanged)
Q_PROPERTY(bool cancelEnable READ cancelEnabled NOTIFY cancelEnabledChanged)
Q_PROPERTY(QString temperature READ temperature NOTIFY temperatureChanged)
Q_PROPERTY(QString temperatureGradient READ temperatureGradient NOTIFY temperatureGradientChanged)
Q_PROPERTY(float temperature READ temperature NOTIFY temperatureChanged)
Q_PROPERTY(float temperatureGradient READ temperatureGradient NOTIFY temperatureGradientChanged)
Q_PROPERTY(int progress READ progress WRITE setProgress NOTIFY progressChanged)
Q_OBJECT
@ -99,33 +99,29 @@ public slots:
return m_progress;
}
QString temperature()
float temperature()
{
return m_temperature;
}
QString temperatureGradient()
float temperatureGradient()
{
return m_temperatureGradient;
}
void setTemperature(float status)
void setTemperature(float temp)
{
QString tmp = QString("%1").arg(status, 5, 'f', 2);
if (m_temperature != tmp) {
m_temperature = tmp;
emit temperatureChanged(tmp);
if (m_temperature != temp) {
m_temperature = temp;
emit temperatureChanged(m_temperature);
}
}
void setTemperatureGradient(float status)
void setTemperatureGradient(float tempGradient)
{
QString tmp = QString("%1").arg(status, 5, 'f', 2);
if (m_temperatureGradient != tmp) {
m_temperatureGradient = tmp;
emit temperatureGradientChanged(tmp);
if (m_temperatureGradient != tempGradient) {
m_temperatureGradient = tempGradient;
emit temperatureGradientChanged(m_temperatureGradient);
}
}
@ -144,8 +140,8 @@ private:
bool m_endEnabled;
bool m_initDone;
int m_progress;
QString m_temperature;
QString m_temperatureGradient;
float m_temperature;
float m_temperatureGradient;
QScopedPointer<ThermalCalibrationHelper> m_helper;
@ -177,8 +173,8 @@ signals:
void endEnabledChanged(bool state);
void cancelEnabledChanged(bool state);
void temperatureChanged(QString status);
void temperatureGradientChanged(QString status);
void temperatureChanged(float temp);
void temperatureGradientChanged(float tempGradient);
void progressChanged(int value);
void next();
@ -190,7 +186,11 @@ signals:
void init();
void btnStart()
{
setInstructions("");
// HACKS
// clear instructions
setInstructions(QString());
emit temperatureGradientChanged(0);
// END OF HACKS
emit next();
}
void btnEnd()

View File

@ -95,6 +95,8 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
// connect the thermalCalibration model to UI
m_thermalCalibrationModel = new OpenPilot::ThermalCalibrationModel(this);
m_thermalCalibrationModel->init();
m_ui->temperatureLabel->setText("");
m_ui->temperatureGradientLabel->setText("");
connect(m_ui->ThermalBiasStart, SIGNAL(clicked()), m_thermalCalibrationModel, SLOT(btnStart()));
connect(m_ui->ThermalBiasEnd, SIGNAL(clicked()), m_thermalCalibrationModel, SLOT(btnEnd()));
@ -106,8 +108,8 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
connect(m_thermalCalibrationModel, SIGNAL(displayInstructions(QString, WizardModel::MessageType)),
this, SLOT(displayInstructions(QString, WizardModel::MessageType)));
// connect(m_thermalCalibrationModel, SIGNAL(temperatureChanged(QString)), m_ui->textTemperature, SLOT(setText(QString)));
// connect(m_thermalCalibrationModel, SIGNAL(temperatureGradientChanged(QString)), m_ui->textThermalGradient, SLOT(setText(QString)));
connect(m_thermalCalibrationModel, SIGNAL(temperatureChanged(float)), this, SLOT(displayTemperature(float)));
connect(m_thermalCalibrationModel, SIGNAL(temperatureGradientChanged(float)), this, SLOT(displayTemperatureGradient(float)));
connect(m_thermalCalibrationModel, SIGNAL(progressChanged(int)), m_ui->thermalBiasProgress, SLOT(setValue(int)));
// note: init for m_thermalCalibrationModel is done in showEvent to prevent cases wiht "Start" button not enabled due to some itming issue.
@ -242,7 +244,7 @@ void ConfigRevoWidget::displayVisualHelp(QString elementID)
void ConfigRevoWidget::displayInstructions(QString text, WizardModel::MessageType type, bool clear)
{
if (clear || text.isEmpty()) {
if (clear || text.isNull()) {
m_ui->calibrationInstructions->clear();
}
if (!text.isNull()) {
@ -261,6 +263,15 @@ void ConfigRevoWidget::displayInstructions(QString text, WizardModel::MessageTyp
}
}
void ConfigRevoWidget::displayTemperature(float temp) {
m_ui->temperatureLabel->setText(tr("Temperature %1 °C").arg(temp, 5, 'f', 2));
}
void ConfigRevoWidget::displayTemperatureGradient(float tempGradient)
{
m_ui->temperatureGradientLabel->setText(tr("Temperature rise %1 °C/min").arg(tempGradient, 5, 'f', 2));
}
/********** UI Functions *************/
/**

View File

@ -65,10 +65,12 @@ private:
bool isBoardRotationStored;
private slots:
void displayVisualHelp(QString elementID);
void storeAndClearBoardRotation();
void recallBoardRotation();
void displayVisualHelp(QString elementID);
void displayInstructions(QString instructions, WizardModel::MessageType type = WizardModel::Info, bool clear = false);
void displayTemperature(float temp);
void displayTemperatureGradient(float tempGradient);
// ! Overriden method from the configTaskWidget to update UI
virtual void refreshWidgetsValues(UAVObject *object = NULL);

View File

@ -275,17 +275,62 @@
</layout>
</item>
<item>
<widget class="QLabel" name="temperatureLabel">
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>12</number>
</property>
<property name="text">
<string>&lt;temperature information&gt;</string>
<property name="leftMargin">
<number>0</number>
</property>
</widget>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="temperatureLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font">
<font>
<weight>50</weight>
<bold>false</bold>
</font>
</property>
<property name="text">
<string>&lt;temperature&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="temperatureGradientLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;temperature gradient&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>