+/*
+ * Acceleration start dialog
+ *
+ * @author Jukka Kurttila <jukka.kurttila@fudeco.com>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
#include "accelerationstart.h"
#include "ui_accelerationstartdialog.h"
#include <QMessageBox>
+/*
+ * Acceleration start dialog
+ *
+ * @author Jukka Kurttila <jukka.kurttila@fudeco.com>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
#ifndef ACCELERATIONSTART_H
#define ACCELERATIONSTART_H
Accelerometer::Accelerometer()
{
initValues();
+ calibrateDialog = NULL;
}
/**
*/
Accelerometer::~Accelerometer()
{
+ if(calibrateDialog)
+ delete calibrateDialog;
}
/**
calibrateDialog = new CalibrateDialog();
calibrateDialog->show();
calibrateDialog->resetProgressValue();
+ calibrateDialog->setMaxValue( kIterations + 1 );
do {
calibrateDialog->setProgressValue(iteration);
calibrationY = calibrationY/kIterations;
calibrationZ = calibrationZ/kIterations;
- calibrateDialog->hide();
+ calibrateDialog->close();
}
/**
+/*
+ * Acceleration info in real time dialog
+ *
+ * @author Jukka Kurttila <jukka.kurttila@fudeco.com>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
#include "accrealtimedialog.h"
#include "ui_accrealtimedialog.h"
#include <math.h>
updateScreenCounter = 0;
resetAccelerometerMeasurements();
- //Load image
- QPixmap pixMap("back.png",0,Qt::AutoColor);
- ui->pictureLabel->setPixmap(pixMap);
+ resultDialog = NULL;
}
AccRealTimeDialog::~AccRealTimeDialog()
delete accelerometerTimer;
delete calculate;
delete movingAverageZ;
+ if(resultDialog)
+ delete resultDialog;
}
void AccRealTimeDialog::changeEvent(QEvent *e)
y -= accelerometer->getCalibrationY();
z -= accelerometer->getCalibrationZ();
- QString str = QString("acc x: " + QString::number(x) + "\n" +
- "acc y: " + QString::number(y) + "\n" +
- "acc z: " + QString::number(z) + "\n");
+// QString str = QString("acc x: " + QString::number(x) + "\n" +
+// "acc y: " + QString::number(y) + "\n" +
+// "acc z: " + QString::number(z) + "\n");
currentAcceleration = z;//sqrt(x*x + y*y + z*z);
changeInAcceleration = currentAcceleration;
updateScreenCounter++;
//Open result dialog if target speed reached
- if( speed > stopMeasureSpeed )
+ if( (stopMeasureSpeed > 0) && (speed > stopMeasureSpeed) )
{
this->accelerometerTimer->stop();
+ if(!resultDialog)
+ {
+ resultDialog = new ResultDialog(this);
+ }
+ resultDialog->setEnd(stopMeasureSpeed);
+
+ //Put all times from all speeds
+ QMap<int,double> tempMap = calculate->getValuesMap();
+
+ for( int i = 1 ; i <= tempMap.count() ; i++ )
+ {
+ resultDialog->setValue(i*10,tempMap[i*10]);
+ }
+ resultDialog->show();
+ this->hide();
}
}
}
void AccRealTimeDialog::startAccelerationMeasure()
{
+ double temp = stopMeasureSpeed;
+ resetAccelerometerMeasurements();
+ stopMeasureSpeed = temp;
accelerometerTimer->start(40);
}
void AccRealTimeDialog::SetStopMeasureSpeed(double speed)
+/*
+ * Acceleration info in real time dialog
+ *
+ * @author Jukka Kurttila <jukka.kurttila@fudeco.com>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
#ifndef ACCREALTIMEDIALOG_H
#define ACCREALTIMEDIALOG_H
#include <QTimer>
#include "accelerometer.h"
#include "movingaverage.h"
+#include "resultdialog.h"
+
namespace Ui {
class AccRealTimeDialog;
Accelerometer* accelerometer;
Calculate *calculate;
MovingAverage* movingAverageZ;
+ ResultDialog* resultDialog;
int updateScreenCounter;
double accelerationStartThreshold;
* Calculate class to process accelerometer data
*
* @author Kai Rasilainen
+ * @author Jukka Kurttila <jukka.kurttila@fudeco.com>
* @copyright (c) 2010 Speed Freak team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
maxSpeed = value;
}
+QMap<int,double> Calculate::getValuesMap()
+{
+ return valuesMap;
+}
* Calculate class to process accelerometer data
*
* @author Kai Rasilainen
+ * @author Jukka Kurttila <jukka.kurttila@fudeco.com>
* @copyright (c) 2010 Speed Freak team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
void reset();
void calculateParameters(double currentAcceleration, double seconds);
void accelStoppedCheck(double currentAcceleration);
+ QMap<int,double> getValuesMap();
double getAverageSpeed();
void setAverageSpeed(double value);
double currentPower;
double averagePower;
QList<int> speedCheckPoints;
-public:
+
QMap<int,double> valuesMap;
signals:
{
ui->progressBar->reset();
}
+
+void CalibrateDialog::setMaxValue(int max)
+{
+ ui->progressBar->setMaximum( max );
+}
void setProgressValue(int value);
void resetProgressValue();
+ void setMaxValue(int max);
protected:
void changeEvent(QEvent *e);
<x>0</x>
<y>0</y>
<width>800</width>
- <height>480</height>
+ <height>150</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
- <widget class="QLabel" name="label">
- <property name="geometry">
- <rect>
- <x>300</x>
- <y>30</y>
- <width>201</width>
- <height>161</height>
- </rect>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="pixmap">
- <pixmap>line_chart.png</pixmap>
- </property>
- <property name="scaledContents">
- <bool>true</bool>
- </property>
- <property name="alignment">
- <set>Qt::AlignHCenter|Qt::AlignTop</set>
- </property>
- </widget>
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
- <x>60</x>
- <y>220</y>
+ <x>50</x>
+ <y>40</y>
<width>681</width>
<height>71</height>
</rect>