<?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>about:benjie</title>
	<atom:link href="http://www.benjiegillam.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.benjiegillam.com</link>
	<description>Benjie Gillam's blog, and home of MythPyWii - probably the best Wii remote (Wiimote) interface to MythTV - see sidebar.</description>
	<lastBuildDate>Tue, 06 Apr 2010 14:14:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>iPhone Music and Sound Effects in Parallel</title>
		<link>http://www.benjiegillam.com/2010/04/iphone-music-and-sound-effects-in-parallel/</link>
		<comments>http://www.benjiegillam.com/2010/04/iphone-music-and-sound-effects-in-parallel/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 13:49:55 +0000</pubDate>
		<dc:creator>Benjie</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[sdk]]></category>
		<category><![CDATA[sound]]></category>

		<guid isPermaLink="false">http://www.benjiegillam.com/?p=337</guid>
		<description><![CDATA[I was trying to find out how to use [MPMusicPlayerController iPodMusicPlayer] and AVAudioPlayer in parallel. I&#8217;d read before that I&#8217;d need Audio Sessions, but the documentation for that was huge and confusing. Fortunately Andrew pointed me at this post from Mark at Sputnik Games which solved my issue immediately just by copying and pasting 14 [...]]]></description>
			<content:encoded><![CDATA[<p>I was trying to find out how to use [MPMusicPlayerController iPodMusicPlayer] and AVAudioPlayer in parallel. I&#8217;d read before that I&#8217;d need Audio Sessions, but the documentation for that was huge and confusing. Fortunately Andrew pointed me at <a title="iPhone games and iPod Music" href="http://www.sputnikgames.com/blog/?p=14" target="_blank">this post</a> from Mark at Sputnik Games which solved my issue immediately just by copying and pasting 14 lines of code into the applicationDidFinishLaunching method of my application delegate (see below). Sputnik Games&#8217; blog doesn&#8217;t seem to support comments, so I thought I&#8217;d buy his latest game, <a href="http://www.sputnikgames.com/aerolite_iphone_game.htm">Aerolite</a>, and write this post to show my appreciation. Thanks Mark!</p>
<blockquote><p><code class="source">

  OSStatus result = AudioSessionInitialize(NULL, NULL, NULL, self);
  <span class="enscript-keyword">if</span> (result) {
     <span class="enscript-comment">// Init error, handle error here
</span>  }<span class="enscript-keyword">else</span> {
    UInt32 category = kAudioSessionCategory_AmbientSound;
    result = AudioSessionSetProperty(kAudioSessionProperty_AudioCategory,
                                     <span class="enscript-keyword">sizeof</span>(category), &amp;category);
    <span class="enscript-keyword">if</span> (result) {
       <span class="enscript-comment">// set audio session error, handle error here
</span>    }<span class="enscript-keyword">else</span> {
      result = AudioSessionSetActive(true);
      <span class="enscript-keyword">if</span> (result) {
         <span class="enscript-comment">// Set audio session active error, handle error here
</span>      }
    }
  }</code>
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.benjiegillam.com/2010/04/iphone-music-and-sound-effects-in-parallel/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MythPyWii &#8211; now on Google Code</title>
		<link>http://www.benjiegillam.com/2010/01/mythpywii-now-on-google-code/</link>
		<comments>http://www.benjiegillam.com/2010/01/mythpywii-now-on-google-code/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 18:58:10 +0000</pubDate>
		<dc:creator>Benjie</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MythPyWii]]></category>
		<category><![CDATA[MythTV]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://www.benjiegillam.com/?p=335</guid>
		<description><![CDATA[Fancy submitting to MythPyWii? Let me know! It&#8217;s now on Google Code.
Code, documentation, bugs, bugfixes, etc all welcome!
]]></description>
			<content:encoded><![CDATA[<p>Fancy <a href="http://code.google.com/p/mythpywii/">submitting to MythPyWii</a>? Let me know! It&#8217;s now on Google Code.</p>
<p>Code, documentation, bugs, bugfixes, etc all welcome!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.benjiegillam.com/2010/01/mythpywii-now-on-google-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>N900: first impressions</title>
		<link>http://www.benjiegillam.com/2009/12/n900-first-impressions/</link>
		<comments>http://www.benjiegillam.com/2009/12/n900-first-impressions/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 09:18:39 +0000</pubDate>
		<dc:creator>Benjie</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[first]]></category>
		<category><![CDATA[impressions]]></category>
		<category><![CDATA[indestructible]]></category>
		<category><![CDATA[n900]]></category>
		<category><![CDATA[nokia]]></category>

		<guid isPermaLink="false">http://www.benjiegillam.com/?p=254</guid>
		<description><![CDATA[This post is part 2 of a three part series. You may also be interested in:
Part 1: N900: the tale of the indestructible box
Part 3: N900: a phone for hackers? (coming soon&#8230;)
After conquering the indestructible box and charging the N900 I decided to have a quick play. I watched the getting started video which I [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>This post is part 2 of a three part series. You may also be interested in:<br />
<a href="http://www.benjiegillam.com/2009/12/n900-the-tale-of-the-indestructible-box/">Part 1: N900: the tale of the indestructible box</a><br />
Part 3: N900: a phone for hackers? (coming soon&#8230;)</em></strong></p>
<p>After <a href="http://www.benjiegillam.com/2009/12/n900-the-tale-of-the-indestructible-box/">conquering the indestructible box</a> and charging the N900 I decided to have a quick play. I watched the getting started video which I found to be both beautifully smooth, showing off the high definition of the N900 screen immediately, and somewhat slow content-wise.</p>
<p><a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/DSCF4230.JPG"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/DSCF4230-300x121.jpg" alt="G1 (top), N900 (left), iPhone 3GS (right)" title="G1 (top), N900 (left), iPhone 3GS (right)" width="300" height="121" class="alignleft size-medium wp-image-323" /></a></p>
<p>The N900 is similar in width and height to the <a class="zem_slink" href="http://www.apple.com/iphone" title="iPhone" rel="homepage">iPhone</a> but is much greater in depth at 1.8cm &#8211; just a millimetre deeper than the G1. This is not surprising due to it&#8217;s hard keyboard and more advanced hardware.</p>
<p><a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/DSCF4219.JPG"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/DSCF4219-300x57.jpg" alt="G1 (back), N900 (left), iPhone 3GS (right)" title="G1 (back), N900 (left), iPhone 3GS (right)" width="300" height="57" class="alignleft size-medium wp-image-324" /></a></p>
<p>The first thing that struck me about the N900 (other than how high definition the hands were in the famous Nokia splash video!) was how much force it required to press on the screen. The iPhone (my current primary phone because I develop iPhone fitness apps) only requires the lightest of touches; whilst the <a class="zem_slink" href="http://en.wikipedia.org/wiki/HTC_Dream" title="HTC Dream" rel="wikipedia">Android G1</a> (my wife&#8217;s phone) requires a bit more. I later discovered the reason for this heavier interface was probably the stylus (which I discovered accidentally while interrogating the outside of the device), which is great to use &#8211; reminds me of my old iPaqs only much much higher resolution and more responsive!</p>
<p><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/vcHeVMbO-Ck&#038;hl=en_GB&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/vcHeVMbO-Ck&#038;hl=en_GB&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p>
<p>I noticed that every time I touched the screen firmly enough the phone would do a very small vibration in the way of <a class="zem_slink" href="http://en.wikipedia.org/wiki/Haptic_technology" title="Haptic technology" rel="wikipedia">haptic feedback</a>. This would be good if it weren&#8217;t for the fact that it does it <strong>every</strong> time, and not only the times when your touch actually triggers an action (opening a menu, etc) &#8211; this is becoming more annoying than useful.</p>
<p>Because of the devices HD screen I found it quite hard to be exact with my touches (my thumbs must be almost 200 pixels wide on that screen!) though the interface deals with this well by using large touch areas. After failing at playing Marbles (a pre-installed game with small touch areas) for a minute or so I quickly learned where the device thought my presses were and the device became even easier to use. (Sure this would have been much easier with a stylus but I hadn&#8217;t discovered that yet!)</p>
<p>The web browser is a pleasure to use, though it appears to support in page Flash which I personally hate &#8211; especially on a small screen mobile device. I went to YouTube to see how it handles and &#8220;very well&#8221; was the answer. The device supports the double tap to zoom in to a region of text paradigm of Safari on the iPhone though it obviously lacks the multi-touch pinch and zoom. </p>
<p><a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/IMG_0231-2.JPG"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/IMG_0231-2-300x148.jpg" alt="N900 vs G1" title="N900 vs G1" width="300" height="148" class="alignleft size-medium wp-image-320" /></a></p>
<p>Pressing play on a YouTube video, I wished to turn the volume up and so I pressed the volume rocker on the outside of the phone. This surprisingly zoomed the web page (very smoothly!) but not the volume &#8211; a useful feature but definitely not what I had expected. I attempted to change the volume using the YouTube Flash control but could not drag the slider up as my fingers were too fat and dragging scrolled the page. (I hadn&#8217;t discovered the stylus at this time but have since attempted with they stylus with the same result.) To change the volume I had to click the web page, click the &#8220;toggle fullscreen&#8221; button at the bottom right, the status icons at the top and then drag the volume slider. Not too hard, but certainly more effort than just using the volume rocker &#8211; the video would play on a good few seconds more before you can change the volume and get back to it. Perhaps there&#8217;s a better way of doing it, but this is a &#8220;first impressions&#8221; post so I feel I should stick to first impressions!</p>
<p>One very cool feature of the N900 is how blazingly fast the screen lock/unlock is. There&#8217;s a sprung switch on the right side of the phone which when you flick it will lock or unlock the screen seemingly instantly (no slider here!). If you prefer the iPhone style slider then you can press the power button at the top of the phone and use the slider there, though I much prefer the flick button on the side.</p>
<p><a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/DSCF4238.JPG"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/DSCF4238-300x156.jpg" alt="N900 lock screen switch (left) and kickstand." title="N900 lock screen switch (left) and kickstand." width="300" height="156" class="alignleft size-medium wp-image-328" /></a></p>
<p>I like the stand on the back of the phone &#8211; this would be immensely useful when you&#8217;re trying to watch a film on the train on the way back from London (rather than constructing a stand with your backpack, wallet and other accessories like I do for my iPhone&#8230;). The stand is fairly sturdy and definitely supports the phone well, though it does rock a bit when you use the stylus at the top right of the screen (not really the stands intention to be fair!).</p>
<p>I know virtually nothing about photography, but to me the camera seems to be a decent quality 5MP phone camera with a fairly decent flash. Coming from a 3MP iPhone with no flash the difference is astounding. The N900&#8217;s sheer performance is very visible here &#8211; as you move the phone around you can clearly see the surroundings &#8211; there is no massive blurring like when you wobble the iPhone&#8217;s camera. The photos themselves come out quite well, though there is still minor blurring due to handshake &#8211; but no where near the magnitude of the blurring on the iPhone. I bet a &#8220;bar code scanner&#8221; application on the N900 would be far faster and more accurate than any I have used on the iPhone or Android!</p>
<p><a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/screenshot09.png"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/screenshot09.png" alt="N900-YouTube Windowed" title="N900-YouTube Windowed" width="800" height="480" class="aligncenter size-full wp-image-308" /></a></p>
<p>Connecting the device to my <a class="zem_slink" href="http://en.wikipedia.org/wiki/Wi-Fi" title="Wi-Fi" rel="wikipedia">WiFi</a> network was painless and intuitive. The major widgets (menu button [top left], fullscreen button [bottom right], close button [top right], status tray [top, right of menu button]) are well laid out and application switching (and closing [<a class="zem_slink" href="http://www.symbian.com" title="Symbian" rel="homepage">Symbian</a>: I'm talking to you]!) is simple and intuitive. </p>
<p style="text-align:left;"><a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/screenshot04.png"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/screenshot04-300x180.png" alt="N900 - Home Screen" title="N900 - Home Screen" width="300" height="180" class="alignleft size-medium wp-image-313" /></a> <a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/screenshot05.png"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/screenshot05-300x180.png" alt="N900 - Running Applications" title="N900 - Running Applications" width="300" height="180" class="alignleft size-medium wp-image-314" /></a> <a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/screenshot06.png"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/screenshot06-300x180.png" alt="N900 - Applications Home" title="N900 - Applications Home" width="300" height="180" class="alignleft size-medium wp-image-315" /></a> <a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/screenshot07.png"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/screenshot07-300x180.png" alt="N900 - Applications More" title="N900 - Applications More" width="300" height="180" class="alignleft size-medium wp-image-316" /></a></p>
<p>Opening applications could do with some work &#8211; the menu first opens and shows you 15 icons (standard icons like Contacts, Phone, Web, Email, Conversations), with a More button at the bottom right. Pressing More is how you get to your other apps &#8211; games, utilities, etc. Unfortunately these apps appear ordered by the time they were installed and not separated into folders, and there is no obviously intuitive way to organise them. In fact I have yet to find out how to organise them through exploring the device &#8211; I will search the internet later.</p>
<p><a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/DSCF4216.JPG"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/DSCF4216-300x198.jpg" alt="N900 (top left), G1 (top right), iPhone 3GS (bottom)" title="N900 (top left), G1 (top right), iPhone 3GS (bottom)" width="300" height="198" class="alignleft size-medium wp-image-325" /></a></p>
<p>That&#8217;s the end of my first impressions&#8230; When I discovered the X Terminal application I got immediately a lot more excited as I am by nature a hacker. Read on&#8230;</p>
<p><strong><em>This post is part 2 of a three part series. You may also be interested in:<br />
<a href="http://www.benjiegillam.com/2009/12/n900-the-tale-of-the-indestructible-box/">Part 1: N900: the tale of the indestructible box</a><br />
Part 3: N900: a phone for hackers? (coming soon&#8230;)</em></strong></p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/1cddb918-dbf7-405a-b4b1-d2de7e9854f4/" title="Reblog this post [with Zemanta]"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=1cddb918-dbf7-405a-b4b1-d2de7e9854f4" alt="Reblog this post [with Zemanta]" style="border:none;float:right"></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.benjiegillam.com/2009/12/n900-first-impressions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>N900: the tale of the indestructible box</title>
		<link>http://www.benjiegillam.com/2009/12/n900-the-tale-of-the-indestructible-box/</link>
		<comments>http://www.benjiegillam.com/2009/12/n900-the-tale-of-the-indestructible-box/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 08:51:03 +0000</pubDate>
		<dc:creator>Benjie</dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[box]]></category>
		<category><![CDATA[hackerbox]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[indestructible]]></category>
		<category><![CDATA[n900]]></category>
		<category><![CDATA[nokia]]></category>
		<category><![CDATA[surprise]]></category>

		<guid isPermaLink="false">http://www.benjiegillam.com/?p=251</guid>
		<description><![CDATA[This post is part 1 of a 3 part series. You may also be interested in:
Part 2: N900: first impressions
Part 3: N900: a phone for hackers? (coming soon&#8230;)
A week ago I was contacted by Lydia of WOMWorld.com/nokia who asked me if I would be interested in receiving an indestructible box. I was told that she [...]]]></description>
			<content:encoded><![CDATA[<p><strong><em>This post is part 1 of a 3 part series. You may also be interested in:<br />
<a href="http://www.benjiegillam.com/2009/12/n900-first-impressions/">Part 2: N900: first impressions</a><br />
Part 3: N900: a phone for hackers? (coming soon&#8230;)</em></strong></p>
<p>A week ago I was contacted by Lydia of <a title="WOMWorld/Nokia" href="http://www.womworld.com/nokia/" target="_blank">WOMWorld.com/nokia</a> who asked me if I would be interested in receiving an indestructible box. I was told that she found me via <a title="Benjie Gillam on Twitter" href="http://twitter.com/BenjieGillam" target="_blank">my twitter profile</a> and felt it would appeal to my passions. After confirming the email was not spam I replied, intrigued, &#8220;yes please&#8221; and sent her my address.</p>
<div style="float:left;margin-right:10px;"><a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/NokiaPackageArrives.jpg"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/NokiaPackageArrives-150x150.jpg" alt="Package Arrives" title="Package Arrives" width="150" height="150" class="alignleft size-thumbnail wp-image-266"></a></div>
<p>Yesterday it arrived. I opened the door to a delivery man who offered me a large cardboard box. Jof had suggested to me that it would likely be an N900 (which I had heard a little about but had not had time to look into) so I was expecting a small package. Surprised I was when the box the man handed me was so large and heavy &#8211; 35&#215;35x35cm and 7.5kg!</p>
<div style="float:right;margin-left:10px;"><a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/NokiaBoxHybrid.jpg"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/NokiaBoxHybrid-150x150.jpg" alt="Nokia Box" title="Nokia Box" width="150" height="150" class="alignright size-thumbnail wp-image-270"></a></div>
<p>I took it indoors and opened it, to find a large package, cold to the touch, wrapped up in brown parcel paper and surrounded by polystyrene balls.&nbsp;Unwrapping this (and making a hell of a mess with the styrofoam balls which attempted to mirror the snow outside onto my living room floor) unveiled a 25&#215;25x25cm black shiny box with a <a class="zem_slink" href="http://nokia.com" title="Nokia Siemens" rel="homepage">Nokia</a> logo on top, a hinge and a small <a href="http://en.wikipedia.org/wiki/Universal_Serial_Bus#Connector_types" target="_blank">USB mini-B socket</a> barely visible on one side. It was obvious that the top would open&#8230; but how?</p>
<p>I wanted to attempt to hack it right away, but two things stopped me: firstly, I should be working; and secondly the box was wet with condensation from the sudden contrast with the cold outside. I went back to work.</p>
<p>A hour and a half later I got temporarily stumped with a programming problem and decided to attempt to hack the box.</p>
<p>My first step was to see what happened when I plugged it in to the USB. I booted into <a class="zem_slink" href="http://www.ubuntu.com/" title="Ubuntu (operating system)" rel="homepage">Ubuntu</a> 9.10, ran <tt>dmesg -c</tt> to clear all the kernel messages, plugged it in, waited a few seconds, and ran <tt>dmesg</tt> again to see just the new logs:</p>
<pre style="color:green;font-weight:bold;">[  314.544034] usb 6-2: new full speed USB device using uhci_hcd and address 2
[  314.747104] usb 6-2: configuration #1 chosen from 1 choice
[  314.811722] usbcore: registered new interface driver usbserial
[  314.811734] USB Serial support registered for generic
[  314.811764] usbcore: registered new interface driver usbserial_generic
[  314.811766] usbserial: USB Serial Driver core
[  314.823161] USB Serial support registered for FTDI USB Serial Device
[  314.823263] ftdi_sio 6-2:1.0: FTDI USB Serial Device converter detected
[  314.823283] usb 6-2: Detected FT232RL
[  314.823285] usb 6-2: Number of endpoints 2
[  314.823287] usb 6-2: Endpoint 1 MaxPacketSize 64
[  314.823289] usb 6-2: Endpoint 2 MaxPacketSize 64
[  314.823291] usb 6-2: Setting MaxPacketSize 64
[  314.825064] usb 6-2: FTDI USB Serial Device converter now attached to ttyUSB0
[  314.825077] usbcore: registered new interface driver ftdi_sio
[  314.825079] ftdi_sio: v1.5.0:USB FTDI Serial Converters Driver
</pre>
<p>I spotted the <tt>/dev/ttyUSB0</tt> and instantly thought &#8220;<tt>minicom</tt>.&#8221; It took me a while to refamiliarise myself with the program and get it to connect, but soon I had fiddled with the speed settings (reduced it to just 9600baud from 115200) and was greeted the following output on my screen:</p>
<pre style="color:green;font-weight:bold;">  _   _  ___  _  _____    _
 | \ | |/ _ \| |/ /_ _|  / \
 |  \| | | | | ' / | |  / _ \
 | |\  | |_| | . \ | | / ___ \
 |_| \_|\___/|_|\_\___/_/   \_\
 *******************************
    W3lc0m3 t0 n0k14 h4x0rb0x!
 *******************************                                               

 ? - displays help dialog                                                      

$-nokia h4x0rb0x-&gt;
</pre>
<p>Unfortunately I could not type into minicom. I experimented with the speed and parity settings some more (as they had helped before) but no use. Finally I disabled hardware <a class="zem_slink" href="http://en.wikipedia.org/wiki/Control_flow" title="Control flow" rel="wikipedia">flow control</a> and voilà I could type. Then it was simply a case of typing &#8220;?&#8221; to find out what commands were available:</p>
<pre style="color:green;font-weight:bold;">$-nokia h4x0rb0x-&gt; ?
Available commands:                                                            

 ? - prints this help dialog                                                    

 connecting &lt;argument&gt; - opens box                                              

$-nokia h4x0rb0x-&gt;
</argument></pre>
<p>And guessing what the argument to the nokia connecting command was&#8230;</p>
<pre style="color:green;font-weight:bold;">$-nokia h4x0rb0x-&gt; connecting people                                            

Initiation complete.                                                            

Start Connecting.                                                               

$-nokia h4x0rb0x-&gt;
</pre>
<div style="float:left;margin-right:10px"><a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/DSCF4070.JPG"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/DSCF4070-150x150.jpg" alt="The Box Opens" title="The Box Opens" width="150" height="150" class="alignleft size-thumbnail wp-image-273"></a></div>
<p>Hardly a challenge! A nice clichéd progress bar appeared for a few seconds and then *click* the lid popped open a little. I opened it fully and was pleased to see that they had even included <a class="zem_slink" href="http://en.wikipedia.org/wiki/Dry_ice" title="Dry ice" rel="wikipedia">dry ice</a> to maximise theatrics, with the N900 packed safely waiting to be admired.</p>
<div style="float:right;margin-left:10px"><a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/NokiaWinnings.jpg"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/NokiaWinnings-150x150.jpg" alt="Nokia Winnings" title="Nokia Winnings" width="150" height="150" class="alignright size-thumbnail wp-image-274"></a></div>
<p>They really put a lot of thought into this! I delved deeper and here are all of my winnings:</p>
<p>That&#8217;s: an N900 with accessories plus a butane soldering iron, sports band, cake, and a little fox figurine. </p>
<p style="clear:both;">The box itself was powered by a Roboduino Nano (which I intend to repurpose later&#8230; not sure what as yet) hooked up to a solenoid:</p>
<div style="text-align:center;"><a href="http://www.benjiegillam.com/wp-content/uploads/2009/12/20091219_001.jpg"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/12/20091219_001-300x168.jpg" alt="Internals of the indestructible box" title="Internals of the indestructible box" width="300" height="168" class="aligncenter size-medium wp-image-276"></a></div>
<p><strong>UPDATE:</strong> Techcrunch have a <a href="http://eu.techcrunch.com/2009/12/22/insane-video-of-nokia-n900-unboxing-requires-you-to-hack-into-it/trackback/">video of the opening</a> &#8211; check it out!</p>
<p><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/SvKL7To6VbM&#038;hl=en_GB&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/SvKL7To6VbM&#038;hl=en_GB&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></p>
<p><strong><em>Continue reading:<br />
<a href="http://www.benjiegillam.com/2009/12/n900-first-impressions/">Part 2: N900: first impressions</a><br />
Part 3: N900: a phone for hackers? (coming soon&#8230;)</em></strong></p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/a1ddef28-4180-4a08-bc41-36db7671a790/" title="Reblog this post [with Zemanta]"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=a1ddef28-4180-4a08-bc41-36db7671a790" alt="Reblog this post [with Zemanta]" style="border:none;float:right"></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.benjiegillam.com/2009/12/n900-the-tale-of-the-indestructible-box/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>4iP Funding For GymFu</title>
		<link>http://www.benjiegillam.com/2009/12/4ip-funding-for-gymfu/</link>
		<comments>http://www.benjiegillam.com/2009/12/4ip-funding-for-gymfu/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 09:55:33 +0000</pubDate>
		<dc:creator>Benjie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.benjiegillam.com/?p=246</guid>
		<description><![CDATA[
GymFu (that&#8217;s Jof Arnold, Jem Gillam and myself) has received just shy of £100,000 funding from 4iP (an angel/investment arm of Channel 4) to work on a new project improving the health of the nation in bitesize chunks. This is obviously very exciting for us all, but I&#8217;m afraid we can&#8217;t tell you any more [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gymfu.com/"><img class="alignright" title="GymFu Logo" src="http://www.gymfu.com/press/GymFu/gymfu-logo-small.jpg" alt="" width="160" height="61" style="padding-left:6px;" /></a></p>
<p><a class="zem_slink" title="GymFu" rel="homepage" href="http://www.GymFu.com">GymFu</a> (that&#8217;s <a title="Jof Arnold, GymFu Co-Founder" href="http://www.jofarnold.com/" target="_blank">Jof Arnold</a>, <a title="Jem Gillam, GymFu Employee" href="http://jem.jemjie.com" target="_blank">Jem Gillam</a> and myself) has received just shy of £100,000 funding from <a href="http://www.4ip.org.uk/" target="_blank">4iP</a> (an angel/investment arm of Channel 4) to work on a new project improving the health of the nation in bitesize chunks. This is obviously very exciting for us all, but I&#8217;m afraid we can&#8217;t tell you any more until details are firmed up, though I can tell you that you should see output from this project by the middle of next year. Wish us luck!</p>
<p>Why not read <a href="http://www.4ip.org.uk/blog/post/4ip_invests_in_gymfu/" target="_blank">4iP&#8217;s press release</a> and <a href="http://eu.techcrunch.com/2009/12/01/4ip-invests-in-iphone-fitness-app-gymfu-and-a-new-service-to-help-parents-choose-a-school/" target="_blank">TechCrunch&#8217;s take</a> on the funding?</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.benjiegillam.com/2009/12/4ip-funding-for-gymfu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MythPyWii Power Update (v17)</title>
		<link>http://www.benjiegillam.com/2009/10/mythpywii-power-update-v17/</link>
		<comments>http://www.benjiegillam.com/2009/10/mythpywii-power-update-v17/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 17:37:58 +0000</pubDate>
		<dc:creator>Benjie</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MythPyWii]]></category>
		<category><![CDATA[MythTV]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Open source]]></category>

		<guid isPermaLink="false">http://www.benjiegillam.com/?p=242</guid>
		<description><![CDATA[



Image via Wikipedia



Thanks to Matthew Zimmerman for sending me his modified version of MythPyWii, it now has power-saving &#8211; after 35 minutes of inactivity the Wiimote turns off. You can download the latest version, as always, here; or you can get this specific version (v17) here.
I love open source!

]]></description>
			<content:encoded><![CDATA[<div class="zemanta-img" style="margin: 1em; display: block;">
<div>
<dl class="wp-caption alignright" style="width: 282px;">
<dt class="wp-caption-dt"><a href="http://commons.wikipedia.org/wiki/Image:Myth_tv_logo.png"><img title="Myth tv logo" src="http://upload.wikimedia.org/wikipedia/commons/6/6a/Myth_tv_logo.png" alt="Myth tv logo" width="272" height="91" /></a></dt>
<dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;">Image via <a href="http://commons.wikipedia.org/wiki/Image:Myth_tv_logo.png">Wikipedia</a></dd>
</dl>
</div>
</div>
<p>Thanks to Matthew Zimmerman for sending me his modified version of MythPyWii, it now has power-saving &#8211; after 35 minutes of inactivity the Wiimote turns off. You can download the latest version, as always, <a title="Latest MythPyWii version" href="http://www.benjiegillam.com/code/myth_py_wii.py" target="_blank">here</a>; or you can get this specific version (v17) <a title="MythPyWii revision 17" href="http://www.benjiegillam.com/code/myth_py_wii.r17.py" target="_blank">here</a>.</p>
<p>I love open source!</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/422a939e-dfa7-48f3-9059-6e69acd0420a/"><img class="zemanta-pixie-img" style="border: medium none ; float: right;" src="http://img.zemanta.com/reblog_c.png?x-id=422a939e-dfa7-48f3-9059-6e69acd0420a" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.benjiegillam.com/2009/10/mythpywii-power-update-v17/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Arduino Pin Speed (Multiplexing)</title>
		<link>http://www.benjiegillam.com/2009/09/arduino-pin-speed-multiplexing/</link>
		<comments>http://www.benjiegillam.com/2009/09/arduino-pin-speed-multiplexing/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 21:13:57 +0000</pubDate>
		<dc:creator>Benjie</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Binary numeral system]]></category>
		<category><![CDATA[Clock signal]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[Source code]]></category>

		<guid isPermaLink="false">http://www.benjiegillam.com/?p=224</guid>
		<description><![CDATA[I&#8217;m working on a new project, I&#8217;ve got a 8&#215;8 dual colour dot matrix display (£2.50 delivered from Earthshine Design) and I want to power it from the Arduino. One way of making a chip like that (which has 2&#215;8x8 = 128 LEDs) would be to have a common ground and an additional 128 pins [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.earthshinedesign.co.uk/index.php?route=product/product&amp;path=38_43&amp;product_id=82" target="_blank"><img class="alignright" title="8x8 dual colour dot matrix display" src="http://www.earthshinedesign.co.uk/image/cache/1425313_75-250x250.jpg" alt="" width="250" height="250" /></a>I&#8217;m working on a new project, I&#8217;ve got a <a title="8x8 dual colour dot matrix display" href="http://www.earthshinedesign.co.uk/index.php?route=product/product&amp;path=38_43&amp;product_id=82" target="_blank">8&#215;8 dual colour dot matrix display</a> (£2.50 delivered from Earthshine Design) and I want to power it from the <a class="zem_slink" title="Arduino" rel="homepage" href="http://www.arduino.cc" target="_blank">Arduino</a>. One way of making a chip like that (which has 2&#215;8x8 = 128 <a class="zem_slink" title="Light-emitting diode" rel="wikipedia" href="http://en.wikipedia.org/wiki/Light-emitting_diode" target="_blank">LEDs</a>) would be to have a common ground and an additional 128 pins &#8211; one for each LED. This, I think you&#8217;d agree, would be a nightmare, so instead they&#8217;ve basically gone for an 8&#215;16 grid for a total of 24 pins. This raises two main problems:</p>
<ol>
<li>You can&#8217;t turn 2 arbitrary LEDs on at the same time unless they are on the same row/column. (Doing so would actually draw a square of LEDs.)</li>
<li>My Arduino doesn&#8217;t have enough digital input/output pins</li>
</ol>
<p>Point 1 is easily solved &#8211; we simply update just one row at a time, letting <a href="http://en.wikipedia.org/wiki/Persistence_of_vision" target="_blank">Persistance Of Vision</a> (POV) do the hard work for us. Point 2 is the subject of this post &#8211; multiplexing, combining multiple individual signals into just one signal. I will not be using this dot matrix display in this post, instead I will simply be powering normal LEDs. I wanted to find out if the Arduino is fast enough to multiplex the data through just a few pins in order to power this display. The answer (one of my favourite answers!) is: &#8220;Yes, but not without some hacking.&#8221; Read on&#8230;</p>
<p><span id="more-224"></span></p>
<h2>The Hardware</h2>
<p>In order to get a balance between the number of pins we use for this and the speed of the output I&#8217;ve decided to use 3 data pins, each controlling 8 bits, for a total of 24 bits (the same as the number of pins on the LED component &#8211; no coincidence!) The way that I have implemented it, we also need 2 pins for clocks (one fast, one slow) &#8211; read on. The clock pins will be common to all 3 data pins, so for the rest of this post I will only detail one data pin (8 bits).</p>
<p><a href="http://www.benjiegillam.com/wp-content/uploads/2009/09/arduino-project2.JPG"><img src="http://www.benjiegillam.com/wp-content/uploads/2009/09/arduino-project2-300x155.jpg" alt="The Hardware" title="The Hardware" width="300" height="155" class="aligncenter size-medium wp-image-235" /></a></p>
<p>(Sorry about the messiness. Click for a larger picture. There is a Roboduino (Arduino compatible) board on the left, the LEDs and resistors should be fairly obvious from the photo, then there are 3 chips. From left to right they are the Darlington array, the SIPO shift register and the flip flop array (see below for all of these)).</p>
<h3>Fast clock &#8211; Shift Register</h3>
<p>We want to send the data through one pin (data line 1, DL1) to an external Serial-In Parallel-Out (SIPO) chip, also known as a <a class="zem_slink" title="Shift register" rel="wikipedia" href="http://en.wikipedia.org/wiki/Shift_register" target="_blank">shift-register</a> (I&#8217;m using a <a href="http://www.google.co.uk/search?q=M74HC164B1" target="_blank">M74HC164B1</a> octal shift register). This does exactly what it says &#8211; it takes a serial (single) input and converts it to parallel (multiple) outputs. However the chip just receives some high signals and some low signals &#8211; how should it know how many digital 1s there are in a second&#8217;s worth of high signal? This is where the fast clock (FC) comes in. FC just goes from low to high and back again for every bit of data we send through the data lines, and when it changes from low to high the SIPO chip &#8220;reads&#8221; the value of DL1 and outputs it on it&#8217;s first output pin (Pin1). The next time the SIPO chip reads from DL1, it &#8220;shifts&#8221; the value from Pin1 to the second pin (Pin2), and again stores the value of DL1 (on or off) into Pin1. This continues indefinitely, shifting the data along a pin at a time, filling up all 8 of the SIPO chip&#8217;s output pins (and forever overwriting previous data). Here&#8217;s a diagram from the datasheet:</p>
<p><img src="http://www.benjiegillam.com/wp-content/uploads/2009/09/screenshot736.png" alt="Shift Register" title="Shift Register" width="576" height="470" class="aligncenter size-full wp-image-234" /></p>
<p>Time goes from right to left (the left shows an earlier time than the right). The data is the second signal (the third can just remain high always) and the 4th signal is the clock pulse. Signals 5-12 show the state of the output pins at each point in time.</p>
<h3>Slow Clock &#8211; Flip Flop</h3>
<p>We don&#8217;t want to display this shifting data though, so we use a &#8220;<a class="zem_slink" title="Flip-flop (electronics)" rel="wikipedia" href="http://en.wikipedia.org/wiki/Flip-flop_%28electronics%29" target="_blank">flip-flop</a>&#8221; (FF) to store the values. A flip flop can be thought of as a Serial-In Serial-Out (SISO) chip in that it takes it&#8217;s input and uses that as the output. What&#8217;s so special about it then, I hear you ask, isn&#8217;t it just a bit of wire? The &#8220;special&#8221; thing about flip flops is that they &#8220;store&#8221; this value &#8211; recording it when it receives a clock pulse, like the SIPO chip above. We&#8217;re going to use the slow clock (SC) for this purpose, because we only want to store the values once all 8 bits have been output from the SIPO chip. (The SC is triggered once every 8 FC pulses.) Doing so we wait for the SIPO chip to correctly represent the 8 bits it has been sent, and then we store these values whilst the next 8 bits are loaded. I&#8217;m using a <a href="http://www.google.co.uk/search?q=SN74HC273N" target="_blank">SN74HC273N</a> octal flip flop chip which has 8 individual flip flops in it.</p>
<h3>Boosting &#8211; Darlington array</h3>
<p>Unfortunately the flip flop chip does not supply much current &#8211; not enough to power an LED &#8211; so we need to use transistors to boost the current. I&#8217;ve used a Darlington array to boost the current in my circuit as I had one left over from a previous project (it is a <a href="http://www.google.co.uk/search?q=ULN2803A" target="_blank">ULN2803A</a>).</p>
<h3>Display</h3>
<p>I&#8217;ve displayed the output of just one of the data pins using 8 standard LEDs, each with a resistor that&#8217;s too big (didn&#8217;t have one the correct rating).</p>
<h2>The Software</h2>
<p>To test this, I decided to do some binary counting.</p>
<h3>Initial Software</h3>
<p>First I implemented my own solution, and when I turned of the debugging delays and optimized as much as I could it resulted in 2 of the LEDs (the ones signifying the most significant bits) visibly flashing, a sad result meaning that there would be visible flickering on the final display if I used this method, especially as I was outputting only 8 bits and not 24 (doing 24 would make it roughly half as fast due to the extra digitalWrite operations).</p>
<p><code class="source">
<span class="enscript-comment">// The pins I will be using:
</span><span class="enscript-type">int</span> dataPin = 10;
<span class="enscript-type">int</span> fastClockPin = 11;
<span class="enscript-type">int</span> slowClickPin = 12;
<span class="enscript-comment">// The data to display:
</span>byte count=0; 

<span class="enscript-type">void</span> <span class="enscript-function-name">setup</span>() {
  <span class="enscript-comment">// All the pins are output pins
</span>  pinMode(dataPin,OUTPUT);
  pinMode(fastClockPin, OUTPUT);
  pinMode(slowClockPin, OUTPUT);
  <span class="enscript-comment">// Reset all pins low
</span>  digitalWrite(dataPin, LOW);
  digitalWrite(fastClockPin, LOW);
  digitalWrite(slowClockPin, LOW);
}
<span class="enscript-comment">// This will pulse the fast clock pin
</span><span class="enscript-type">void</span> <span class="enscript-function-name">fastClock</span>() {
  digitalWrite(fastClockPin, HIGH);
  digitalWrite(fastClockPin, LOW);
}
<span class="enscript-comment">// This will pulse the slow clock pin
</span><span class="enscript-type">void</span> <span class="enscript-function-name">slowClock</span>() {
  digitalWrite(slowClockPin, HIGH);
  digitalWrite(slowClockPin, LOW);
}
<span class="enscript-type">void</span> <span class="enscript-function-name">loop</span>() {
  <span class="enscript-comment">// We don't want to edit count, so copy it.
</span>  byte v = count;
  <span class="enscript-type">int</span> i;
  <span class="enscript-comment">// There are 8 bits in a byte, do the following for each bit.
</span>  <span class="enscript-keyword">for</span> (i=0; i&lt;8; i++) {
    <span class="enscript-comment">// Set the data: if v modulo 2 is 1, send high, otherwise low. (v modulo 2 is the remainder when you divide v by 2)
</span>    digitalWrite(dataPin, v%2 == 1 ? HIGH : LOW);
    <span class="enscript-comment">// I've written the data, let the SIPO chip know
</span>    fastClock();
    <span class="enscript-comment">// Shift v 1 bit along, dropping the bit we just checked.
</span>    v = v &gt;&gt; 1;
  }
  <span class="enscript-comment">// All 8 bits have been output, tell the flip flops to store their current values:
</span>  slowClock();
  <span class="enscript-comment">// Increase the value of count by one
</span>  ++count;
}
</code>
</p>
<h3>Abstraction Principle</h3>
<p>Looking around at how to optimize this, I soon found that I could use a built in function shiftOut instead of my own method calling digitalWrite for every bit. I updated my code, changing 11 lines of code to just 1. This did speed it up (their <a class="zem_slink" title="Binary numeral system" rel="wikipedia" href="http://en.wikipedia.org/wiki/Binary_numeral_system" target="_blank">binary arithmetic</a> was faster than my method of the time) but not by enough &#8211; 1 LED still flashed &#8211; there would still be visible flicker. How annoying.</p>
<p><code class="source">
<span class="enscript-comment">// The pins I will be using:
</span><span class="enscript-type">int</span> dataPin = 10;
<span class="enscript-type">int</span> fastClockPin = 11;
<span class="enscript-type">int</span> slowClickPin = 12;
<span class="enscript-comment">// The data to display:
</span>byte count=0; 

<span class="enscript-type">void</span> <span class="enscript-function-name">setup</span>() {
  <span class="enscript-comment">// All the pins are output pins
</span>  pinMode(dataPin,OUTPUT);
  pinMode(fastClockPin, OUTPUT);
  pinMode(slowClockPin, OUTPUT);
  <span class="enscript-comment">// Reset all pins low
</span>  digitalWrite(dataPin, LOW);
  digitalWrite(fastClockPin, LOW);
  digitalWrite(slowClockPin, LOW);
}
<span class="enscript-comment">// REMOVED: fastClock(), because shiftOut() handles this for us.
</span>
<span class="enscript-comment">// This will pulse the slow clock pin
</span><span class="enscript-type">void</span> <span class="enscript-function-name">slowClock</span>() {
  digitalWrite(slowClockPin, HIGH);
  digitalWrite(slowClockPin, LOW);
}
<span class="enscript-type">void</span> <span class="enscript-function-name">loop</span>() {
  <span class="enscript-comment">// REMOVED: Most of the code here, shiftOut() does it all for us:
</span>  shiftOut(dataPin, fastClockPin, LSBFIRST, count);
  <span class="enscript-comment">// All 8 bits have been output, tell the flip flops to store their current values:
</span>  slowClock();
  <span class="enscript-comment">// Increase the value of count by one
</span>  ++count;
}
</code>
</p>
<h3>Digging Deeper</h3>
<p>I was a bit disappointed by this, as I knew from the last SoutHACKton meetup that on <a class="zem_slink" title="PICAXE" rel="wikipedia" href="http://en.wikipedia.org/wiki/PICAXE" target="_blank">PICAXE</a> boards you could set multiple pins at the same time. Setting just one pin at a time in Arduino seemed unnecessarily slow. I dug a bit deeper in the <a title="Arduino Extended Reference" href="http://arduino.cc/en/Reference/Extended" target="_blank">extended documentation</a>, and came across <a title="Arduino Port Manipulation" href="http://arduino.cc/en/Reference/PortManipulation" target="_blank">the Port Manipulation page</a>:</p>
<blockquote><p>You may need to be able to turn pins on and off very quickly, meaning within fractions of a microsecond. If you look at the source code in lib/targets/arduino/wiring.c, you will see that digitalRead() and digitalWrite() are each about a dozen or so lines of code, which get compiled into quite a few machine instructions. Each machine instruction requires one clock cycle at 16MHz, which can add up in time-sensitive applications. Direct port access can do the same job in a lot fewer <a class="zem_slink" title="Clock signal" rel="wikipedia" href="http://en.wikipedia.org/wiki/Clock_signal" target="_blank">clock cycles</a>.</p></blockquote>
<p>Huzzah! I can write multiple pins at once, and not only that, I can skip a lot of the clever code that the Arduino libraries come with as I&#8217;m happy making assumptions about my program&#8217;s operation. Excellent!</p>
<p>I had a look at the built in functions, and revised my binary arithmetic so that I could be as optimized as possible, and ran the code&#8230;</p>
<p><code class="source">
<span class="enscript-comment">// REMOVED: the pins (these are now implicit in the binary masks below rather than explicit as before)
</span><span class="enscript-comment">// The data to display:
</span>byte count=0;
<span class="enscript-comment">// Alternatively: unsigned int count = 0;
</span>
<span class="enscript-type">void</span> <span class="enscript-function-name">setup</span>() {
  <span class="enscript-comment">// The pins I am using are output pins: (12,11,10)
</span>  DDRB = B00011100;
  <span class="enscript-comment">// Reset all pins low:
</span>  PORTB = B00000000;
}
<span class="enscript-type">int</span> i;
<span class="enscript-type">void</span> <span class="enscript-function-name">loop</span>() {
  <span class="enscript-comment">// REMOVED: most previous code
</span>  <span class="enscript-comment">// Loop through the bits of count. (if count is an unsigned int, then use this instead:) for (i=0; i &lt; 16; i++) {
</span>  <span class="enscript-keyword">for</span> (i=0; i &lt; 8; i++) {
    <span class="enscript-comment">// Turn all clocks off, and set the data pin
</span>    PORTB = B00000000 | (!!(count &amp; (1 &lt;&lt; i)) &lt;&lt; 2);
    <span class="enscript-comment">// Leave the data pin as it is, turn on the fast clock pin, and if we're on the last bit also turn on the slow clock pin
</span>    PORTB |= B00001000 | (!!(i == 7) &lt;&lt; 4);
    <span class="enscript-comment">// If we're working with an unsigned int, then change the 7 above to a 15.
</span>  }
  <span class="enscript-comment">// Increase the value of count by one
</span>  ++count;
}
</code>
</p>
<p>... All the LEDs appeared on all the time... Either it's working perfectly or something's very wrong. Fortunately by adding a delay into the loop, I could see it was the former, and I celebrated! But just how much faster is it? I couldn't use the Arduinos internal timing, as timing it would cause it to use more processing power and thus slow down... Instead I decided to display the 8 most significant bits of a 16bit number, and see how many of those flickered. All except one flickered (not unexpected) but this meant it was significantly faster than before.</p>
<p>I timed the slowest flashing LED - one full cycle (on to off and back on again) of this 1st bit took an average of 2.2 seconds. This meant that one full cycle of the 9th bit (the one we're bothered about - the slowest of the initial 8 bits) was taking 2.2/256 = 0.0086s, or, in other words, it was running at 116Hz - good enough to not be noticeable by human perception (standard TV is 25-30 Hz). (This also means that the fastest bit is being pulsed at around 15,000Hz.) This is just 8bits, mind, not 24. Adding in the extra bits would not be too taxing on the system though - purely mathematics - as we can set all the pins in the same step. I would expect it to run all 24 bits at around 40-60Hz. </p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/20a08457-e3af-41d3-a25c-0a4b3401d280/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_c.png?x-id=20a08457-e3af-41d3-a25c-0a4b3401d280" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.benjiegillam.com/2009/09/arduino-pin-speed-multiplexing/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>AWESOME! Zombie Brain Cupcake!</title>
		<link>http://www.benjiegillam.com/2009/08/awesome-zombie-brain-cupcake/</link>
		<comments>http://www.benjiegillam.com/2009/08/awesome-zombie-brain-cupcake/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 16:18:33 +0000</pubDate>
		<dc:creator>Benjie</dc:creator>
				<category><![CDATA[Personal]]></category>
		<category><![CDATA[brain]]></category>
		<category><![CDATA[cupcake]]></category>
		<category><![CDATA[zombie]]></category>

		<guid isPermaLink="false">http://www.benjiegillam.com/?p=222</guid>
		<description><![CDATA[
That is all.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://zombiesvaderandthings.tumblr.com/post/156380020/zombie-brain-cupcake"><img class="aligncenter" title="Zombie Brain Cupcake" src="http://1.media.tumblr.com/wXXB9EAdrqqxa9kjvZ0dIyPno1_250.jpg" alt="" width="250" height="333" /></a></p>
<p>That is all.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.benjiegillam.com/2009/08/awesome-zombie-brain-cupcake/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OSStatus iPhone SDK Meanings</title>
		<link>http://www.benjiegillam.com/2009/07/osstatus-iphone-sdk-meanings/</link>
		<comments>http://www.benjiegillam.com/2009/07/osstatus-iphone-sdk-meanings/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 12:57:56 +0000</pubDate>
		<dc:creator>Benjie</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.benjiegillam.com/?p=218</guid>
		<description><![CDATA[



Image via CrunchBase



If you&#8217;ve got a line like this:
LOGGING_FACILITY1( sanityCheck == noErr, @"Problem adding private key, OSStatus == %d.", sanityCheck );
But you don&#8217;t know what the OSStatus value means, and you&#8217;re devving on iPhone, here&#8217;s the answers:

enum
{
errSecSuccess                = 0,  [...]]]></description>
			<content:encoded><![CDATA[<div class="zemanta-img" style="margin: 1em; display: block;">
<div>
<dl class="wp-caption alignright" style="width: 260px;">
<dt class="wp-caption-dt"><a href="http://www.crunchbase.com/product/iphone"><img title="Image representing iPhone as depicted in Crunc..." src="http://www.benjiegillam.com/wp-content/uploads/2009/12/19797v1-max-250x250.jpg" alt="Image representing iPhone as depicted in Crunc..." width="250" height="195"></a></dt>
<dd class="wp-caption-dd zemanta-img-attribution" style="font-size: 0.8em;">Image via <a href="http://www.crunchbase.com">CrunchBase</a></dd>
</dl>
</div>
</div>
<p>If you&#8217;ve got a line like this:</p>
<blockquote><p>LOGGING_FACILITY1( sanityCheck == noErr, @"Problem adding private key, OSStatus == %d.", sanityCheck );</p></blockquote>
<p>But you don&#8217;t know what the OSStatus value means, and you&#8217;re devving on iPhone, here&#8217;s the answers:</p>
<blockquote><p><code class="source">
enum
{
errSecSuccess                = 0,       /* No error. */
errSecUnimplemented          = -4,      /* Function or operation not implemented. */
errSecParam                  = -50,     /* One or more parameters passed to a function where not valid. */
errSecAllocate               = -108,    /* Failed to allocate memory. */
errSecNotAvailable           = -25291,	/* No keychain is available. You may need to restart your computer. */
errSecDuplicateItem          = -25299,	/* The specified item already exists in the keychain. */
errSecItemNotFound           = -25300,	/* The specified item could not be found in the keychain. */
errSecInteractionNotAllowed  = -25308,	/* User interaction is not allowed. */
errSecDecode                 = -26275,  /* Unable to decode the provided data. */
};</code>
</p></blockquote>
<p>This was taken from <tt title="/Developer/Platform/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h">/Developer /Platform /iPhoneOS.platform /Developer /SDKs /iPhoneOS3.0.sdk /System /Library /Frameworks /Security.framework /Headers /SecBase.h</tt> [remove spaces] (so quite easy to find then&#8230; NOT!) because <tt>SecCopyErrorMessageString</tt> doesn&#8217;t work on iPhone OS.</p>
<p>I hope this helps you &#8211; if it does, let me know in the comments!</p>
<p>To help you find this in the search engines this might be triggered if you are using <tt>SecItemAdd</tt>, <tt>SecItemCopyMatching</tt> or any of the other keychain services in the iPhone SDK. You might be using Apple&#8217;s <tt>[SecKeyWrapper sharedWrapper]</tt> functions too&#8230; Anything security related really. Or private key, public key, asymmetric key, signing, blah blah blah.</p>
<div class="zemanta-pixie" style="margin-top:10px;height:15px"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/5e82cf26-f27f-4bfd-9eec-dbcb318e2e0e/" title="Reblog this post [with Zemanta]"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=5e82cf26-f27f-4bfd-9eec-dbcb318e2e0e" alt="Reblog this post [with Zemanta]" style="border:none;float:right"></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.benjiegillam.com/2009/07/osstatus-iphone-sdk-meanings/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iPhone SDK Upload Issues? Blame Apple&#8217;s &#8220;Compress This&#8221; Feature.</title>
		<link>http://www.benjiegillam.com/2009/06/iphone-sdk-upload-issues-blame-apples-compress-this-feature/</link>
		<comments>http://www.benjiegillam.com/2009/06/iphone-sdk-upload-issues-blame-apples-compress-this-feature/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 16:26:50 +0000</pubDate>
		<dc:creator>Benjie</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.benjiegillam.com/?p=214</guid>
		<description><![CDATA[If your app won&#8217;t upload but you&#8217;re sure you&#8217;ve compiled it and signed it right, the fault might not be yours. For me, it was the built in &#8220;Compress [Folder]&#8230;&#8221; option &#8211; the archive produced from this might be missing files. You&#8217;re likely to see such errors as:
&#8220;The binary you uploaded was invalid. The signature [...]]]></description>
			<content:encoded><![CDATA[<div class="wp-caption alignright" style="width: 170px"><a href="http://jasonjeffrey.files.wordpress.com/2007/09/apple-sucks.png"><img title="Apple Sucks" src="http://jasonjeffrey.files.wordpress.com/2007/09/apple-sucks.png" alt="Apple Sucks" width="160" height="154" /></a><p class="wp-caption-text">Apple Sucks</p></div>
<p>If your app won&#8217;t upload but you&#8217;re sure you&#8217;ve compiled it and signed it right, the fault might not be yours. For me, it was the built in &#8220;Compress [Folder]&#8230;&#8221; option &#8211; the archive produced from this might be missing files. You&#8217;re likely to see such errors as:</p>
<p>&#8220;The binary you uploaded was invalid. The signature was invalid, or it was not signed with an Apple submission certificate.&#8221;</p>
<p>&#8220;Icon specified in the info.plist not found under the top level app wrapper&#8221;</p>
<p>Seriously, Apple, what the f*ck? Thats 2 hours of my life lost because Apple couldn&#8217;t nail the basics: an archive utility. I&#8217;m so angry right now.</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Reblog this post [with Zemanta]" href="http://reblog.zemanta.com/zemified/374b9e2b-0b73-4742-a18f-37c05e7c688b/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_c.png?x-id=374b9e2b-0b73-4742-a18f-37c05e7c688b" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script src="http://static.zemanta.com/readside/loader.js" type="text/javascript"></script></span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.benjiegillam.com/2009/06/iphone-sdk-upload-issues-blame-apples-compress-this-feature/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
