# Friday, December 12, 2003
« Finalization and the JIT | Main | Asynchronous Exceptions »

(This entry is totally unrelated to IKVM.NET)

Last week I got my new ThinkPad T41p and it has a cool feature, a built-in accelerometer. It is used to park the harddisk when the system detects shocks or falls down ("IBM Hard Drive Active Protection System").

I reverse engineered one of the IOCTLs that can be used to read the accelerometer data and built a simple C# application that displays an artificial horizon. It includes a simple reusable class that encapsulates the communication with the device driver (the standard IBM device driver).

Source can be found here.

Not very useful, but fun stuff anyway. In Longhorn this could be used to keep the desktop level :-)

Friday, December 12, 2003 2:10:43 PM (W. Europe Standard Time, UTC+01:00)  #    Comments [13]
Friday, December 12, 2003 2:31:36 PM (W. Europe Standard Time, UTC+01:00)
Any chance of a picture of it in action? You're crazy, btw... =o)
Friday, December 12, 2003 3:19:54 PM (W. Europe Standard Time, UTC+01:00)
Hey Jeroen, you should modify your app so that it integrates under the acceleration curve. This way you could get time-to-velocity and time-to-distance measurements from your device and use it to measure 0-60 and 0-1/4 mile acceleration times using your laptop! This might give me a reason to get a T41p (that and the 128MB graphics card :)
Friday, December 12, 2003 3:35:02 PM (W. Europe Standard Time, UTC+01:00)
In a previous life I used to work on software to do just that, for the oil industry (tracking where you are while drilling a hole). See http://www.bakerhughes.com/inteq/evaluation/mwd/navitrak2.htm for an example of such a tool.
But I'm not sure I feel comfortable using my ThinkPad for this ;-)
Friday, December 12, 2003 6:35:37 PM (W. Europe Standard Time, UTC+01:00)
Have you considered the lucrative "rolling marbles around a maze" videogame segment?
Monday, December 15, 2003 8:17:38 PM (W. Europe Standard Time, UTC+01:00)
With a sufficiently accurate 3d model of your environment, could this be used to make the display of the laptop transparent? ;)

(You'd also need an indication of the angle between keyboard and screen to do this, I guess - does the laptop have that?)

Are you going to actually implement the "make your desktop level" hack for Longhorn? I'd love to see a photo or video of that in action ;)
Tuesday, December 16, 2003 4:06:43 PM (W. Europe Standard Time, UTC+01:00)
I don't think there is a sensor to determine the angle between keyboard and display. That would be cool though.

I might implement the Longhorn desktop levelling, but it'll be a while, because you really need the desktop compositing engine and I don't think that's in the current release.
Tuesday, December 16, 2003 9:42:44 PM (W. Europe Standard Time, UTC+01:00)
Another application: half-fill the screen with simulated water, and have it slosh around realistically as you move the laptop. Or any number of different variations on the "the screen's a box with something in it that behaves realistically" theme: Balls that just stay still until you shake the laptop and they start bouncing around; the standard "aquarium" screensaver but with the fish getting startled when their world gets bounced all over the place, other animals, the marbles-in-a-maze thing suggested earlier, use your computer as an egg-timer by standing it up like a christmas card and then turning it upside down...

The number of useless but fascinating things you can do with this hardware is endless... :)
Tuesday, January 13, 2004 11:56:33 PM (W. Europe Standard Time, UTC+01:00)
Hmmm - I've got it...

Etch-a-sketch - nothing special with the regular UI - however when you shake your machine - boom, a nice smearing erasure....
Jason Kaczor
Thursday, January 22, 2004 11:41:42 AM (W. Europe Standard Time, UTC+01:00)
Can you post an executable for those of us who can't compile C# code?
Robert Andrews
Thursday, January 22, 2004 12:32:06 PM (W. Europe Standard Time, UTC+01:00)
The executable (requires .NET Framework 1.1) is downloadable here:
Friday, March 9, 2007 12:55:53 AM (W. Europe Standard Time, UTC+01:00)
Do you know why it isn´t working with Windows Vista?
Tuesday, March 27, 2007 11:08:50 PM (W. Europe Daylight Time, UTC+02:00)
Thanks for posting this, it helped me out.

I wrote up an explanation and brief guide to accessing the sensor data on a Thinkpad from within a .NET application (the source is in C#). I provide calibration data, example code, a command-line executable for viewing / capturing the sensor data, and a small GUI application that graphically displays the x- and y-tilt values in real-time.

You can find the tutorial, etc. at:


Thursday, June 21, 2007 8:50:31 PM (W. Europe Daylight Time, UTC+02:00)
Here's my accelerometer app...

Comments are closed.