Compass app for Windows Phone 7
| As per the request of an XDA user, I’ve put together a Compass application for Windows Phone 7 that will work (for now) on Samsung phones. Windows Phone 7 device guidelines dictate that each phone must have Compass hardware, but there is not a common API through which developers can access the hardware. Samsung includes support in their platform drivers, so I’ve taken advantage of that.
As always, you can download the XAP and source code. A developer-unlocked Windows Phone is required. This app will not work on Dell, HTC or LG phones as of this posting. I have tested so far on the Samsung Focus, I suspect it will work on all Samsung Windows Phones. |
![]() |
Comments
21 Comments on Compass app for Windows Phone 7
-
Sina on
Tue, 18th Jan 2011 12:36 AM
-
David Gardiner on
Tue, 18th Jan 2011 1:38 AM
-
Dave on
Tue, 18th Jan 2011 1:42 AM
-
Dave on
Tue, 18th Jan 2011 1:43 AM
-
Menny on
Tue, 18th Jan 2011 8:57 AM
-
Ando on
Tue, 18th Jan 2011 9:50 AM
-
Dave on
Tue, 18th Jan 2011 3:34 PM
-
Ashraf on
Tue, 18th Jan 2011 4:04 PM
-
David Gardiner on
Tue, 18th Jan 2011 5:14 PM
-
Dave on
Tue, 18th Jan 2011 5:17 PM
-
David Gardiner on
Tue, 18th Jan 2011 11:07 PM
-
Dave on
Tue, 18th Jan 2011 11:11 PM
-
Roger on
Wed, 19th Jan 2011 5:18 AM
-
Gerald on
Wed, 19th Jan 2011 8:33 PM
-
Dave on
Wed, 19th Jan 2011 8:37 PM
-
Dave on
Wed, 19th Jan 2011 8:37 PM
-
Roger on
Thu, 20th Jan 2011 2:31 AM
-
Martin on
Sat, 22nd Jan 2011 3:09 PM
-
Simon on
Tue, 15th Feb 2011 4:15 PM
-
xutoma on
Fri, 18th Mar 2011 5:39 PM
-
Dave on
Fri, 1st Apr 2011 3:55 PM
LG Phones already have a fully working Compass.Yyou can access a fully working compass in the MFG app under Engineer Menu->Device Test->Sensor Test->Compass. Or you can just run ScanSearch…Perhaps that could help in getting it to work on LG phones?
Installs and runs on my Samsung Omnia 7, though I’m not convinced that it’s displaying valid data.. compass keeps swinging around all over the place.
Maybe it’s because I’m indoors?
-dave
@dave -
Maybe. For best results, hold it as if you’re trying to take a photo of the floor. Leaving it still on a table (away from other electronics) should result in a pretty stable reading after several seconds.
@Sina – thanks, I’ll look into it!
great work once again Dave is the man.
On Omnia 7 it randomly jumps all over the place
@Ando – even while holding it still, pointing downward, as if you were to take a photo of the floor?
Dave, thanks; you did a great job.
I left it sitting on my desk and the reading didn’t look correct.
I did notice that if I tilted the phone (in a horizontal way), then the reading sometimes seemed to follow the the down-side of the tilt..
almost like it was hooked into some kind of data source but not the necessarily the compass.
@David -
The driver doesn’t give me a way to verify accuracy or anything. On iOS, it instructs you to remove electronic interference (which means your desk/computer may be the issue). It also instructs you to wave the phone around in a figure 8… and then it gets a reading.
It does sound like you may have an interference issue.
Did another couple more tests, as I noticed there was a big steel filing cabinet below the desk which could have been a problem.
Went for a walk outside – reading was still inaccurate, and would change depending on the angle I tilted.
Then did some more tilting and it’s almost like the app has actually hooked into some kind of gyroscope-type data.
Having said that, I’ve now had the phone hang twice whilst using the compass app, so there’s definitely something strange going on. If I get a chance, I’ll grab your source code and run it on the phone with the debugger enabled to see if that sheds any light on what’s going on.
@David – I’m pretty sure the reading of any digital compass (magnetometer) will change based on angle. As far as I can tell, doing anything but facing it straight down will result in an inaccurate reading.
The Samsung interface doesn’t seem perfect – sometimes it would return data >360 (like in the 10,000 range).
Also note that, if you force-quit the application using the debugger, the Samsung driver gets into a bad state and the phone will need a reboot, else the reading will remain constant at zero.
On my Focus, the needle rotates the wrong way. For example, when I hold the phone level (and “north up”), it reads ~0°N as expected. Then, as I turn to the west, the “needle” moves toward E (but the readout displays in °W as expected). This makes the compass confusing to use.
Seems to work fairly well, but appears a bit jumpy. I haven’t had a chance to check the accuracy, though. It’s certainly in the right ballpark.
Now a question: I can’t load the Homebrew solution –
the TestApp.csproj
@Roger – it rotates the correct way. The needle will always point north. I realize having the face itself not rotate is causing some confusion though.
Gerald – Just remove TestApp from the solution, it isn’t needed.
@Dave – thanks, that makes better sense, I wasn’t interpreting the compass correctly at all (user fail!)
If the compass is so bad maybe that’s the reason the API wasn’t included at first…
Has anybody yet heard of a way to access compass data on HTC devices?
Is there any known models for converting these readings based on the XYZ accelerometer data? For example, if I tilt the phone as if I was taking a picture of the horizon; how can we translate the heading to get an accurate reading? I’ve tried searching for the web but not sure how to get an answer to this! Thanks for any help.
Very good
@Simon – check the Samsung COM interface, there is a method for Bearing that returns x/y/z.


