If you're the type of person who enjoys conspiracy theories, you may be wondering if all this Windows Phone 7 hype is really just a ploy by Microsoft to get developers to buy more Zune HDs. It actually makes a little bit of sense: Having first been enticed into coding in C# for small devices, we then discover that no actual Windows Phone 7 devices are allowed outside the Redmond city limits except when accompanied by armed guards hired from Blackwater. Several times I've been in the same room as a phone but never closer than about 10 feet.
Although the phone emulator included with the Windows Phone 7 developer tools is adequate for some purposes, it doesn't really give you a good sense of the user interaction with capacitance multi-touch and the accelerometer. To my mind, successful understanding of these input devices is likely to make or break Windows Phone 7 apps.
That's where the Zune HD comes in. Although the Zune HD is limited to XNA 2D programming — it can't do XNA 3D or Silverlight like the phone — it does allow experimenting with capacitance multi-touch and an accelerometer that will probably be similar to the phone.
What's weird, however, is that programming for the Zune HD has now become somewhat of a PITA. You can't use Visual Studio 2010; you need to use Visual Studio 2008. You can't use XNA Game Studio 4.0 (like the phone); you need XNA Game Studio 3.1 and the Zune Extensions. Fortunately you can run a Zune-enabled configuration of VS 2008 alongside a Phone-enabled configuration of VS 2010.
In my blog entry Visualizing the Windows Phone Accelerometer (on a Zune HD) I discussed one program to help you visualize the accelerometer. But I haven't been happy with that one. The impetus for another accelerometer visualization program came from questions I asked myself such as: How does the accelerometer react when you tap the side of the device or shake it? I assumed that spikes in the components of the acceleration vector resulted, but they were too fast to see with the earlier program. I wanted the spikes visually preserved so I would have a better idea how I could interpret them in code. This suggested to me a line graph of the three components of the acceleration vector, and that's what I did:
(By the way, getting screen shots from the Zune HD is a snap. To connect your Zune HD with Visual Studio 2008, you use the XNA Game Studio Device Center. In that program, right click the device icon, and you can get a shot of the screen as a PNG File.)
This is the view when you hold the Zune HD upright after it's been turned around a little. The graph continuously moves up the screen with new values coming in at the bottom and displaying the history from the past 16 seconds. The heavier horizontal lines are seconds; the lighter lines divide each second into 6 groups of 5 ticks. (The screen refresh for both the Zune HD and Windows Phone 7 is 30 fps.) The X, Y, and Z components of the acceleration vector are the Red, Green, and Blue lines, respectively. The center vertical line indicates a value of 0; the left edge of the screen is –2 and the right edge is +2. The heavier vertical lines represente –1 on the left and +1 on the right. The lighter vertical lines are increments of 0.25.
When the device is at rest, the acceleration vector should have a magnitude of 1 (or thereabouts) and point towards the center of the Earth. That's how software can determine the orientation of the device. But sudden taps or jerks do indeed cause spikes (as you can tell by experimenting). Here's the source code.
Programming Windows Phone 7 Series
Free ebook to be published later this year. Preview excerpts available now.