I couldn’t resist creating another GPS related mobile application. One of the neat pieces of data you get from your GPS device is time. This is great. It is like having one of the clocks that can update itself over the air by reading data transmitted from various atomic clocks throughout the world. Many phones today have the ability to update their time by connecting to the OEM’s time servers, but not all. And there are still lots of Windows Mobile classic devices in the world that do not have cellular capabilities.
Vista has the ability to update its time by using a feature called Internet Time. Basically Vista connects to time.windows.com and reads a Network Time Protocol server.
GPS Clock
Our user interface is simple and direct. We are using a nice graphic to adds some visual zing to the application. At the top of the screen we show the user their current device time and their current GPS time.
This allows the user to tell at a glance if they need to update their device’s time using the Update menu option.
On the menu we have added some simple settings features: GPS Start, GPS Stop, About, and Exit.
This is one of those Web 2.0 ideas where an application does one thing but does it very well. Sometimes these are the best apps. In this case, our application provides a bride for GPS time data to become device time data.
Somtimes that’s all it takes to make a user happy.
UpdateData Method:
1: void UpdateData(object sender, System.EventArgs args)
2: {
3: if (gps.Opened)
4: {
5: if (position != null)
6: {
7: if (position.TimeValid)
8: {
9: gpsTime = position.Time;
10:
11: labelCurrentGpsDate.Text = gpsTime.ToLongDateString();
12: labelCurrentGpsTime.Text = gpsTime.ToLongTimeString();
13: }
14: }
15: }
16: }
UpdateTime Method:
1: private struct SYSTEMTIME
2: {
3: public short Year;
4: public short Month;
5: public short DayOfWeek;
6: public short Day;
7: public short Hour;
8: public short Minute;
9: public short Second;
10: public short Milliseconds;
11: }
12:
13: [DllImport("coredll.dll")]
14: private static extern bool SetSystemTime(ref SYSTEMTIME time);
15:
16: private void UpdateTime()
17: {
18: DateTime idag = gpsTime.ToUniversalTime();
19:
20: SYSTEMTIME s = new SYSTEMTIME();
21: s.Year = (short) idag.Year;
22: s.Month = (short) idag.Month;
23: s.DayOfWeek = (short) idag.DayOfWeek;
24: s.Day = (short) idag.Day;
25: s.Hour = (short) idag.Hour;
26: s.Minute = (short) idag.Minute;
27: s.Second = (short) idag.Second;
28: s.Milliseconds = (short) idag.Millisecond;
29:
30: SetSystemTime(ref s);
31: }
Possibilities:
How about changing the color of the date and time if they are more than five minutes off? Simple feature to add but really helps the user. And that’s what matters.
Download executable: gpsClock.cab
Download Source Code: gpsClock.zip
Feedback:
Want more? What else would you like to see? Time’s running out on submitting ideas. Be sure to get yours in soon!