For best results, lock the operating system orientation. (Double click home button, scroll to left, click leftmost icon so that a lock appears within it.) The calibration isn't 100% accurate; I'm still getting my head around the API, and tweaking the CSS.
This is a quick hack-up of a spirit level for iPhone/iPad/iPod Touch devices with iOS 4.2 or higher. (Ultimately it should work on any device with the appropriate hardware and support for the API.)
Written by John Smith, November 2010. My blog . Twitter
Debug text appears here