Speed

Snowboarding’s fastest speed record stands at over 125MPH –  but whether you’ve got a deathwish or not, our speed sensors will track you all the way.  Multiple sensors were tested during development, but ultimately nothing even touches the Nokia N8’s GPS for accuracy and reliability.

Why Measure Speed?

The most commonly requested metric from our boarders. Not just max speeds, the data will show acceleration too, so you could create an app to share via twitter each and every time you fall over. Combine it with other sensors like orientation and position for really interesting intepretations.

#ifndef PUSHN8PHONEGPS_H
#define PUSHN8PHONEGPS_H

#include <qmobilityglobal.h>
#include <QGeoPositionInfoSource>
#include <QDateTime>

#include “npushgpstick.h”

#include “pushburtongenericdevice.h”

#include <tz.h>
#include <TzLocalizer.h>
#include <TzLocalizationDataTypes.h>

QTM_BEGIN_NAMESPACE
class QGeoPositionInfo;
QTM_END_NAMESPACE

QTM_USE_NAMESPACE

class PushN8PhoneGPS : public PushBurtonGenericDevice
{
Q_OBJECT
public:
PushN8PhoneGPS(QObject * parent);

~PushN8PhoneGPS();

QString get_description();

bool is_online();

virtual void start_readings();
virtual void stop_readings();

public slots:
void positionUpdated(QGeoPositionInfo);

private:

void computeUTCOffset();

QGeoPositionInfoSource * gpsSource;
bool gpsOnline;
int UTCOffset;

protected:
void timerEvent(QTimerEvent *);
};

#endif // PUSHN8PHONEGPS_H

PushN8PhoneGPS::PushN8PhoneGPS(QObject * parent)
{
computeUTCOffset();
gpsSource = QGeoPositionInfoSource::createDefaultSource(0);

connect(gpsSource, SIGNAL(positionUpdated(QGeoPositionInfo)),
this, SLOT(positionUpdated(QGeoPositionInfo)));

gpsSource->requestUpdate(60000);
gpsSource->setUpdateInterval(500);

gpsOnline = false;

timerId = -1;//disable any periodic events

}

PushN8PhoneGPS::~PushN8PhoneGPS()
{
gpsSource->deleteLater();
}

void PushN8PhoneGPS::start_readings()
{
gpsSource->startUpdates();
}

void PushN8PhoneGPS::stop_readings()
{
gpsSource->stopUpdates();
}

void PushN8PhoneGPS::timerEvent(QTimerEvent *)
{

}

QString PushN8PhoneGPS::get_description()
{
return QString(“Phone’s Internal Gps”);
}

bool PushN8PhoneGPS::is_online()
{
return gpsOnline;
}

void PushN8PhoneGPS::positionUpdated(QGeoPositionInfo info)
{
if(info.isValid())
{
//emitting connected signal when receiving first reading
if(!gpsOnline)
emit connected();

gpsOnline = true;

QDateTime correctedTstamp;
correctedTstamp = info.timestamp().addSecs(UTCOffset);
info.setTimestamp(correctedTstamp);

NPushGpsTick * newGPSTick = new NPushGpsTick(info);

if(receivers(SIGNAL(reading_ready(NPushLogTick*))) > 0)
{
emit reading_ready(newGPSTick);
} else {
delete newGPSTick;
}
}

}

void PushN8PhoneGPS::computeUTCOffset()
{
RTz tzServer;
CTzId* timeZoneID;

User::LeaveIfError(tzServer.Connect());

CleanupClosePushL(tzServer);

timeZoneID = tzServer.GetTimeZoneIdL();

RArray<TInt> tzid;
RArray<TInt> utcOffsets;

tzid.Append(timeZoneID->TimeZoneNumericID());
tzServer.GetOffsetsForTimeZoneIdsL(tzid, utcOffsets);

UTCOffset = utcOffsets[0]*60;

qDebug() << “Local Offset to UTC” << UTCOffset;

tzid.Close();
utcOffsets.Close();

CleanupStack::PushL(timeZoneID);
CleanupStack::PopAndDestroy(timeZoneID);
CleanupStack::PopAndDestroy(1);
}

/*
* Copyright (c) 2011 Nokia Corporation
*
* This file is part of the Push Snowboarding Project, More info at:
* http://pushsnowboarding.com/tech/developer-centre/
*
* This file is under the GPLv3 License, more details at:
* http://www.gnu.org/licenses/
*
*/