<?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>Dual Elephants</title>
	<atom:link href="http://www.adebenham.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adebenham.com</link>
	<description>Always keep a spare for redundancy</description>
	<lastBuildDate>Mon, 21 May 2012 02:26:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>USB-Rubber Ducky scripts on Arduino/Leostick</title>
		<link>http://www.adebenham.com/2012/05/usb-rubber-ducky-scripts-on-arduinoleostick/</link>
		<comments>http://www.adebenham.com/2012/05/usb-rubber-ducky-scripts-on-arduinoleostick/#comments</comments>
		<pubDate>Mon, 21 May 2012 02:26:47 +0000</pubDate>
		<dc:creator>cjd</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[LeoStick]]></category>

		<guid isPermaLink="false">http://www.adebenham.com/?p=65</guid>
		<description><![CDATA[The other day I was at Jaycar and saw that they are now selling small USB sticks that are arduino compatible. It is called the LeoStick and is made by Freetronics down in Melbourne. Seeing that it could pretend to be a USB HID device (ie keyboard/mouse) I wondered if I could do the sort [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was at Jaycar and saw that they are now selling small USB sticks that are arduino compatible.<br />
It is called the <a title="LeoStick" href="http://www.freetronics.com/products/leostick" target="_blank">LeoStick</a> and is made by Freetronics down in Melbourne.<br />
Seeing that it could pretend to be a USB HID device (ie keyboard/mouse) I wondered if I could do the sort of thing that the <a title="Ducky Store" href="http://hakshop.myshopify.com/products/usb-rubber-ducky" target="_blank">USB Rubber Ducky</a> from Hak5 can do<br />
As it turns out the answer is YES <img src='http://www.adebenham.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Since it was possible I spent an hour or two writing a quick shell script which can convert ducky script payloads into a sketch suitable for uploading to the LeoStick (or any arduino that has USB-HID capability)   The end result is a small bash script which can be downloaded from <a title="Download script" href="http://www.adebenham.com/files/leo/compile_payload.sh" target="_blank">compile_payload.sh</a></p>
<p>Usage is fairly simple &#8211; you run the script with two options &#8211; the first being the payload file, and the second being the arduino script output.</p>
<p>ie: compile_payload lock_prank.txt lock_prank.ino</p>
<p>Various payloads can be found linked from the <a title="Ducky wiki" href="https://github.com/hak5darren/USB-Rubber-Ducky/wiki" target="_blank">USB-Rubber-Ducky wiki</a></p>
<p>As a bit of fun I changed the lock_prank payload to work on Gnome/Linux and it also plays the mission impossible theme once done <img src='http://www.adebenham.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
Grab it from <a title="lock_prank download" href="http://www.adebenham.com/files/leo/lock_prank.ino" target="_blank">lock_prank.ino</a></p>
<p>Also note that to get this working you need to edit the arduino libraries so that the sendReport function is marked as public.</p>
<p>To to this edit the USBAPI.h file which can be found in ${ARDUINO_DIR}/hardware/arduino/cores/arduino directory.<br />
This may be /usr/share/arduino/hardware/arduino/cores/arduino/USBAPI.h or similar<br />
If you installed the LeoStick board stuff from their website then it will be under your sketches directory as hardware/LeoStick/cores/arduino/USBAPI.h</p>
<p>Open that file and find</p>
<pre>private:
    KeyMap* _keyMap;
    void sendReport(KeyReport* keys);
    void setKeyMap(KeyMap* keyMap);
public:
    Keyboard_();
    virtual size_t write(uint8_t);</pre>
<p>Then change that to</p>
<pre>private:
    KeyMap* _keyMap;
    void setKeyMap(KeyMap* keyMap);
public:
    void sendReport(KeyReport* keys);
    Keyboard_();
    virtual size_t write(uint8_t);</pre>
<p>Then everything should work fine.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adebenham.com/2012/05/usb-rubber-ducky-scripts-on-arduinoleostick/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Freetronics DMD &#8211; Screen transitions</title>
		<link>http://www.adebenham.com/2012/04/dmd-screen-transitions/</link>
		<comments>http://www.adebenham.com/2012/04/dmd-screen-transitions/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 04:34:31 +0000</pubDate>
		<dc:creator>cjd</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.adebenham.com/?p=61</guid>
		<description><![CDATA[I was driving past one of those led advertising signs sitting on the side of the road the other day and thought to myself &#8216;I can do that&#8217; So I&#8217;ve hooked up 6 of the freetronics DMD modules (in a 2&#215;3 layout) and got down to coding up a way to do it. In the [...]]]></description>
			<content:encoded><![CDATA[<p>I was driving past one of those led advertising signs sitting on the side of the road the other day and thought to myself &#8216;I can do that&#8217;<br />
So I&#8217;ve hooked up 6 of the freetronics DMD modules (in a 2&#215;3 layout) and got down to coding up a way to do it.<br />
In the end I got it working by adding support for multiple buffers into my DMD library &#8211; <a href="https://github.com/cjd/DMD">github.com/cjd/DMD</a><br />
Since I have the ability to have multiple buffers I can now transition between buffers presentation-style.<br />
There are 8 transitions &#8211; wipe left/right/up/down, box in/out and cross in/out<br />
The following video demonstrates some of the transitions<br />
It is my sons first birthday in a few days so I thought it nice to create a moving sign for his party <img src='http://www.adebenham.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<iframe src="http://www.youtube.com/embed/s4Qjski-WMY?version=3&amp;wmode=transparent" width="560" height="340" title="YouTube video player" style="background-color:#000;display:block;margin-bottom:0;max-width:100%;" frameborder="0" allowfullscreen></iframe><p style="font-size:11px;margin-top:0;"><a href="http://www.youtube.com/watch?v=s4Qjski-WMY" target="_blank" title="Watch on YouTube">Watch this video on YouTube</a>.</p></p>
<p>For the hardware I mounted the displays on a wooden frame (hold on by hot-glue) and then routed power down each side and signal was daisy-chained from bottom-right (bottom-left in photo) to each display.<br />
<a href="http://www.adebenham.com/wp-content/uploads/2012/04/DMD_Display_layout.jpg"><img class="aligncenter size-large wp-image-62" title="DMD_Display_layout" src="http://www.adebenham.com/wp-content/uploads/2012/04/DMD_Display_layout-1024x768.jpg" alt="" width="600" height="400" /></a></p>
<p>Source code below:</p>
<pre>/*---------------------------------------------------------------
 Includes
 ----------------------------------------------------------------*/
#include &lt;SPI.h&gt;        //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include &lt;DMD.h&gt;        //
#include &lt;TimerOne.h&gt;   //
#include "Arial_black_16.h"
//Fire up the DMD library as dmd
DMD dmd(2,3,1);

long mDelay=30;
long timer=-1;
long oldtimer=-1;
int centreX=32;
int centreY=24;
int trans=0;
int i=0;

/*--------------------------------------------------------------------------------------
 Interrupt handler for Timer1 (TimerOne) driven DMD refresh scanning, this gets
 called at the period set in Timer1.initialize();
 --------------------------------------------------------------------------------------*/
void ScanDMD()
{
  dmd.scanDisplayBySPI();
}

/*--------------------------------------------------------------------------------------
 setup
 Called by the Arduino architecture before the main loop begins
 --------------------------------------------------------------------------------------*/
void setup(void)
{
  randomSeed(analogRead(0));
  //initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
  Timer1.initialize( 5000 );           //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
  Timer1.attachInterrupt( ScanDMD );   //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()
  //clear/init the DMD pixels held in RAM
  dmd.clearScreen( 0 );   //true is normal (all pixels off), false is negative (all pixels on)
  dmd.selectFont(Arial_Black_16);
  dmd.setupBuffer(3);
}

/*--------------------------------------------------------------------------------------
 loop
 Arduino architecture main loop
 --------------------------------------------------------------------------------------*/
void loop(void)
{
  lookaround();
  dmd.setBufferEdit(0);
  smile();
  dmd.setBufferDisplay(0);
  delay(1000);
  wink();
  delay(300);
  dmd.copyBuffer(2,0);
  dmd.setBufferEdit(0);
  dmd.setBufferDisplay(0);
  char stringa[]="Happy Birthday Lucas";

  dmd.drawMarquee(stringa,strlen(stringa),64,16,0xFF,0);
  while (!dmd.stepMarquee(-1,0)){delay(30);}

  dmd.setBufferEdit(1);
  dmd.clearScreen(0);
  dmd.drawString(8,0,"Happy",5,1,0);
  dmd.drawString(0,16,"Birthday",8,1,0);
  dmd.drawString(6,32,"Lucas!",6,1,0);

  dmd.copyBuffer(0,2);
  dmd.setBufferDisplay(2);  
  transition(0,1);
  delay(1000);
 
  dmd.setBufferEdit(0);
  smile();
  transition(1,0);
  delay(500);
 
  dmd.setBufferEdit(1);
  dmd.clearScreen(0);
  dmd.drawString(8,0,"Lucas",5,1,0);
  dmd.drawString(26,16,"is",2,1,0);
  dmd.drawString(16,32,"One!",4,1,0);
  dmd.copyBuffer(0,2);
  dmd.setBufferDisplay(2);

  transition(0,1);
  delay(1000);

  dmd.setBufferEdit(0);
  dmd.clearScreen(0);
  dmd.drawString(16,0,"Born",4,1,0);
  dmd.drawString(0,16,"28 April",8,1,0);
  dmd.drawString(16,32,"2011",4,1,0);

  transition(1,0);
  delay(1000);
 
  dmd.copyBuffer(1,0);
}

void transition(byte from, byte to)
{
  int i=0;
  trans=random(8);
  dmd.copyBuffer(from,2);
  while (dmd.transition(from,to,2,trans,i)) {i=i+1;}
}

void wink()
{
  dmd.setBufferEdit(0);
  dmd.clearScreen(0);
  dmd.setBufferDisplay(2);  
  head();
  eyes();
  mouth_smile();
  dmd.drawFilledBox(centreX-8,centreY-7,centreX-6,centreY-5,1);
  dmd.copyBuffer(0,2);

  int winkspeed=100;  

  dmd.setBufferEdit(1);
  for (int i=0;i&lt;=8;i++) {
    dmd.copyBuffer(0,1);
    if (i&lt;=4) {
      dmd.drawFilledBox(centreX+6,centreY-7,centreX+8,centreY-5,1);
    } else if(i==5) {
      dmd.drawFilledBox(centreX+6,centreY-6,centreX+8,centreY-5,1);
    }
    int width=0;
    if (i==0 || i==8) {
      dmd.drawLine(centreX+7-1,centreY-11+i,centreX+7+1,centreY-11+i,1);
    } else if(i&lt;=2 || i&gt;=6) {
      dmd.drawLine(centreX+7-3,centreY-11+i,centreX+7+3,centreY-11+i,1);
    } else {
      dmd.drawLine(centreX+7-4,centreY-11+i,centreX+7+4,centreY-11+i,1);
    }
    dmd.copyBuffer(1,2);
    delay(50);
  }
  for (int i=8;i&gt;=0;i--) {
    dmd.copyBuffer(0,1);
    if (i&lt;=4) {
      dmd.drawFilledBox(centreX+6,centreY-7,centreX+8,centreY-5,1);
    } else if(i==5) {
      dmd.drawFilledBox(centreX+6,centreY-6,centreX+8,centreY-5,1);
    }
    int width=0;
    if (i==0 || i==8) {
      dmd.drawLine(centreX+7-1,centreY-11+i,centreX+7+1,centreY-11+i,1);
    } else if(i&lt;=2 || i&gt;=6) {
      dmd.drawLine(centreX+7-3,centreY-11+i,centreX+7+3,centreY-11+i,1);
    } else {
      dmd.drawLine(centreX+7-4,centreY-11+i,centreX+7+4,centreY-11+i,1);
    }
    dmd.copyBuffer(1,2);
    delay(50);
  }
  dmd.setBufferEdit(2);
}

void lookaround()
{
  //head
  dmd.setBufferEdit(0);
  dmd.clearScreen(0);
  dmd.setBufferDisplay(2);  
  head();
  eyes();
  mouth_flat();
  dmd.copyBuffer(0,2);
 
  // eyelids
  dmd.drawLine(centreX-5,centreY-10,centreX-10,centreY-10,1);
  dmd.drawLine(centreX+5,centreY-10,centreX+10,centreY-10,1);

  dmd.setBufferEdit(1);
  for (int i=0;i&lt;=2;i++) {
    dmd.copyBuffer(0,1);
    dmd.drawFilledBox(centreX-8+i,centreY-7,centreX-6+i,centreY-5,1);
    dmd.drawFilledBox(centreX+6+i,centreY-7,centreX+8+i,centreY-5,1);
    dmd.copyBuffer(1,2);
    delay(100);
  }
  for (int i=2;i&gt;=-2;i--) {
    dmd.copyBuffer(0,1);
    dmd.drawFilledBox(centreX-8+i,centreY-7,centreX-6+i,centreY-5,1);
    dmd.drawFilledBox(centreX+6+i,centreY-7,centreX+8+i,centreY-5,1);
    dmd.copyBuffer(1,2);
    delay(100);
  }
  for (int i=-2;i&lt;=0;i++) {
    dmd.copyBuffer(0,1);
    dmd.drawFilledBox(centreX-8+i,centreY-7,centreX-6+i,centreY-5,1);
    dmd.drawFilledBox(centreX+6+i,centreY-7,centreX+8+i,centreY-5,1);
    dmd.copyBuffer(1,2);
    delay(100);
  }
  dmd.setBufferEdit(2);
}

void smile()
{
  dmd.clearScreen(0);
  head();
  eyes();
  mouth_smile();
  dmd.drawFilledBox(centreX-8,centreY-7,centreX-6,centreY-5,1);
  dmd.drawFilledBox(centreX+6,centreY-7,centreX+8,centreY-5,1);
}

void head()
{
  dmd.drawCircle(centreX,centreY,20,1);
}

void eyes()
{
  dmd.drawCircle(centreX-7,centreY-7,5,1);
  dmd.drawCircle(centreX+7,centreY-7,5,1);
}

void mouth_flat()
{
  dmd.drawLine(centreX-12,centreY+8,centreX+12,centreY+8,1);
}

void mouth_smile()
{
  dmd.drawLine(centreX-12,centreY+6,centreX-4,centreY+11,1);
  dmd.drawLine(centreX-4,centreY+11,centreX,centreY+11,1);
  dmd.drawLine(centreX+4,centreY+11,centreX,centreY+11,1);
  dmd.drawLine(centreX+12,centreY+6,centreX+4,centreY+11,1);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.adebenham.com/2012/04/dmd-screen-transitions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MTPFS 1.1 &#8211; Now supporting multiple storage areas</title>
		<link>http://www.adebenham.com/2012/02/mtpfs-1-1/</link>
		<comments>http://www.adebenham.com/2012/02/mtpfs-1-1/#comments</comments>
		<pubDate>Mon, 27 Feb 2012 01:22:56 +0000</pubDate>
		<dc:creator>cjd</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[MTPfs]]></category>

		<guid isPermaLink="false">http://www.adebenham.com/?p=59</guid>
		<description><![CDATA[I am now the proud owner of an Asus Transformer tablet (not the prime) and so wanted to update mtpfs to work better with it. The biggest change was to add support for multiple storage areas.  Now when you mount a MTP device which has internal storage and a MicroSD card (or similar) it shows [...]]]></description>
			<content:encoded><![CDATA[<p>I am now the proud owner of an Asus Transformer tablet (not the prime) and so wanted to update mtpfs to work better with it.</p>
<p>The biggest change was to add support for multiple storage areas.  Now when you mount a MTP device which has internal storage and a MicroSD card (or similar) it shows up as two separate directories which you can access.</p>
<p>The download is available from <a href="http://www.adebenham.com/mtpfs/" title="MTPfs">mtpfs page</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.adebenham.com/2012/02/mtpfs-1-1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Freetronics DMD &#8211; Games</title>
		<link>http://www.adebenham.com/2012/02/freetronics-dmd-games/</link>
		<comments>http://www.adebenham.com/2012/02/freetronics-dmd-games/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 05:09:07 +0000</pubDate>
		<dc:creator>cjd</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[DMD]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.adebenham.com/?p=56</guid>
		<description><![CDATA[I had a little while free and so ported a bunch of games I wrote for the Peggy2 to work with a pair of DMD&#8217;s In doing so the games now run at 32&#215;32 and are controlled by a Wii nunchuck. The games are snake, pong, breakout and race. The Arduino code is available at [...]]]></description>
			<content:encoded><![CDATA[<p>I had a little while free and so ported a bunch of games I wrote for the Peggy2 to work with a pair of DMD&#8217;s<br />
In doing so the games now run at 32&#215;32 and are controlled by a Wii nunchuck.<br />
The games are snake, pong, breakout and race.<br />
The Arduino code is available at <a href="/arduino/DMD_games.zip">DMD_games.zip</a><br />
The two screens are daisy-chained but as the cable connecting them is quite short the top one is upside-down.<br />
To get this working the modified <a href="http://www.adebenham.com/2012/02/freetronics-dmd-updated-library/">DMD library</a> is setup to handle rows of displays where odd-numbered rows are upside down.<br />
See this diagram for how it is laid out (for 2&#215;2 case)</p>
<p><img class="aligncenter" title="Multi-DMD layout" src="/arduino/multi-DMD.svg" alt="" width="515" height="303" /></p>
<p>Playing is fairly straight-forward.  Only thing to remember is that the &#8216;z-button&#8217; on the nunchuck is used to select and the &#8216;c-button&#8217; is used to exit back to the menu</p>
<p>Have a look at the video below to see them in action.<br />
<iframe src="http://www.youtube.com/embed/5WW9ZmvjSA4?version=3&amp;wmode=transparent" width="560" height="340" title="YouTube video player" style="background-color:#000;display:block;margin-bottom:0;max-width:100%;" frameborder="0" allowfullscreen></iframe><p style="font-size:11px;margin-top:0;"><a href="http://www.youtube.com/watch?v=5WW9ZmvjSA4" target="_blank" title="Watch on YouTube">Watch this video on YouTube</a>.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.adebenham.com/2012/02/freetronics-dmd-games/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Freetronics DMD &#8211; updated library</title>
		<link>http://www.adebenham.com/2012/02/freetronics-dmd-updated-library/</link>
		<comments>http://www.adebenham.com/2012/02/freetronics-dmd-updated-library/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 04:49:27 +0000</pubDate>
		<dc:creator>cjd</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[DMD]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.adebenham.com/?p=55</guid>
		<description><![CDATA[I recently got two Dot Matrix Displays from Freetronics - They are 32&#215;16 LED panels that can be daisychained via SPI. It came with a quick library which worked okay but could do with a few enhancements My modified library supports multiple displays (tested with 2&#215;1 and 1&#215;2 layout &#8211; but should work with other [...]]]></description>
			<content:encoded><![CDATA[<p>I recently got two Dot Matrix Displays from Freetronics -<br />
They are 32&#215;16 LED panels that can be daisychained via SPI.<br />
It came with a quick library which worked okay but could do with a few enhancements <img src='http://www.adebenham.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
My modified library supports multiple displays (tested with 2&#215;1 and 1&#215;2 layout &#8211; but should work with other layouts)<br />
It also supports multiple fonts, marquee text, scrolling the display around and grayscale (grayscale sort of works &#8211; but not well <img src='http://www.adebenham.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  )<br />
I have updated the examples included in the original library to use these new functions.</p>
<p>The library can be downloaded from <a href="https://github.com/cjd/DMD">github.com/cjd/DMD</a><br />
See <a href="http://forum.freetronics.com/viewtopic.php?f=26&#038;t=153">freetronics forum for my DMD library</a><br />
<iframe src="http://www.youtube.com/embed/5DLmWrpV-3M?version=3&amp;wmode=transparent" width="560" height="340" title="YouTube video player" style="background-color:#000;display:block;margin-bottom:0;max-width:100%;" frameborder="0" allowfullscreen></iframe><p style="font-size:11px;margin-top:0;"><a href="http://www.youtube.com/watch?v=5DLmWrpV-3M" target="_blank" title="Watch on YouTube">Watch this video on YouTube</a>.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.adebenham.com/2012/02/freetronics-dmd-updated-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Console-based podcaster &#8211; updated</title>
		<link>http://www.adebenham.com/2010/02/console-based-podcaster-updated/</link>
		<comments>http://www.adebenham.com/2010/02/console-based-podcaster-updated/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 21:43:29 +0000</pubDate>
		<dc:creator>cjd</dc:creator>
				<category><![CDATA[Scripts]]></category>
		<category><![CDATA[bashpodder]]></category>

		<guid isPermaLink="false">http://www.adebenham.com/?p=52</guid>
		<description><![CDATA[It has been a while since I first posted my version of bashpodder (a console-based podcaster in a single bash script) Since then a bunch of small fixes have been added to the script to better handle &#8216;odd&#8217; rss feeds and also to clean up the output. The configuration of the script now sits in [...]]]></description>
			<content:encoded><![CDATA[<p>It has been a while since I first posted my version of bashpodder (a console-based podcaster in a single bash script)</p>
<p>Since then a bunch of small fixes have been added to the script to better handle &#8216;odd&#8217; rss feeds and also to clean up the output.</p>
<p>The configuration of the script now sits in the file ~/.bashpodder  Inside this file you can specify where the logs go to and where the files download to (makes it easier to run the script automatically)</p>
<p>Thanks to <cite>Mobilediesel</cite> it now also doesn&#8217;t create the temporary xslt file and there is the option to use &#8216;-a feedurl [items]&#8216; to add a feed to the config file.  The [items] parameter is optional and when used will cause bashpodder to mark all items in the feed as already downloaded <strong>except</strong> the last <em>[items]</em> items.  This is useful when added a new feed so that it doesn&#8217;t try to download every item in the feed since day one <img src='http://www.adebenham.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>The updated script can be downloaded as <a href="/files/bashpodder/bashpodder.sh">bashpodder.sh</a> and an example config file as <a href="/files/bashpodder/.bashpodder">.bashpodder</a></p>
<p>For more details on the script see the original post <a href="http://www.adebenham.com/2009/03/console-based-podcatcher/">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.adebenham.com/2010/02/console-based-podcaster-updated/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MusicXML/MIDI for Arduino</title>
		<link>http://www.adebenham.com/2010/02/musicxmlmidi-for-arduino/</link>
		<comments>http://www.adebenham.com/2010/02/musicxmlmidi-for-arduino/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 00:47:49 +0000</pubDate>
		<dc:creator>cjd</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Peggy 2]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://www.adebenham.com/?p=49</guid>
		<description><![CDATA[For a recent project I wanted to add music. Being that I am not musically talented in any way I figured the best way to do this was to generate the music from a midi file. To help with this I wrote a converter that would take a MusicXML file and output an include file. [...]]]></description>
			<content:encoded><![CDATA[<p>For a recent project I wanted to add music.</p>
<p>Being that I am not musically talented in any way I figured the best way to do this was to generate the music from a midi file.</p>
<p>To help with this I wrote a converter that would take a MusicXML file and output an include file.</p>
<p>It simply reads the XML and outputs an array where each note is stored in two uint16 values &#8211; the first is the note name as a defined in pitches.h (ie NOTE_C4), the second is the duration in milliseconds.  The entire array is stored in PROGMEM so as to not use up too much ram on the AVR.</p>
<p>The script is as follows (or download from <a href="/files/arduino/convert_xml.pl">here</a>)</p>
<pre>#!/usr/bin/perl
# Convert a single-channel musicxml file to include file for arduino
# Pass the xml filename on the commandline and a .h file will be generated
# with the same name (replacing .xml with .h)

# Needs XML::Mini perlmodule (libxml-mini-perl package in debian/ubuntu)
use XML::Mini::Document;
my $size = 0;

my $name = $ARGV[0];
$name =~ s/\.xml$//;
open(OUT, "&gt;".$name.".h");
print OUT "PROGMEM prog_uint16_t ".$name."Tune[] = {\n";

my $xmldoc = XML::Mini::Document-&gt;new();
$xmldoc-&gt;fromFile($ARGV[0]);
my $xmlHash = $xmldoc-&gt;toHash();
my $measures = $xmlHash-&gt;{'score-partwise'}-&gt;{'part'}-&gt;{'measure'};
foreach my $measure (@$measures) {
  my $notes=$measure-&gt;{'note'};
  foreach (@$notes) {
    my $note = "";
    if ($_-&gt;{'pitch'}) {
      if (defined $_-&gt;{'accidental'}) {
        if ($_-&gt;{'accidental'} eq "sharp") {
          $_-&gt;{'pitch'}-&gt;{'step'}=$_-&gt;{'pitch'}-&gt;{'step'}."S";
        } elsif ($_-&gt;{'accidental'} eq "flat") {
          $_-&gt;{'pitch'}-&gt;{'step'} =~ tr/A-F/FA-E/;
          $_-&gt;{'pitch'}-&gt;{'step'}=$_-&gt;{'pitch'}-&gt;{'step'}."S";
        }
      }
      $note = "NOTE_".$_-&gt;{'pitch'}-&gt;{'step'}.$_-&gt;{'pitch'}-&gt;{'octave'};
    } else {
      $note = "NOTE_00";
    }
    my $duration = $_-&gt;{'duration'};
    print OUT $note.", ".$duration.", ";
    $size++;
  }
  print OUT "\n";
}
print OUT "};\n";
print OUT "byte ".$name."TuneSteps = ".$size.";\n";
print "total memory usage:".(($size*4)+1)." bytes\n";
close OUT;
</pre>
<p>To actually use this generated include file I created a function &#8216;playMelody&#8217; which is called regularly during the running of a sketch.</p>
<p>Each time it runs it checks if it is time to play the next note, if so then it reads the next note from the array,calls &#8216;tone&#8217; to play it and then sets a variable to say when the next note should be played.  If it is not yet time to play the next note then it quickly returns (there is not much latency added by calling the function so it&#8217;s okay to call too often)</p>
<pre><span style="color: #cc6600;">boolean</span> playMelody()
{
  <span style="color: #cc6600;">boolean</span> retVal=<span style="color: #cc6600;">true</span>;
  <span style="color: #cc6600;">if</span> (<span style="color: #cc6600;">millis</span>() &gt; time) {
    <span style="color: #cc6600;">int</span> toneVal = 0;
    <span style="color: #cc6600;">int</span> duration = 0;
    <span style="color: #cc6600;">if</span> (tuneStep &gt;= SmoothCriminalTuneSteps) {
      retVal=<span style="color: #cc6600;">false</span>;
      tuneStep=0;
    }
    toneVal=pgm_read_word_near(SmoothCriminalTune+(tuneStep*2));
    duration = pgm_read_word_near(SmoothCriminalTune+(tuneStep*2)+1);
    tuneStep++;
    <span style="color: #cc6600;">if</span> (toneVal) <span style="color: #cc6600;">tone</span>(speakerPin,toneVal,duration*2);
    time=<span style="color: #cc6600;">millis</span>()+(duration*2)+5;
  }
  <span style="color: #cc6600;">return</span> retVal;
}
</pre>
<p>I have a sample sketch which uses this to play a short melody loop as <a href="/files/arduino/music.zip">music.zip</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.adebenham.com/2010/02/musicxmlmidi-for-arduino/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Peggy 2 multi-game sketch v0.2</title>
		<link>http://www.adebenham.com/2010/02/peggy-2-multi-game-sketch-v0-2/</link>
		<comments>http://www.adebenham.com/2010/02/peggy-2-multi-game-sketch-v0-2/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 00:28:23 +0000</pubDate>
		<dc:creator>cjd</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Peggy 2]]></category>

		<guid isPermaLink="false">http://www.adebenham.com/?p=48</guid>
		<description><![CDATA[I&#8217;ve done a lot more work on the multi-game sketch for my Peggy2 &#8211; mostly to add functionality and fix up a few &#8216;issues&#8217; See the original post for more details on what is included Download it from here When compiled it uses 13808 bytes so there only a bit of room to spare. I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve done a lot more work on the multi-game sketch for my Peggy2 &#8211; mostly to add functionality and fix up a few &#8216;issues&#8217;<br />
See the original post <a href="http://www.adebenham.com/2010/02/peggy-2-multi-game-sketch-v0-1/">here</a> for more details on what is included<br />
Download it from <a href="/files/arduino/peggy2_games_0.2.zip">here</a> When compiled it uses 13808 bytes so there only a bit of room to spare.<br />
I&#8217;ve added a two player version of pong (use up/down buttons to control player two &#8211; I&#8217;ve made a separate plug-in controller for player two to make things easier to use)<br />
I&#8217;ve fixed up the &#8216;breakout&#8217; clone so it actually can be considered a &#8216;game&#8217; <img src='http://www.adebenham.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
I also added a &#8216;demo&#8217; game which just lights up all leds with a nice grayscale pattern than can be moved around via the direction buttons (press select to stop the motion)<br />
The other main thing is that it now has sound!<br />
With the release of arduino-0018 they added a function &#8216;tone&#8217; to generate square waves on a digital pin. I connected a piezo speaker (from a headphone) to ADC5 and generated the tones on that pin.<br />
There is intro music at the game select screen, music when displaying the score and various bips and beeps while playing the games.<br />
To make the music I wrote a small perl script to convert MusicXML files to a suitable include file (will be documented in a separate post)<br />
Adding the music and extra games meant I was hitting the space limits in the AVR so there is a bit of &#8216;dodgyness&#8217; in the code so that it would fit.</p>
<p>See the original post <a href="http://www.adebenham.com/2010/02/peggy-2-multi-game-sketch-v0-1/">here</a> for more details on what is included</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adebenham.com/2010/02/peggy-2-multi-game-sketch-v0-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Peggy 2 multi-game sketch v0.1</title>
		<link>http://www.adebenham.com/2010/02/peggy-2-multi-game-sketch-v0-1/</link>
		<comments>http://www.adebenham.com/2010/02/peggy-2-multi-game-sketch-v0-1/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 22:26:30 +0000</pubDate>
		<dc:creator>cjd</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[Peggy 2]]></category>

		<guid isPermaLink="false">http://www.adebenham.com/?p=17</guid>
		<description><![CDATA[I had such fun writing the simple &#8216;snake&#8217; game for my peggy 2 that I wrote a bunch of other games for it as well. At the moment there is Snake, Breakout, Pong and Race. You can download the sketch as peggy2_games_0.1.zip When compiled it takes up 11432 bytes (it includes the &#8216;Tone&#8217; library as [...]]]></description>
			<content:encoded><![CDATA[<p>I had such fun writing the simple &#8216;snake&#8217; game for my peggy 2 that I wrote a bunch of other games for it as well.</p>
<p>At the moment there is Snake, Breakout, Pong and Race.</p>
<p>You can download the sketch as <a href="/files/arduino/peggy2_games_0.1.zip">peggy2_games_0.1.zip</a></p>
<p>When compiled it takes up 11432 bytes (it includes the &#8216;Tone&#8217; library as I have started adding sound to the sketch &#8211; connect speaker to ADC5 to hear it)</p>
<h2>Starting peggy2_game</h2>
<p><a href="http://www.adebenham.com/wp-content/uploads/2010/02/game_menu.jpg"><img class="aligncenter size-full wp-image-19" title="Game menu" src="http://www.adebenham.com/wp-content/uploads/2010/02/game_menu.jpg" alt="Game menu" width="300" height="327" /></a></p>
<p>When you turn on the peggy2 a menu is presented displaying the available games &#8211; you can select from them using the up/down buttons and select with the &#8216;select&#8217; or &#8216;any&#8217; button on the left of the peggy2.  Only three game names fit on the screen at once so the entire display scrolls up/down when changing game (and highlights the current selection)  To change games press the reset button.</p>
<h2>Playing the games</h2>
<h3>Snake</h3>
<p style="text-align: center;"><a href="http://www.adebenham.com/wp-content/uploads/2010/02/snake.jpg"><img class="alignnone size-full wp-image-21" title="Snake" src="http://www.adebenham.com/wp-content/uploads/2010/02/snake.jpg" alt="Snake" width="300" height="309" /></a><a href="http://www.adebenham.com/wp-content/uploads/2010/02/level_select.jpg"><img class="alignnone size-full wp-image-20" title="Level select" src="http://www.adebenham.com/wp-content/uploads/2010/02/level_select.jpg" alt="Level select" width="300" height="307" /></a></p>
<p>When the game first starts you can choose which level to start at.  There are four different boards available &#8211; these boards are re-used in a loop just at a higher speed for later levels.</p>
<p>Eat the &#8216;apples&#8217; to get points, don&#8217;t hit yourself or walls</p>
<p>Arrow buttons control movement of the snake.</p>
<p><a href="http://www.adebenham.com/wp-content/uploads/2010/02/score.jpg"><img class="aligncenter size-full wp-image-22" title="Score screen" src="http://www.adebenham.com/wp-content/uploads/2010/02/score.jpg" alt="Score screen" width="300" height="299" /></a></p>
<h3>Pong</h3>
<p><a href="http://www.adebenham.com/wp-content/uploads/2010/02/pong.jpg"><img class="aligncenter size-full wp-image-23" title="Pong game" src="http://www.adebenham.com/wp-content/uploads/2010/02/pong.jpg" alt="Pong game" width="300" height="292" /></a></p>
<p>Hit the ball back, get a point if the AI misses, AI gets the point if you miss</p>
<p>Left/right buttons control movement of the bottom paddle (one player only for the moment)</p>
<h3>Break</h3>
<p><a href="http://www.adebenham.com/wp-content/uploads/2010/02/break.jpg"><img class="aligncenter size-full wp-image-24" title="Breakout game" src="http://www.adebenham.com/wp-content/uploads/2010/02/break.jpg" alt="Breakout game" width="300" height="284" /></a></p>
<p>Not much here yet, just displays a bouncing ball + blocks to hit</p>
<p>Left/right buttons control movement of the paddle</p>
<h3>Race</h3>
<p><a href="http://www.adebenham.com/wp-content/uploads/2010/02/race.jpg"><img class="aligncenter size-full wp-image-25" title="Race game" src="http://www.adebenham.com/wp-content/uploads/2010/02/race.jpg" alt="Race game" width="300" height="280" /></a></p>
<p>Avoid the walls.  One point every 25 blocks driven past, walls get narrower every 25 points</p>
<p>Left/right buttons control movement of the car.</p>
<p>peggy2_games.zip</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adebenham.com/2010/02/peggy-2-multi-game-sketch-v0-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Peggy 2 Character display</title>
		<link>http://www.adebenham.com/2010/01/peggy-2-character-display/</link>
		<comments>http://www.adebenham.com/2010/01/peggy-2-character-display/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 03:48:31 +0000</pubDate>
		<dc:creator>cjd</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Peggy 2]]></category>

		<guid isPermaLink="false">http://www.adebenham.com/?p=15</guid>
		<description><![CDATA[As mentioned in the  post I wrote a bunch of small utility functions to display a string on the peggy 2. Each character is stored as a 24-bit number (held in a 32bit uint32) where each 4 bits indicates the on/off status for a row of 4 pixels. This results in allowing for a 4&#215;6 [...]]]></description>
			<content:encoded><![CDATA[<p>As mentioned in the <a href="http://www.adebenham.com/2010/01/peggy-2-snake/">Peggy 2 Snake</a> post I wrote a bunch of small utility functions to display a string on the peggy 2.</p>
<p>Each character is stored as a 24-bit number (held in a 32bit uint32) where each 4 bits indicates the on/off status for a row of 4 pixels. This results in allowing for a 4&#215;6 pixel character</p>
<p>For example the character for the number &#8217;0&#8242; is stored as 0&#215;699996 which when spread out looks like:</p>
<pre>0<strong>11</strong>0
<strong>1</strong>00<strong>1</strong>
<strong>1</strong>00<strong>1</strong>
<strong>1</strong>00<strong>1</strong>
<strong>1</strong>00<strong>1</strong>
0<strong>11</strong>0</pre>
<p>By doing this I can store 0-9 and A-Z in only 144bytes.<br />
To save RAM I put this in program memory using: PROGMEM prog_uint32_t chars[37] ﻿</p>
<p>To write a character to the display I use a function &#8220;show_char&#8221; (note I use a special function &#8216;setPixel&#8217; to set the individual pixels to a certain brightness level &#8211; but if you are not using grayscale then the call can be replaced by standard frame.SetPixel calls)</p>
<pre>void show_char(char Character, byte x, byte y)
{
  byte charNum = 36;
  if ((Character &gt;= '0') &amp;&amp; (Character &lt;= '9')) {
    charNum=Character-48;
  }
  if ((Character &gt;= 'A') &amp;&amp; (Character &lt;= 'Z')) {
    charNum=Character-55;
  }
  unsigned long w;
  w = pgm_read_dword_near(chars + charNum);
  for (byte i=0; i&lt;6; i++) {
    byte offset = 4*(5-i);
    byte b = w &gt;&gt; offset; // get four bits
    b=b &amp; 0xF;
    if (b &amp; B1000) setPixel(x,y+i,7);
    if (b &amp; B0100) setPixel(x+1,y+i,7);
    if (b &amp; B0010) setPixel(x+2,y+i,7);
    if (b &amp; B0001) setPixel(x+3,y+i,7);
  }
}
</pre>
<p>To make things a bit easier to display a string I also created a quick wrapper function &#8216;write_string&#8217;</p>
<pre>void write_string(char string[], byte x, byte y)
{
  byte i=0;
  while (string[i] != '\0') {
    show_char(string[i], x+(5*i), y);
    i++;
  }
}
</pre>
<p>Full usage/source can be found in the peggy 2 snake code</p>
]]></content:encoded>
			<wfw:commentRss>http://www.adebenham.com/2010/01/peggy-2-character-display/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
