Click here to Skip to main content
15,885,546 members
Articles / Mobile Apps / Windows Mobile

Microsoft's First Accelerometer API (for ZuneHD)

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
25 Sep 2009CPOL2 min read 11.9K   1  
Microsoft's First Accelerometer API (for ZuneHD)

As things stand now on Windows Mobile, there exist devices with accelerometers, but the method for reading that accelerometer is dependent on the device OEM. Currently the only OEM that supports access to their accelerometers is Samsung through the Samsung Windows Mobile SDK; their solution for giving developers access to their device specific features. HTC doesn't officially provide accelerometer support but their implementation has been reverse engineered far enough to be usable. There are other devices with accelerometers, but documentation on accessing them is not widely available (example: does anyone know how to read the accelerometer on the LG Incite).

While it's not officially known if and when Microsoft will provide a common API on accelerometer access, the ZuneHD is believed to be an indicator of what is yet to come. With the USA release of the ZuneHD, there was also an update to the XNA game studio, a free managed (C#/VB.NET based) development environment that supports the previous generation Zunes, the Xbox 360, and the PC. In addition to adding the ZuneHD as a supported target, some new classes were added to access some of the ZuneHD specific functionality, including the Accelerometer. I had interest in looking at the class in the hopes that it provides insight on what is yet to come.

Accelerometer Capabilities

The Accelerometer class has two methods of interest, GetCapabilities and GetState. You will always want to call GetCapabilities first. It will let you know whether or not your code is running on a device that has an accelerometer. It returns an AccelerometerCapabilities member. The IsConnected member lets you know whether or not the accelerometer is available. Three members, HasXAxis, HasYAxis, and HasZAxis tell on what axes the accelerometer detects acceleration. For the ZuneHD, all three of these are true. Though in the future, I could see an interface (such as a steering wheel) that doesn't need all three axes. If you needed information on the resolution of the accelerometer or its boundries, the information can be retrieved through the members AccelerometerResolution, MaximumAcceleration, and MinimumAcceleration.

Reading the Values

The accelerometer's values can be acquired through the method Accelerometer.GetState(). It returns an AccelerometerState object. The IsConnected member lets you know if an accelerometer is available and Acceleration which is of type Vector3 (member containing X, Y, and Z values of type float).

So What Does this Mean for Windows Mobile Developers

Nothing officially. But this being an accelerometer API coming from Microsoft I found it interesting to look at. My hopes are that it gives insight to what to expect in Windows Mobile 7. But right now, there is no way to be certain of that.

This article was originally posted at http://j2i.net/blogs/home/default.aspx

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
United States United States
I attended Southern Polytechnic State University and earned a Bachelors of Science in Computer Science and later returned to earn a Masters of Science in Software Engineering. I've largely developed solutions that are based on a mix of Microsoft technologies with open source technologies mixed in. I've got an interest in astronomy and you'll see that interest overflow into some of my code project articles from time to time.



Twitter:@j2inet

Instagram: j2inet


Comments and Discussions

 
-- There are no messages in this forum --