Click here to Skip to main content
Click here to Skip to main content

Tagged as

Microsoft's First Accelerometer API (for ZuneHD)

, 25 Sep 2009
Rate this:
Please Sign up or sign in to vote.
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.

License

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

Share

About the Author

Joel Ivory Johnson
Software Developer Razorfish
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.
 
For the past few years I've been providing solutions to clients using Microsoft technologies for web and Windows applications.
 
While most of my CodeProject.com articles are centered around Windows Phone it is only one of the areas in which I work and one of my interests. I also have interest in mobile development on Android and iPhone. Professionally I work with several Microsoft technologies including SQL Server technologies, Silverlight/WPF, ASP.Net and others. My recreational development interest are centered around Artificial Inteligence especially in the area of machine vision.
 
Follow on   Twitter

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web03 | 2.8.140827.1 | Last Updated 25 Sep 2009
Article Copyright 2009 by Joel Ivory Johnson
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid