+/*
+ * 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;
<string/>
</property>
<property name="pixmap">
- <pixmap resource="graphics.qrc">:/new/prefix1/Graphics/Speedometer .png</pixmap>
+ <pixmap resource="graphics.qrc">:/new/prefix1/Graphics/Speedometer.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
* 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>
<set>Qt::AlignCenter</set>
</property>
</widget>
- <widget class="QWidget" name="">
+ <widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
</item>
</layout>
</widget>
- <widget class="QWidget" name="">
+ <widget class="QWidget" name="layoutWidget">
<property name="geometry">
<rect>
<x>20</x>
<y>300</y>
<width>751</width>
- <height>41</height>
+ <height>42</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
</property>
</widget>
</item>
- <item row="0" column="1">
+ <item row="0" column="2">
<widget class="QLabel" name="label_16">
<property name="font">
<font>
</property>
</widget>
</item>
- <item row="0" column="2">
+ <item row="0" column="3">
<widget class="QLabel" name="label_15">
<property name="font">
<font>
</property>
</widget>
</item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_18">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Gentleface.com</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QLabel" name="label_19">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Harwen</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QLabel" name="label_20">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>silvestre herrera</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="label_21">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>DevCom</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="label_22">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Icons-Land</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QLabel" name="label_23">
+ <property name="font">
+ <font>
+ <pointsize>10</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Ken Saunders</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</widget>
--- /dev/null
+/*
+ * GPS data
+ *
+ * @author Toni Jussila <toni.jussila@fudeco.com>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
+#include "gpsdata.h"
+
+/**
+ *Default constructor of this class.
+ */
+GPSData::GPSData(Maemo5Location *maemo5location)
+{
+ location = maemo5location;
+
+ connect(location,SIGNAL(agnss()),this,SLOT(agnss()));
+ connect(location,SIGNAL(awcp()),this,SLOT(awcp()));
+ connect(location,SIGNAL(locationUpdated()),this,SLOT(locationUpdated()));
+ connect(location,SIGNAL(gps_connected()),this,SLOT(gpsConnected()));
+ connect(location,SIGNAL(gps_disconnected()),this,SLOT(gpsDisconnected()));
+ connect(location,SIGNAL(gps_error(int)),this,SLOT(gpsError()));
+ connect(location,SIGNAL(gpsd_running()),this,SLOT(gpsdRunning()));
+ connect(location,SIGNAL(gpsd_stopped()),this,SLOT(gpsdStopped()));
+
+ gpsDateTime = new QDateTime();
+ resetAll();
+}
+
+/**
+ *Destructor of this class. Deletes all dynamic objects and sets them to NULL.
+ */
+GPSData::~GPSData()
+{
+ delete location;
+ delete gpsDateTime;
+}
+
+void GPSData::resetAll()
+{
+ satellitesInUse = 0;
+ satellitesInView = 0;
+ signalStrength = 0;
+ latitude = 0;
+ longitude = 0;
+ time = 0;
+ ept = 0;
+ eph = 0;
+ altitude = 0;
+ epv = 0;
+ track = 0;
+ epd = 0;
+ speed = 0;
+ eps = 0;
+ climb = 0;
+ epc = 0;
+ latitudePrevious = 0;
+ longitudePrevious = 0;
+ sLatitudeNow = "";
+ sLongitudeNow = "";
+ sLatitudePrevious = "";
+ sLongitudePrevious = "";
+ routeStartTime = "";
+ routeStopTime = "";
+ recordingStatus = false;
+ roundCounter = 0;
+}
+
+/**
+ *This slot function is called when GPS update location.
+ */
+void GPSData::agnss()
+{
+ //satellitesInUse = location->getSatellitesInUse()); //Returns number of satellites in use.
+ //satellitesInView = location->getSatellitesInView(); //Returns number of satellites in view.
+ //signalStrength = location->getSignalStrength(); //Returns average signal strength of satellites which are in use.
+ //gpsOnline = location->getGpsOnline(); //Returns gsp online
+ //ept = location->getEpt(); //Returns time accuracy in seconds.
+ //eph = location->getEph(); //Returns horizontal position accuracy in cm.
+ //track = location->getTrack(); //Returns direction of motion in degrees(0-359).
+ //epd = location->getEpd(); //Returns track accuracy in degrees.
+ //climb = location->getClimb(); //Returns current rate of climb in m/s.
+ //epc = location->getEpc(); //Returns climb accuracy in m/s.
+ //time = location->getTime(); //Returns timestamp of the update in seconds.
+ //epv = location->getEpv(); //Returns altitude accuracy in meters.
+ //eps = location->getEps(); //Returns speed accuracy in km/h.
+ //distance = location->distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f);
+
+ //If route recording true
+ if ( recordingStatus == true )
+ {
+ latitudePrevious = latitude;
+ longitudePrevious = longitude;
+ latitude = location->getLatitude(); //Returns latitude.
+ longitude = location->getLongitude(); //Returns longitude.
+ altitude = location->getAltitude(); //Returns fix altitude in meters.
+ speed = location->getSpeed(); //Returns current speed in km/h.
+
+ QFile routeTempFile("routetemp.xml");//Temp xml.
+
+ //If first round
+ if (roundCounter == 0)
+ {
+ if (!routeTempFile.open(QIODevice::WriteOnly | QIODevice::Text))
+ return;
+ writeRouteXml(&routeTempFile, 0);
+ routeTempFile.close();
+ roundCounter ++;
+ }
+
+ //Points writing round.
+ else
+ {
+ sLatitudeNow.sprintf("%.4f", latitude); //Latitude now to string
+ sLongitudeNow.sprintf("%.4f", longitude);//Longitude now to string
+ sLatitudePrevious.sprintf("%.4f", latitudePrevious); //Previous latitude to string
+ sLongitudePrevious.sprintf("%.4f", longitudePrevious); //Previous longitude to string
+
+ //If latitude or longitude change
+ if ( sLatitudeNow != sLatitudePrevious || sLongitudeNow != sLongitudePrevious )
+ {
+ if (!routeTempFile.open(QIODevice::Append | QIODevice::Text))
+ return;
+
+ writeRouteXml(&routeTempFile, 0);
+ roundCounter ++;
+ routeTempFile.close();
+ }
+ }
+ }
+}
+
+/**
+ *This slot function is called when gprs update location.
+ */
+void GPSData::awcp()
+{
+
+}
+
+/**
+ *This slot function is called when .
+ */
+void GPSData::locationUpdated()
+{
+
+}
+
+/**
+ *This slot function is called when .
+ */
+void GPSData::gpsConnected()
+{
+
+}
+
+/**
+ *This slot function is called when .
+ */
+void GPSData::gpsDisconnected()
+{
+
+}
+
+/**
+ *This slot function is called when .
+ */
+void GPSData::gpsError()
+{
+
+}
+
+/**
+ *This slot function is called when .
+ */
+void GPSData::gpsdRunning()
+{
+
+}
+
+/**
+ *This slot function is called when .
+ */
+void GPSData::gpsdStopped()
+{
+
+}
+
+/**
+ *This function start route recording.
+ *@param QString time recording start time.
+ */
+void GPSData::startRouteRecording()
+{
+ if (recordingStatus == false)
+ {
+ //Get start time and start recording.
+ gpsDateTime->setTime_t(location->getTime());
+ routeStartTime = gpsDateTime->toString("dd.MM.yyyy hh:mm:ss");
+ recordingStatus = true;
+ roundCounter = 0;
+ }
+}
+
+/**
+ *This function stop route recording.
+ *@param QString time recording stop time.
+ */
+void GPSData::stopRouteRecording()
+{
+ if (recordingStatus == true)
+ {
+ //Get stop time and stop recording.
+ gpsDateTime->setTime_t(location->getTime());
+ routeStopTime = gpsDateTime->toString("dd.MM.yyyy hh:mm:ss");
+ recordingStatus = false;
+
+ //Write final xml.
+ QFile file("route.xml");
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
+ return;
+ writeRouteXml(&file, 1);
+ file.close();
+ roundCounter = 0;
+ }
+}
+
+/**
+ *This function write route to .xml file.
+ */
+void GPSData::writeRouteXml(QIODevice *device, int round)
+{
+ xmlwriter.setDevice(device);
+
+ //Write temp xml (routetemp.xml).
+ if ( round == 0 )
+ {
+ xmlwriter.writeStartElement("Point");
+ xmlwriter.writeAttribute("Latitude", QString::number(latitude));
+ xmlwriter.writeAttribute("Longitude", QString::number(longitude));
+ xmlwriter.writeAttribute("Altitude", QString::number(altitude));
+ xmlwriter.writeAttribute("Speed", QString::number(speed));
+ xmlwriter.writeEndElement();//Point
+ }
+
+ //Write final xml (route.xml).
+ else if ( round == 1 )
+ {
+ xmlwriter.writeStartDocument();
+ xmlwriter.writeStartElement("Route");
+ xmlwriter.writeAttribute("Start-time", routeStartTime);
+ xmlwriter.writeAttribute("Stop-time", routeStopTime);
+ xmlwriter.writeAttribute("Points", QString::number(roundCounter));
+
+ //Open temp xml and read points
+ QFile tempFile("routetemp.xml");
+ if (!tempFile.open(QIODevice::ReadOnly | QIODevice::Text))
+ return;
+ QTextStream readRoute(&tempFile);
+ QTextStream writeRoute(device);
+ writeRoute << readRoute.readLine();
+ tempFile.close();//Close temp xml
+
+ xmlwriter.writeEndElement();//Route
+ xmlwriter.writeEndDocument();
+ }
+}
--- /dev/null
+/*
+ * GPS data
+ *
+ * @author Toni Jussila <toni.jussila@fudeco.com>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
+#ifndef GPSDATA_H
+#define GPSDATA_H
+
+#include <QObject>
+#include <maemo5location.h>
+#include <QFile>
+#include <QTextStream>
+#include <QXmlStreamWriter>
+#include <qdatetime.h>
+
+class GPSData : public QObject
+{
+ Q_OBJECT
+public:
+ GPSData( Maemo5Location *maemo5location );
+ ~GPSData();
+ void startRouteRecording();
+ void stopRouteRecording();
+ int roundCounter; //testing, move private!!!
+
+private:
+ Maemo5Location *location;
+ void resetAll();
+ QXmlStreamWriter xmlwriter;
+ void writeRouteXml(QIODevice *device, int round);
+
+ int satellitesInUse; //Number of satellites in use.
+ int satellitesInView;//Number of satellites in view.
+ int signalStrength; //Average signal strength of satellites which are in use.
+ double latitude; //Latitude.
+ double longitude; //Longitude.
+ double time; //Timestamp of the update in seconds.
+ double ept; //Time accuracy in seconds.
+ double eph; //Horizontal position accuracy in cm.
+ double altitude; //Fix altitude in meters.
+ double epv; //Altitude accuracy in meters.
+ double track; //Direction of motion in degrees(0-359).
+ double epd; //Track accuracy in degrees.
+ double speed; //Current speed in km/h.
+ double eps; //Speed accuracy in km/h.
+ double climb; //Current rate of climb in m/s.
+ double epc; //Climb accuracy in m/s.
+ double latitudePrevious;
+ double longitudePrevious;
+ QString routeStartTime;
+ QString routeStopTime;
+ QString sLatitudeNow;
+ QString sLongitudeNow;
+ QString sLatitudePrevious;
+ QString sLongitudePrevious;
+ QDateTime *gpsDateTime;
+ bool recordingStatus;
+ //int roundCounter;
+
+private slots:
+ void agnss();
+ void awcp();
+ void locationUpdated();
+ void gpsConnected();
+ void gpsDisconnected();
+ void gpsError();
+ void gpsdRunning();
+ void gpsdStopped();
+
+};
+
+#endif // GPSDATA_H
<qresource prefix="/new/prefix1">
<file>Graphics/meter.png</file>
<file>Graphics/route.png</file>
- <file>Graphics/Speedometer .png</file>
+ <file>Graphics/satellite_vista.png</file>
+ <file>Graphics/route_play.png</file>
+ <file>Graphics/route_stop.png</file>
+ <file>Graphics/settings.png</file>
+ <file>Graphics/trophy_gold.png</file>
+ <file>Graphics/applications_internet.png</file>
+ <file>Graphics/Speedometer.png</file>
+ <file>Graphics/Speedometer2.png</file>
+ <file>Graphics/info.png</file>
+ <file>Graphics/speedfreak.png</file>
</qresource>
</RCC>
--- /dev/null
+/*
+ * Maemo5Location
+ *
+ * @author Toni Jussila <toni.jussila@fudeco.com>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
+//#ifdef Q_WS_MAEMO_5
+#include "maemo5locationprivate.h"
+#include "maemo5location.h"
+
+/**
+ *Default constructor of this class.
+ *@param QObject pointer to parent object. By default the value is NULL.
+ */
+Maemo5Location::Maemo5Location(QObject* parent):QObject(parent)
+{
+ ptr = new Maemo5LocationPrivate(this);
+
+ connect(ptr, SIGNAL(agnss()), this, SIGNAL(agnss()));
+ connect(ptr, SIGNAL(awcp()), this, SIGNAL(awcp()));
+ connect(ptr, SIGNAL(locationUpdated()), this, SIGNAL(locationUpdated()));
+ connect(ptr, SIGNAL(gps_connected()), this, SIGNAL(gps_connected()));
+ connect(ptr, SIGNAL(gps_disconnected()), this, SIGNAL(gps_disconnected()));
+ connect(ptr, SIGNAL(gps_error(int)), this, SIGNAL(gps_error(int)));
+ connect(ptr, SIGNAL(gpsd_running()), this, SIGNAL(gpsd_running()));
+ connect(ptr, SIGNAL(gpsd_stopped()), this, SIGNAL(gpsd_stopped()));
+}
+
+/**
+ *Destructor of this class. Should be used to release all allocated resources.
+ */
+Maemo5Location::~Maemo5Location()
+{
+ delete ptr;
+}
+
+/**
+ *Start polling gps.
+ */
+void Maemo5Location::startPollingGPS()
+{
+ ptr->get_agnss();
+}
+
+/**
+ *Stop polling gps.
+ */
+void Maemo5Location::stopPollingGPS()
+{
+ ptr->stop();
+}
+
+/**
+ *Returns number of satellites in use.
+ */
+int Maemo5Location::getSatellitesInUse()
+{
+ return ptr->get_satellites_in_use();
+}
+
+/**
+ *Returns number of satellites in view.
+ */
+int Maemo5Location::getSatellitesInView()
+{
+ return ptr->get_satellites_in_view();
+}
+
+/**
+ *Returns average signal strength of satellites which are in use.
+ */
+int Maemo5Location::getSignalStrength()
+{
+ return ptr->get_signal_strength();
+}
+
+/**
+ *Returns gps online.
+ */
+bool Maemo5Location::getGpsOnline()
+{
+ return ptr->get_gps_online();
+}
+
+/**
+ *Returns latitude.
+ */
+double Maemo5Location::getLatitude()
+{
+ return ptr->get_lat();
+}
+
+/**
+ *Returns longitude.
+ */
+double Maemo5Location::getLongitude()
+{
+ return ptr->get_lon();
+}
+
+/**
+ *Returns timestamp of the update in seconds.
+ */
+double Maemo5Location::getTime()
+{
+ return ptr->get_time();
+}
+
+/**
+ *Returns time accuracy in seconds.
+ */
+double Maemo5Location::getEpt()
+{
+ return ptr->get_ept();
+}
+
+/**
+ *Returns horizontal position accuracy in cm.
+ */
+double Maemo5Location::getEph()
+{
+ return ptr->get_eph();
+}
+
+/**
+ *Returns fix altitude in meters.
+ */
+double Maemo5Location::getAltitude()
+{
+ return ptr->get_altitude();
+}
+
+/**
+ *Returns altitude accuracy in meters.
+ */
+double Maemo5Location::getEpv()
+{
+ return ptr->get_epv();
+}
+
+/**
+ *Returns direction of motion in degrees(0-359).
+ */
+double Maemo5Location::getTrack()
+{
+ return ptr->get_track();
+}
+
+/**
+ *Returns track accuracy in degrees.
+ */
+double Maemo5Location::getEpd()
+{
+ return ptr->get_epd();
+}
+
+/**
+ *Returns current speed in km/h.
+ */
+double Maemo5Location::getSpeed()
+{
+ return ptr->get_speed();
+}
+
+/**
+ *Returns speed accuracy in km/h.
+ */
+double Maemo5Location::getEps()
+{
+ return ptr->get_eps();
+}
+
+/**
+ *Returns current rate of climb in m/s.
+ */
+double Maemo5Location::getClimb()
+{
+ return ptr->get_climb();
+}
+
+/**
+ *Returns climb accuracy in m/s.
+ */
+double Maemo5Location::getEpc()
+{
+ return ptr->get_epc();
+}
+
+/**
+ *Returns distance between two points in kilometers.
+ *@param latitude of first point
+ *@param longitude of first point
+ *@param latitude of second point
+ *@param longitude of second point
+ */
+double Maemo5Location::distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f)
+{
+ return ptr->distance_between_two_points(latitude_s, longitude_s, latitude_f, longitude_f);
+}
--- /dev/null
+/*
+ * Maemo5Location
+ *
+ * @author Toni Jussila <toni.jussila@fudeco.com>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
+#ifndef MAEMO5LOCATION_H
+#define MAEMO5LOCATION_H
+
+#include <QObject>
+
+class Maemo5LocationPrivate;
+
+class Maemo5Location : public QObject
+{
+ Q_OBJECT
+public:
+ Maemo5Location(QObject* parent = 0);
+ ~Maemo5Location();
+
+ void startPollingGPS();
+ void stopPollingGPS();
+ int getSatellitesInUse();
+ int getSatellitesInView();
+ int getSignalStrength();
+ bool getGpsOnline();
+ double getLatitude();
+ double getLongitude();
+ double getTime();
+ double getEpt();
+ double getEph();
+ double getAltitude();
+ double getEpv();
+ double getTrack();
+ double getEpd();
+ double getSpeed();
+ double getEps();
+ double getClimb();
+ double getEpc();
+ double distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f);
+
+signals:
+ void awcp();
+ void agnss();
+ void locationUpdated();
+ void gps_connected();
+ void gps_disconnected();
+ void gps_error(int);
+ void gpsd_running();
+ void gpsd_stopped();
+
+private:
+ Maemo5LocationPrivate* ptr;
+};
+
+#endif // MAEMO5LOCATION_H
--- /dev/null
+/*
+ * Maemo5LocationPrivate
+ *
+ * @author Toni Jussila <toni.jussila@fudeco.com>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
+#include "maemo5locationprivate.h"
+
+/**
+ *Default constructor of this class.
+ *@param Maemo5Location pointer to public interface.
+ */
+Maemo5LocationPrivate::Maemo5LocationPrivate(Maemo5Location* location):QObject(location)
+{
+ //Initialize variables
+ gps_online = false;
+ usegps = -1;
+ resetAll();
+ //Get gps control object
+ control = location_gpsd_control_get_default();
+ //create gps device
+ device = (LocationGPSDevice*) g_object_new(LOCATION_TYPE_GPS_DEVICE, NULL);
+
+ g_signal_connect(device, "changed", G_CALLBACK(gps_data_changed), this);
+ g_signal_connect(device, "connected", G_CALLBACK(gps_connected_func), this);
+ g_signal_connect(device, "disconnected", G_CALLBACK(gps_disconnected_func), this);
+
+ g_signal_connect(control, "error-verbose", G_CALLBACK(gps_error_func), this);
+ g_signal_connect(control, "gpsd_running", G_CALLBACK(gpsd_running_func), this);
+ g_signal_connect(control, "gpsd_stopped", G_CALLBACK(gpsd_running_func), this);
+
+}
+/**
+ *Destructor of this class. Should be used to release all allocated resources.
+ */
+Maemo5LocationPrivate::~Maemo5LocationPrivate()
+{
+ delete device;
+ delete control;
+}
+
+/**
+ *This function is used to start to poll with gprs
+ */
+void Maemo5LocationPrivate::get_acwp()
+{
+ g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_ACWP, NULL);
+ usegps = 0;
+ restart();
+}
+
+/**
+ *This function starts to poll via gps interface
+ */
+void Maemo5LocationPrivate::get_agnss()
+{
+ g_object_set(G_OBJECT(control), "preferred-method", LOCATION_METHOD_AGNSS, NULL);
+ usegps = 1;
+ restart();
+}
+
+/**
+ *Stop polling gps
+ */
+void Maemo5LocationPrivate::stop()
+{
+ location_gpsd_control_stop(control);
+}
+
+/**
+ *Stop and restart polling
+ */
+void Maemo5LocationPrivate::restart()
+{
+ location_gpsd_control_stop(control);
+ location_gpsd_control_start(control);
+}
+
+/**
+ *This function is called when device managed to connect to the lcoation server.
+ *Function emits gps_connected signal.
+ *@param Pointer to LocationGPSDevice class
+ *@param Pointer to Maemo5LocationPrivate class
+ */
+void gps_connected_func(LocationGPSDevice *device, Maemo5LocationPrivate *gps)
+{
+ emit gps->gps_connected();
+}
+
+/**
+ *This function is called when device is disconnected from the location server.
+ *Function emits gps_disconnected signal.
+ *Also this function resets all arguments of Maemo5LcoationPrivate class.
+ *@param Pointer to LocationGPSDevice class
+ *@param Pointer to Maemo5LocationPrivate class
+ */
+void gps_disconnected_func(LocationGPSDevice *device, Maemo5LocationPrivate *gps)
+{
+ gps->resetAll();
+ emit gps->gps_disconnected();
+}
+
+/**
+ *This function is called after the location_gpsd_control_stop has been called.
+ *@param Pointer to LocationGPSDControl class
+ *@param Pointer to Maemo5LocationPrivate class
+ */
+void gpsd_stopped_func(LocationGPSDControl *control, Maemo5LocationPrivate *gps)
+{
+ emit gps->gpsd_stopped();
+}
+
+/**
+ *This function is called when an error has occurred.
+ *@param Pointer to LocationGPSDControl class
+ *@param error code
+ *@param Pointer to Maemo5LocationPrivate class
+ */
+void gps_error_func(LocationGPSDControl *control, gint error, Maemo5LocationPrivate *gps)
+{
+
+ switch (error) {
+ case LOCATION_ERROR_USER_REJECTED_DIALOG:
+ emit gps->gps_error(0);
+ g_debug("User didn't enable requested methods");
+ break;
+ case LOCATION_ERROR_USER_REJECTED_SETTINGS:
+ emit gps->gps_error(1);
+ g_debug("User changed settings, which disabled location");
+ break;
+ case LOCATION_ERROR_BT_GPS_NOT_AVAILABLE:
+ emit gps->gps_error(2);
+ g_debug("Problems with BT GPS");
+ break;
+ case LOCATION_ERROR_METHOD_NOT_ALLOWED_IN_OFFLINE_MODE:
+ emit gps->gps_error(3);
+ g_debug("Requested method is not allowed in offline mode");
+ break;
+ case LOCATION_ERROR_SYSTEM:
+ emit gps->gps_error(4);
+ g_debug("System error");
+ break;
+ }
+}
+
+/**
+ *This function is called after the location_gpsd_control_start has been called.
+ *@param Pointer to LocationGPSDControl class
+ *@param Pointer to Maemo5LocationPrivate class
+ */
+void gpsd_running_func(LocationGPSDControl *control, Maemo5LocationPrivate *gps)
+{
+ emit gps->gpsd_running();
+}
+
+/**
+ *Callback function to catch gps signals.
+ *@param Pointer to LocationGPSDControl class
+ *@param Pointer to Maemo5LocationPrivate class
+ */
+void gps_data_changed(LocationGPSDevice *device, Maemo5LocationPrivate *gps)
+{
+ //First check that LocationGpsDeviceFix can be found...this data structure contains the location info.
+ if(gps->device->fix)
+ {
+ //Check that there are fields
+ if(gps->device->fix->fields)
+ {
+ //Store values and emit signal
+ if(gps->device->fix->fields & LOCATION_GPS_DEVICE_LATLONG_SET)
+ {
+ gps->latitude = gps->device->fix->latitude;
+ gps->longitude = gps->device->fix->longitude;
+ gps->eph = gps->device->fix->eph;
+ }
+
+
+ gps->satellites_in_use = gps->device->satellites_in_use;
+ gps->satellites_in_view = gps->device->satellites_in_view;
+
+ if(gps->device->fix->fields & LOCATION_GPS_DEVICE_TIME_SET)
+ {
+ gps->time = gps->device->fix->time;
+ gps->ept = gps->device->fix->ept;
+ }
+
+ if(gps->device->fix->fields & LOCATION_GPS_DEVICE_ALTITUDE_SET)
+ {
+ gps->altitude = gps->device->fix->altitude;
+ gps->epv = gps->device->fix->epv;
+ }
+
+ if(gps->device->fix->fields & LOCATION_GPS_DEVICE_TRACK_SET)
+ {
+ gps->track = gps->device->fix->track;
+ gps->epd = gps->device->fix->epd;
+ }
+
+ if(gps->device->fix->fields & LOCATION_GPS_DEVICE_SPEED_SET)
+ {
+ gps->speed = gps->device->fix->speed;
+ gps->eps = gps->device->fix->eps;
+ }
+
+ if(gps->device->fix->fields & LOCATION_GPS_DEVICE_CLIMB_SET)
+ {
+ gps->climb = gps->device->fix->climb;
+ gps->epc = gps->device->fix->epc;
+ }
+
+
+ // Calculate average signal strength of satellites in use
+ int temp = 0;
+ if(gps->satellites_in_use != 0)
+ {
+ for(int i=0 ; i < gps->satellites_in_use ; i++)
+ {
+ LocationGPSDeviceSatellite *view = (LocationGPSDeviceSatellite*) g_ptr_array_index (gps->device->satellites, i);
+ temp = temp + view->signal_strength;
+ }
+ gps->signal_strength = (temp / gps->satellites_in_use);
+ }
+
+
+ if(gps->usegps == 0)
+ {
+ emit gps->awcp();
+ }
+ else if(gps->usegps == 1)
+ {
+ emit gps->agnss();
+ }
+ else
+ {
+ emit gps->locationUpdated();
+ }
+ }
+ }
+
+}
+
+/**
+ *Resets all arguments of Maemo5LocationPrivate class.
+ */
+void Maemo5LocationPrivate::resetAll()
+{
+ time = 0;
+ latitude = 0;
+ longitude = 0;
+ satellites_in_view = 0;
+ satellites_in_use = 0;
+ ept = 0;
+ eph = 0;
+ altitude = 0;
+ epv = 0;
+ track = 0;
+ epd = 0;
+ speed = 0;
+ eps = 0;
+ climb = 0;
+ epc = 0;
+}
+
+/**
+ *Returns distance between two points in kilometers.
+ *@param latitude of first point
+ *@param longitude of first point
+ *@param latitude of second point
+ *@param longitude of second point
+ */
+double Maemo5LocationPrivate::distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f)
+{
+ double distance = 0;
+ return distance = location_distance_between(latitude_s, longitude_s, latitude_f, longitude_f);
+}
--- /dev/null
+/*
+ * Maemo5LocationPrivate
+ *
+ * @author Toni Jussila <toni.jussila@fudeco.com>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
+#ifndef MAEMO5LOCATIONPRIVATE_H
+#define MAEMO5LOCATIONPRIVATE_H
+
+//We have to declare these header file inside extern, since these modules are actually c modules not c++
+extern "C"
+{
+#include <location/location-gps-device.h>
+#include <location/location-gpsd-control.h>
+#include <location/location-distance-utils.h>
+}
+
+#include <QObject>
+#include "maemo5location.h"
+
+class Maemo5LocationPrivate : public QObject
+{
+ Q_OBJECT
+
+public:
+ Maemo5LocationPrivate(Maemo5Location* location);
+ ~Maemo5LocationPrivate();
+
+ void get_acwp();
+ void get_agnss();
+
+ friend void gps_data_changed(LocationGPSDevice *device, Maemo5LocationPrivate *gps);
+ friend void gps_connected_func(LocationGPSDevice *device, Maemo5LocationPrivate *gps);
+ friend void gps_disconnected_func(LocationGPSDevice *device, Maemo5LocationPrivate *gps);
+ friend void gps_error_func(LocationGPSDControl *control, gint error, Maemo5LocationPrivate *gps);
+ friend void gpsd_running_func(LocationGPSDControl *control, Maemo5LocationPrivate *gps);
+ friend void gpsd_stopped_func(LocationGPSDControl *control, Maemo5LocationPrivate *gps);
+
+ static void handleStatus( LocationGPSDeviceStatus status );
+
+ int get_satellites_in_view() { return satellites_in_view; }
+ int get_satellites_in_use() { return satellites_in_use; }
+ int get_signal_strength() { return signal_strength; }
+ gboolean get_gps_online() { return gps_online; }
+ double get_lat() { return latitude; }
+ double get_lon() { return longitude; }
+ double get_time() { return time; }
+ double get_ept() { return ept; }
+ double get_eph() { return eph; }
+ double get_altitude() { return altitude; }
+ double get_epv() { return epv; }
+ double get_track() { return track; }
+ double get_epd() { return epd; }
+ double get_speed() { return speed; }
+ double get_eps() { return eps; }
+ double get_climb() { return climb; }
+ double get_epc() { return epc; }
+ double distance_between_two_points(double latitude_s, double longitude_s, double latitude_f, double longitude_f);
+ void stop();
+
+signals:
+ void awcp();
+ void agnss();
+ void locationUpdated();
+ void gps_connected();
+ void gps_disconnected();
+ void gps_error(int);
+ void gpsd_running();
+ void gpsd_stopped();
+
+private:
+ void resetAll();
+ //void stop();
+ void restart();
+
+ int satellites_in_view;
+ int satellites_in_use;
+ int signal_strength;
+ gboolean gps_online;
+ double latitude;
+ double longitude;
+ double time;
+ double ept;
+ double eph;
+ double altitude;
+ double epv;
+ double track;
+ double epd;
+ double speed;
+ double eps;
+ double climb;
+ double epc;
+
+ Maemo5Location* d_ptr;
+ int usegps;
+ LocationGPSDControl *control;
+ LocationGPSDevice *device;
+};
+
+void gps_data_changed(LocationGPSDevice *device, Maemo5LocationPrivate *gps);
+void gps_connected_func(LocationGPSDevice *device, Maemo5LocationPrivate *gps);
+void gps_disconnected_func(LocationGPSDevice *device, Maemo5LocationPrivate *gps);
+void gps_error_func(LocationGPSDControl *control, gint error, Maemo5LocationPrivate *gps);
+void gpsd_running_func(LocationGPSDControl *control, Maemo5LocationPrivate *gps);
+void gpsd_stopped_func(LocationGPSDControl *control, Maemo5LocationPrivate *gps);
+
+#endif // MAEMO5LOCATIONPRIVATE_H
/*
* Mainwindow for speedFreak project
*
- * @author Rikhard Kuutti <rikhard.kuutti@fudeco.com>
+ * @author Rikhard Kuutti <rikhard.kuutti@fudeco.com>
+ * @author Toni Jussila <toni.jussila@fudeco.com>
* @copyright (c) 2010 Speed Freak team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/
QCoreApplication::setOrganizationDomain("fudeco.com");
QCoreApplication::setApplicationName("Speed Freak");
+ routeDialog = new RouteDialog;
accstart = NULL;
creditsDialog = new CreditsDialog;
welcomeDialog = new WelcomeDialog;
welcomeDialog->show();
+
+ //Button settings
+ ui->pushButtonAccelerate->setAutoFillBackground(true);
+ ui->pushButtonAccelerate->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+ ui->pushButtonRoute->setAutoFillBackground(true);
+ ui->pushButtonRoute->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+ ui->pushButtonResults->setAutoFillBackground(true);
+ ui->pushButtonResults->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+ ui->pushButtonSettings->setAutoFillBackground(true);
+ ui->pushButtonSettings->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+ ui->pushButtonWWW->setAutoFillBackground(true);
+ ui->pushButtonWWW->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+ ui->pushButtonCredits->setAutoFillBackground(true);
+ ui->pushButtonCredits->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
}
MainWindow::~MainWindow()
{
delete ui;
-
delete routeSaveDialog;
+ delete routeDialog;
- if(!accstart)
+ if(accstart)
delete accstart;
}
}
}
+/**
+ * This slot function opens browser to project www page.
+ */
void MainWindow::on_pushButtonWWW_clicked()
{
QDesktopServices::openUrl(QUrl("http://garage.maemo.org/projects/speedfreak/"));
}
+/**
+ * This slot function opens the credits dialog
+ */
void MainWindow::on_pushButtonCredits_clicked()
{
creditsDialog->show();
}
+/**
+ * This slot function opens the route save dialog
+ */
void MainWindow::on_pushButtonRoute_clicked()
{
routeSaveDialog->show();
}
+/**
+ * This slot function opens the settings dialog
+ */
void MainWindow::on_pushButtonSettings_clicked()
{
settingsDialog->show();
}
+/**
+ * This slot function opens the acceleration dialog
+ */
void MainWindow::on_pushButtonAccelerate_clicked()
{
if(!accstart)
accstart->show();
}
+/**
+ * This slot function opens the top results dialog
+ */
void MainWindow::on_pushButtonResults_clicked()
{
topResultDialog->show();
httpClient->requestRegistration();
}
+/**
+ * This function performs login to server
+ */
void MainWindow::clientUserLogin()
{
httpClient->checkLogin();
#include "accelerationstart.h"
#include "topresultdialog.h"
#include "httpclient.h"
+#include "routedialog.h"
#include "resultdialog.h"
+
namespace Ui {
class MainWindow;
}
accelerationstart* accstart;
TopResultDialog *topResultDialog;
HttpClient *httpClient;
+ RouteDialog *routeDialog;
ResultDialog *resultDialog;
protected:
</property>
<property name="icon">
<iconset resource="graphics.qrc">
- <normaloff>:/new/prefix1/Graphics/Speedometer .png</normaloff>:/new/prefix1/Graphics/Speedometer .png</iconset>
+ <normaloff>:/new/prefix1/Graphics/Speedometer.png</normaloff>
+ <normalon>:/new/prefix1/Graphics/Speedometer2.png</normalon>
+ <disabledon>:/new/prefix1/Graphics/Speedometer2.png</disabledon>
+ <activeon>:/new/prefix1/Graphics/Speedometer2.png</activeon>
+ <selectedon>:/new/prefix1/Graphics/Speedometer2.png</selectedon>:/new/prefix1/Graphics/Speedometer.png</iconset>
</property>
<property name="iconSize">
<size>
</rect>
</property>
<property name="text">
- <string>Results</string>
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="graphics.qrc">
+ <normaloff>:/new/prefix1/Graphics/trophy_gold.png</normaloff>:/new/prefix1/Graphics/trophy_gold.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>125</width>
+ <height>125</height>
+ </size>
</property>
</widget>
<widget class="QPushButton" name="pushButtonSettings">
</rect>
</property>
<property name="text">
- <string>Settings</string>
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="graphics.qrc">
+ <normaloff>:/new/prefix1/Graphics/settings.png</normaloff>:/new/prefix1/Graphics/settings.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>125</width>
+ <height>125</height>
+ </size>
</property>
</widget>
<widget class="QPushButton" name="pushButtonWWW">
<height>130</height>
</rect>
</property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
<property name="text">
- <string>WWW</string>
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="graphics.qrc">
+ <normaloff>:/new/prefix1/Graphics/applications_internet.png</normaloff>:/new/prefix1/Graphics/applications_internet.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>125</width>
+ <height>125</height>
+ </size>
</property>
</widget>
<widget class="QPushButton" name="pushButtonCredits">
<property name="geometry">
<rect>
- <x>640</x>
+ <x>670</x>
<y>10</y>
- <width>151</width>
- <height>41</height>
+ <width>105</width>
+ <height>105</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="graphics.qrc">
+ <normaloff>:/new/prefix1/Graphics/info.png</normaloff>:/new/prefix1/Graphics/info.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>100</width>
+ <height>100</height>
+ </size>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label">
+ <property name="geometry">
+ <rect>
+ <x>270</x>
+ <y>280</y>
+ <width>461</width>
+ <height>121</height>
</rect>
</property>
<property name="text">
- <string>Credits</string>
+ <string/>
+ </property>
+ <property name="pixmap">
+ <pixmap resource="graphics.qrc">:/new/prefix1/Graphics/speedfreak.png</pixmap>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
</property>
</widget>
</widget>
painter.setPen(QPen((Qt::darkCyan),2));
painter.drawLine(diagramStemStart, diagramStemEnd);
painter.drawLine(diagramHorizontalStart, diagramHorizontalEnd);
+ painter.drawText(diagramStemStart.x() - 50, diagramStemEnd.y() + 100, "S");
+ painter.drawText(diagramStemStart.x() - 50, diagramStemEnd.y() + 115, "P");
+ painter.drawText(diagramStemStart.x() - 50, diagramStemEnd.y() + 130, "E");
+ painter.drawText(diagramStemStart.x() - 50, diagramStemEnd.y() + 145, "E");
+ painter.drawText(diagramStemStart.x() - 50, diagramStemEnd.y() + 160, "D");
+ painter.drawText(diagramStemStart.x() - 65, diagramStemEnd.y() + 180, "(km/h)");
+
+ painter.drawText(diagramStemStart.x() + 140, diagramStemStart.y() + 40, "T");
+ painter.drawText(diagramStemStart.x() + 150, diagramStemStart.y() + 40, "I");
+ painter.drawText(diagramStemStart.x() + 155, diagramStemStart.y() + 40, "M");
+ painter.drawText(diagramStemStart.x() + 165, diagramStemStart.y() + 40, "E");
+ painter.drawText(diagramStemStart.x() + 180, diagramStemStart.y() + 40, "(s)");
int currentX = 0;
int currentY = diagramStemStart.y();
*/
void ResultDialog::setEnd(int pValue)
{
+ for (int i = 0; i < 11; i++)
+ {
+ timeArray[i] = 0;
+ }
+ resultString = "";
+
switch (pValue)
{
case 10:
//QString resultString;
resultString.append("Time was ");
+ QString time;
+
if (this->diagramGapStem == DIAGRAMGAP100KMH)
{
- resultString.append(QString::number(timeArray[10]));
+ time.sprintf("%.2f", timeArray[10]);
+ resultString.append(time);
this->setWindowTitle("Result for accelerating 100 km/h");
}
else if (this->diagramGapStem == DIAGRAMGAP90KMH)
{
- resultString.append(QString::number(timeArray[9]));
+ time.sprintf("%.2f", timeArray[9]);
+ resultString.append(time);
this->setWindowTitle("Result for accelerating 90 km/h");
}
else if (this->diagramGapStem == DIAGRAMGAP80KMH)
{
- resultString.append(QString::number(timeArray[8]));
+ time.sprintf("%.2f", timeArray[8]);
+ resultString.append(time);
this->setWindowTitle("Result for accelerating 80 km/h");
}
else if (this->diagramGapStem == DIAGRAMGAP70KMH)
{
- resultString.append(QString::number(timeArray[7]));
+ time.sprintf("%.2f", timeArray[7]);
+ resultString.append(time);
this->setWindowTitle("Result for accelerating 70 km/h");
}
else if (this->diagramGapStem == DIAGRAMGAP60KMH)
{
- resultString.append(QString::number(timeArray[6]));
+ time.sprintf("%.2f", timeArray[6]);
+ resultString.append(time);
this->setWindowTitle("Result for accelerating 60 km/h");
}
else if (this->diagramGapStem == DIAGRAMGAP50KMH)
{
- resultString.append(QString::number(timeArray[5]));
+ time.sprintf("%.2f", timeArray[5]);
+ resultString.append(time);
this->setWindowTitle("Result for accelerating 50 km/h");
}
else if (this->diagramGapStem == DIAGRAMGAP40KMH)
{
- resultString.append(QString::number(timeArray[4]));
+ time.sprintf("%.2f", timeArray[4]);
+ resultString.append(time);
this->setWindowTitle("Result for accelerating 40 km/h");
}
else if (this->diagramGapStem == DIAGRAMGAP30KMH)
{
- resultString.append(QString::number(timeArray[3]));
+ time.sprintf("%.2f", timeArray[3]);
+ resultString.append(time);
this->setWindowTitle("Result for accelerating 30 km/h");
}
else if (this->diagramGapStem == DIAGRAMGAP20KMH)
{
- resultString.append(QString::number(timeArray[2]));
+ time.sprintf("%.2f", timeArray[2]);
+ resultString.append(time);
this->setWindowTitle("Result for accelerating 20 km/h");
}
else
{
- resultString.append(QString::number(timeArray[1]));
+ time.sprintf("%.2f", timeArray[1]);
+ resultString.append(time);
this->setWindowTitle("Result for accelerating 10 km/h");
}
}
QString rivi;
QFile file;
- QString fileName = QFileDialog::getOpenFileName(this,
- tr("Read Route"), "./", tr("Route Files (*.txt)"));
+ //QString fileName = QFileDialog::getOpenFileName(this,
+ // tr("Read Route"), "./", tr("Route Files (*.txt)"));
- file.setFileName( fileName);
+ //file.setFileName( fileName);
+ file.setFileName( "routetemp.xml");
if (!file.open(QIODevice::ReadOnly))
{
QMessageBox::about(0, "Error", "File not found");
}
vertexList.clear();
+
while(!file.atEnd())
{
+ int count;
+ bool allRead;
+ QString astr1, astr2, astr3, astr4;
QString str1, str2, str3, str4;
rivi = file.readLine();
+ allRead = false;
+ count = 0;
+ while( !allRead)
+ {
+ astr1 = rivi.section(" ", count*4+1, count*4+1); // latitude=""
+ astr2 = rivi.section(" ", count*4+2, count*4+2); // longitude=""
+ astr3 = rivi.section(" ", count*4+3, count*4+3); // altitude=""
+ astr4 = rivi.section(" ", count*4+4, count*4+4); // speed=""
+
+ {
+ double x, y, z, v;
+ str1 = astr1.section('"',1,1);
+ str2 = astr2.section('"',1,1);
+ str3 = astr3.section('"',1,1);
+ str4 = astr4.section('"',1,1);
+ //QString str = QString("%1 %2 %3 %4").arg(str1).arg(str2).arg(str3).arg(str4);
+ //QMessageBox::about(0, "LUKEE", str);
+ /* */
+
+ if (str1.length() > 0)
+ {
+ x = str2.toDouble();// latitude y-value
+ y = str1.toDouble();// longitude x-value
+ z = str3.toDouble();// altitude z-value
+ v = str4.toDouble();// speed m/s
+ // QString str = QString("%1 %2 %3 %4").arg(x).arg(y).arg(z).arg(v);
+ // QMessageBox::about(0, "LUKEE", str);
+ temp.setX( x); // Longitude
+ temp.setY( y); // Latitude
+ temp.setZ( z); // altitude
+ temp.setV( v);
+
+ vertexList.append(temp);
+ count++;
+ }
+ else
+ {
+ allRead = true;
+ }
+ }
+ }
+ // Older version
+ /*
str1 = rivi.section(" ", 0, 0);
if (str1.compare("Start:") != 0 && str1.compare("Stop:") != 0)
{
vertexList.append(temp);
}
}
+ */
}
file.close();
ui->setupUi(this);
this->setWindowTitle("Tracking");
+ routeDialog = new RouteDialog;
+
+ //Button settings
+ buttonStatus = true;
+ pixmapRouteStop = new QPixmap("Graphics/route_stop.png");
+ pixmapRoutePlay = new QPixmap("Graphics/route_play.png");
+ iconRouteStop = new QIcon(*pixmapRouteStop);
+ iconRoutePlay = new QIcon(*pixmapRoutePlay);
+ QSize iconSize(125, 125);
+ ui->buttonRouteStartStop->setIconSize(iconSize);
+ ui->buttonRouteStartStop->setIcon(*iconRoutePlay);
+ ui->buttonRouteStartStop->setAutoFillBackground(true);
+ ui->buttonRouteStartStop->setStyleSheet("background-color: rgb(0, 0, 0); color: rgb(255, 255, 255)");
+
+ //Satellite picture and label
ui->labelRouteSatelliteStatus->setVisible(0);
ui->labelRouteSatellitePicture->setVisible(0);
- ui->labelRouteSatellitePicture->setPixmap(QPixmap("satellite_vista.png"));
+ //ui->labelRouteSatellitePicture->setPixmap(QPixmap("Graphics/satellite_vista.png"));
timerSatellitePicture = new QTimer();
timerSatellitePicture->setInterval(400);
connect(timerSatellitePicture, SIGNAL(timeout()),this, SLOT(timerSatellitePictureTimeout()));
+
+ //Route picture and label
+ ui->labelRouteStatus->setVisible(0);
+ ui->labelRoutePicture->setVisible(0);
+ timerRoutePicture = new QTimer();
+ timerRoutePicture->setInterval(400);
+ connect(timerRoutePicture, SIGNAL(timeout()),this, SLOT(timerRoutePictureTimeout()));
+
+ //GPS speed label
+ ui->labelGpsSpeed->setVisible(0);
+
+ //GPS
+ location = new Maemo5Location(this);
+ gpsData = new GPSData(location);
+ connect(location,SIGNAL(agnss()),this,SLOT(gpsStatus()));
}
/**
RouteSaveDialog::~RouteSaveDialog()
{
delete ui;
+ delete timerSatellitePicture;
+ delete timerRoutePicture;
+ delete location;
+ delete gpsData;
+ delete routeDialog;
+ delete pixmapRouteStop;
+ delete pixmapRoutePlay;
+ delete iconRouteStop;
+ delete iconRoutePlay;
}
void RouteSaveDialog::changeEvent(QEvent *e)
*/
void RouteSaveDialog::on_buttonRouteStartStop_clicked()
{
- if ( ui->buttonRouteStartStop->text() == "Start" )
+ //If start button clicked
+ if ( buttonStatus == true )
{
- ui->buttonRouteStartStop->setText("Stop");
- ui->labelRouteSatelliteStatus->setText("Searching satellite");
- ui->labelRouteSatelliteStatus->setVisible(1);
- ui->labelRouteSatellitePicture->setVisible(1);
- timerSatellitePicture->start();
+ buttonStatus = false;
+ ui->buttonRouteStartStop->setIcon(*iconRouteStop);
+ location->startPollingGPS();
+ gpsStatus();
}
else
{
- ui->buttonRouteStartStop->setText("Start");
+ buttonStatus = true;
+ ui->buttonRouteStartStop->setIcon(*iconRoutePlay);
+
+ //Satellite picture and label
+ ui->labelRouteSatelliteStatus->setText("Searching satellite");
ui->labelRouteSatelliteStatus->setVisible(0);
ui->labelRouteSatellitePicture->setVisible(0);
timerSatellitePicture->stop();
+
+ //Route picture and label
+ ui->labelRouteStatus->setVisible(0);
+ ui->labelRoutePicture->setVisible(0);
+ timerRoutePicture->stop();
+ location->stopPollingGPS();
+ routeDialog->show();
+
+ //GPS speed label
+ ui->labelGpsSpeed->setVisible(0);
+
+ //Stop route recording
+ gpsData->stopRouteRecording();
}
}
}
timerSatellitePicture->start();
}
+
+/**
+ *This slot function is called when route picture timer timeout(400ms).
+ */
+void RouteSaveDialog::timerRoutePictureTimeout()
+{
+ //If route picture visible.
+ if (ui->labelRoutePicture->isVisible() == 1)
+ {
+ ui->labelRouteStatus->setVisible(0);
+ ui->labelRoutePicture->setVisible(0);
+ }
+ else
+ {
+ ui->labelRouteStatus->setVisible(1);
+ ui->labelRoutePicture->setVisible(1);
+ }
+ timerRoutePicture->start();
+}
+
+void RouteSaveDialog::gpsStatus()
+{
+ //IF GPS start button clicked
+ if (buttonStatus == false)
+ {
+ //If GPS find 4 satellite.
+ if (location->getSatellitesInUse() >= 4)
+ {
+ //Satellite picture and label
+ ui->labelRouteSatelliteStatus->setText("GPS Ready");
+ ui->labelRouteSatelliteStatus->setVisible(1);
+ ui->labelRouteSatellitePicture->setVisible(1);
+ timerSatellitePicture->stop();
+
+ //Route picture and label
+ ui->labelRouteStatus->setText("Recorded " + QString::number(gpsData->roundCounter) + " route point");
+ ui->labelRouteStatus->setVisible(1);
+ ui->labelRoutePicture->setVisible(1);
+ timerRoutePicture->start();
+
+ //Set GPS speed.
+ gpsSpeed.sprintf("%.0f",location->getSpeed());
+ ui->labelGpsSpeed->setText(gpsSpeed + " km/h");
+ ui->labelGpsSpeed->setVisible(1);
+
+ //Start route recording
+ gpsData->startRouteRecording();
+ }
+
+ //If GPS find less than 4 satellite.
+ else
+ {
+ //Satellite picture and label
+ ui->labelRouteSatelliteStatus->setText("Searching satellite");
+ ui->labelRouteSatelliteStatus->setVisible(1);
+ ui->labelRouteSatellitePicture->setVisible(1);
+ timerSatellitePicture->start();
+
+ //Route picture and label
+ ui->labelRouteStatus->setVisible(0);
+ ui->labelRoutePicture->setVisible(0);
+ timerRoutePicture->stop();
+
+ //GPS speed label
+ ui->labelGpsSpeed->setVisible(0);
+ }
+ }
+ else
+ {
+ //Satellite picture and label
+ ui->labelRouteSatelliteStatus->setText("Searching satellite");
+ ui->labelRouteSatelliteStatus->setVisible(0);
+ ui->labelRouteSatellitePicture->setVisible(0);
+ timerSatellitePicture->stop();
+
+ //Route picture and label
+ ui->labelRouteStatus->setVisible(0);
+ ui->labelRoutePicture->setVisible(0);
+ timerRoutePicture->stop();
+
+ //GPS speed label
+ ui->labelGpsSpeed->setVisible(0);
+ }
+}
#include <QDialog>
#include <QPixmap>
+#include <QIcon>
+#include <QSize>
#include <QTimer>
+#include <maemo5location.h>
+#include "gpsdata.h"
+#include "routedialog.h"
namespace Ui {
class RouteSaveDialog;
private:
Ui::RouteSaveDialog *ui;
QTimer *timerSatellitePicture;
+ QTimer *timerRoutePicture;
+ GPSData *gpsData;
+ Maemo5Location *location;
+ RouteDialog *routeDialog;
+ QString gpsSpeed;
+ QPixmap *pixmapRouteStop;
+ QPixmap *pixmapRoutePlay;
+ QIcon *iconRouteStop;
+ QIcon *iconRoutePlay;
+ bool buttonStatus;
private slots:
void on_buttonRouteStartStop_clicked();
void timerSatellitePictureTimeout();
+ void timerRoutePictureTimeout();
+ void gpsStatus();
};
#endif // ROUTESAVEDIALOG_H
<x>0</x>
<y>0</y>
<width>800</width>
- <height>480</height>
+ <height>360</height>
</rect>
</property>
+ <property name="font">
+ <font>
+ <family>Bitstream Charter</family>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
<property name="windowTitle">
- <string>Dialog</string>
+ <string>Route</string>
+ </property>
+ <property name="windowIcon">
+ <iconset resource="graphics.qrc">
+ <normaloff>:/new/prefix1/Graphics/route.png</normaloff>:/new/prefix1/Graphics/route.png</iconset>
</property>
<widget class="QPushButton" name="buttonRouteStartStop">
<property name="geometry">
</rect>
</property>
<property name="text">
- <string>Start</string>
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="graphics.qrc">
+ <normaloff>:/new/prefix1/Graphics/route_play.png</normaloff>:/new/prefix1/Graphics/route_play.png</iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>125</width>
+ <height>125</height>
+ </size>
+ </property>
+ <property name="autoRepeat">
+ <bool>false</bool>
</property>
</widget>
<widget class="QLabel" name="labelRouteSatellitePicture">
<property name="geometry">
<rect>
- <x>190</x>
- <y>150</y>
- <width>100</width>
- <height>100</height>
+ <x>200</x>
+ <y>60</y>
+ <width>80</width>
+ <height>80</height>
</rect>
</property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
<property name="text">
- <string>Satellite</string>
+ <string/>
+ </property>
+ <property name="pixmap">
+ <pixmap resource="graphics.qrc">:/new/prefix1/Graphics/satellite_vista.png</pixmap>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
<widget class="QLabel" name="labelRouteSatelliteStatus">
<property name="geometry">
<rect>
- <x>110</x>
- <y>280</y>
- <width>251</width>
+ <x>90</x>
+ <y>80</y>
+ <width>301</width>
<height>51</height>
</rect>
</property>
+ <property name="font">
+ <font>
+ <pointsize>12</pointsize>
+ </font>
+ </property>
<property name="text">
<string>Satellite status</string>
</property>
<set>Qt::AlignCenter</set>
</property>
</widget>
+ <widget class="QLabel" name="labelRoutePicture">
+ <property name="geometry">
+ <rect>
+ <x>200</x>
+ <y>170</y>
+ <width>80</width>
+ <height>80</height>
+ </rect>
+ </property>
+ <property name="autoFillBackground">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="pixmap">
+ <pixmap resource="graphics.qrc">:/new/prefix1/Graphics/route.png</pixmap>
+ </property>
+ <property name="scaledContents">
+ <bool>true</bool>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelRouteStatus">
+ <property name="geometry">
+ <rect>
+ <x>90</x>
+ <y>190</y>
+ <width>301</width>
+ <height>51</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>12</pointsize>
+ </font>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Route status</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" name="labelGpsSpeed">
+ <property name="geometry">
+ <rect>
+ <x>540</x>
+ <y>40</y>
+ <width>241</width>
+ <height>91</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>36</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>GPS speed</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
</widget>
- <resources/>
+ <resources>
+ <include location="graphics.qrc"/>
+ </resources>
<connections/>
</ui>
+/*
+ * SettingsDialog class
+ *
+ * @author Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
#include "settingsdialog.h"
#include "ui_settingsdialog.h"
+#include "usersettings.h"
SettingsDialog::SettingsDialog(QWidget *parent) :
QDialog(parent),
this->setWindowTitle("Settings");
this->ui->regEMailLineEdit->setText("@");
instructionsDialog = new InstructionsDialog;
+
+ if (loginSaved())
+ {
+ QString uName, pWord;
+
+ getLoginInfo( &uName, &pWord);
+ this->username = uName;
+ this->password = pWord;
+
+ ui->setUserPasswordLineEdit->setText(this->password);
+ ui->setUserUsernameLineEdit->setText(this->username);
+
+ // Already someone as user - change button text to "Change"
+ ui->setUserPushButton->setText("Change user");
+ }
}
SettingsDialog::~SettingsDialog()
this->username = ui->setUserUsernameLineEdit->text();
this->password = ui->setUserPasswordLineEdit->text();
+ // Save these also to usersettings
+ saveLogin( this->username, this->password);
+
+ // Set "Set/Change User" button text
+ if (this->username.length() > 0)
+ {
+ ui->setUserPushButton->setText("Change user");
+ }
+ else
+ { // Username "cleared"
+ ui->setUserPushButton->setText("Set user");
+ }
+
emit userNameChanged();
//close(); //using close() hides popup-window which reports error from server
+/*
+ * SettingsDialog class
+ *
+ * @author Olavi Pulkkinen <olavi.pulkkinen@fudeco.com>
+ * @copyright (c) 2010 Speed Freak team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ */
+
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
# -------------------------------------------------
# Project created by QtCreator 2010-03-29T09:21:42
+# @author Speed Freak team
+# @copyright (c) 2010 Speed Freak team
+# @license http://opensource.org/licenses/gpl-license.php GNU Public License
# -------------------------------------------------
QT += dbus \
network \
categorylist.cpp \
httpclient.cpp \
xmlreader.cpp \
- xmlwriter.cpp
+ xmlwriter.cpp \
+ gpsdata.cpp \
+ maemo5locationprivate.cpp \
+ maemo5location.cpp
HEADERS += mainwindow.h \
creditsdialog.h \
routedialog.h \
categorylist.h \
httpclient.h \
xmlreader.h \
- xmlwriter.h
+ xmlwriter.h \
+ maemo5locationprivate.h \
+ maemo5location.h \
+ gpsdata.h
+
FORMS += mainwindow.ui \
creditsdialog.ui \
routedialog.ui \
calibratedialog.ui \
topresultdialog.ui
RESOURCES += graphics.qrc
+contains(QT_CONFIG, hildon):CONFIG += hildon
+CONFIG += link_pkgconfig
+
+# Enable this to disable debugging
+DEFINES += QT_NO_DEBUG_OUTPUT
+target.path += /usr/lib
+devincludes.files = $$HEADERS
+devincludes.path += /usr/include/$$TEMPLATE$$TARGET
+INSTALLS += target \
+ devincludes
+PKGCONFIG += glib-2.0 \
+ liblocation
+exists(/usr/lib/liblocation.so) {
+ DEFINES += LIBLOCATION
+ message(liblocation found)
+}
settings.setValue("password", password);
}
+void getLoginInfo(QString *userName, QString *password)
+{
+ UserSettings myLogin;
+ myLogin.readLoginSettings( userName, password);
+}
+
void saveLogin( QString userName, QString password)
{
UserSettings myLogin;
bool loginSaved( void);
void saveLogin( QString userName, QString password);
+void getLoginInfo( QString *userName, QString *password);
#endif // USERSETTINGS_H