<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Indie iPhone Development Blog &#187; accelerometer</title>
	<atom:link href="http://blog.indieiphonedev.com/tag/accelerometer/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.indieiphonedev.com</link>
	<description>The musings of an independent iPhone developer</description>
	<lastBuildDate>Mon, 20 Jun 2011 18:48:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to test location and accelerometer functions from the comfort of your home</title>
		<link>http://blog.indieiphonedev.com/2010/02/07/how-to-test-location-and-accelerometer-functions-from-the-comfort-of-your-home/</link>
		<comments>http://blog.indieiphonedev.com/2010/02/07/how-to-test-location-and-accelerometer-functions-from-the-comfort-of-your-home/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 03:01:11 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[accelerometer]]></category>
		<category><![CDATA[core location]]></category>
		<category><![CDATA[google maps]]></category>
		<category><![CDATA[iPhone app]]></category>
		<category><![CDATA[objective-C]]></category>
		<category><![CDATA[source code]]></category>

		<guid isPermaLink="false">http://blog.indieiphonedev.com/?p=123</guid>
		<description><![CDATA[The LogYourRun iPhone app uses both the GPS and the accelerometer functions of the iPhone.  Neither the GPS nor the accelerometer can be accessed on the iPhone simulator so to circumvent this I used the following methods: Accelerometer: Otto Chrons has a great Google code project which contains the code for an app that can [...]]]></description>
			<content:encoded><![CDATA[<p>The LogYourRun iPhone app uses both the GPS and the accelerometer functions of the iPhone.  Neither the GPS nor the accelerometer can be accessed on the iPhone simulator so to circumvent this I used the following methods:</p>
<p><strong>Accelerometer: </strong> Otto Chrons has a great <a href="http://code.google.com/p/accelerometer-simulator/wiki/Home" target="_blank">Google code project</a> which contains the code for an app that can be run on an iPod touch or iPhone which is on the same subnet as your development computer.  The app will transmit accelerometer data which can be caught by some code that you can insert into your Xcode project.  When you run your app on the iPhone simulator it will thus receive the accelerometer data from the real life device.  This was a great help in troubleshooting the setup of the pedometer functionality.  I was running around in my living room counting steps and comparing to the # of steps on the iPhone simulator.  Be sure to remove the accelerometer simulator code from your application before releasing.</p>
<p><strong>GPS:</strong> Everyone who has played with the location manager on the iPhone Simulator knows that you will only get only one location from the location manager on the iPhone Simulator.  Testing the GPS functionality is a critical part of testing the LogYourRun app.  I could run the app on an iPhone and then run/walk/drive around outside &#8211; but that would take much too long and the weather in Saint Louis is not conductive to such testing.  Instead I added a button to the pedometer screen of the application which when clicked runs the following code:</p>
<pre class="brush: objc; title: ; notranslate">
- (IBAction) locationButton:(id)sender {
   CLLocation *thisLocation;
   double latitude  = 37.33168900 + (float) ((random() % 100) +1) / 1000000.0;
   double longitude = -122.03073100 + (float) ((random() % 100) +1) / 1000000.0;
   thisLocation = [[CLLocation alloc] initWithLatitude:latitude longitude:longitude];
   [self locationManager:locationManager didUpdateToLocation:thisLocation fromLocation:thisLocation];
   [thisLocation release];
}</pre>
<p>This piece of code creates a random location close to the location that the iPhone Simulator will usually get from the core location (One Infinite Loop).  The location is sent to the location manager delegate function of the pedometer class and is handled as if it came from the real location manager.  Since the location is different from the previous location the getDistanceFrom: still works.  When I am ready to submit the application all I have to do is hide the two buttons (probably should be done programatically &#8211; since one of these days I will forget).</p>
<div id="attachment_122" class="wp-caption aligncenter" style="width: 210px"><a href="http://blog.indieiphonedev.com/wp-content/uploads/2010/02/Screenshot.png"><img class="size-medium wp-image-122" title="Pedometer showing location and step button" src="http://blog.indieiphonedev.com/wp-content/uploads/2010/02/Screenshot-200x300.png" alt="Pedometer showing location and step button" width="200" height="300" /></a><p class="wp-caption-text">The pedometer screen showing location and step button</p></div>
<p style="text-align: center;">
<div id="attachment_127" class="wp-caption aligncenter" style="width: 210px"><a href="http://blog.indieiphonedev.com/wp-content/uploads/2010/02/Screenshot-2010.02.07-21.45.30.png"><img class="size-medium wp-image-127" title="Locations shown on map" src="http://blog.indieiphonedev.com/wp-content/uploads/2010/02/Screenshot-2010.02.07-21.45.30-200x300.png" alt="Locations shown on map" width="200" height="300" /></a><p class="wp-caption-text">The random locations shown on map</p></div>
<p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.indieiphonedev.com%2F2010%2F02%2F07%2Fhow-to-test-location-and-accelerometer-functions-from-the-comfort-of-your-home%2F&amp;title=How%20to%20test%20location%20and%20accelerometer%20functions%20from%20the%20comfort%20of%20your%20home" id="wpa2a_2"><img src="http://blog.indieiphonedev.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.indieiphonedev.com/2010/02/07/how-to-test-location-and-accelerometer-functions-from-the-comfort-of-your-home/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

