Sunday, July 29, 2012

Qt Speed Gauge Tutorial 3 - Adding GPS

This is part 3 of my SpeedGauge ttuorial. In this part we will add GPS capability, we will explain what is PositionSource element and we will introduce some new JavaScript Math functions. Also in this tutorial you are able to download the source code for Symbian^3 and for MeeGo phones.  Hope you enjoy it.

 

This tutorial is created by using Qt SDK 1.2.1 For more info look for the link in the Download section below this text.
This is part 3 of the Qt SpeedGauge tutorial for Symbian^3 and MeeGo. Check out other parts that are currently available:
Qt SpeedGauge tutorial 1 - Arranging the UI
Qt SpeedGauge tutorial 2 - Fixing the loose ends

If you like these tutorials please support them by buying my app from Ovi store
SpeedGauge app from Ovi Store

Ok, so here is what we will be doing in this video:
1. Add PositionSource element
It will enable the communication with GPS from your phone


2. Create currentSpeed property
This will act as an variable that holds current speed

3. Calculate value of needleAngle property
Every time we get new update from PositionSource element we calculate new needleAngle. We have to find out how many degrees does take to change speed for 1 Kmph. So we devide number of degrees our needle is allowded to move (from -36 to 220) with the max speed on our dial (which is 240). Then we multiply it with current speed and subtract 36 from it.

4. Edit the project file to be able to use GPS on phone
Symbian^3 phone have a security mechanism that involves capabilities. This is why you have to declare which parts of your phone will you be using in your app. If you don't declare that you need GPS the app on the phone won't work. It won't even use the GPS.
You don't have to edit the project file if you are trying the app on N9.

The rest is cosmetics, so watch the video :)

In this tutorial I will provide you with source code for N9 MeeGo. You will notice there are few slightly differences from Symbian and MeeGo code but the logic behind it is the same.Also you will noticed that graphics are not adopted to N9. I used the same graphics as on Symbian^3 phones.

And finally here is the video. The video is 720p so you can watch it full screen.

 

Download:

Qt SDK 1.2.1
SpeedGauge app from Ovi Store 
Complete project for Symbian^3 phones
Complete project for MeeGo phones

Learn More:

QML PositionSource Element
JavaScript Math.floor() method
JavaScript .toFixed() method
List of all my Symbian^3 and  MeeGo tutorials

1 comment:

  1. thanks you for tutorials!! can we show the speed number in home screen widget ? thx

    ReplyDelete