<?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>codetorment &#187; game of life</title>
	<atom:link href="http://www.codetorment.com/tag/game-of-life/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codetorment.com</link>
	<description>code, tech, random stuff</description>
	<lastBuildDate>Tue, 04 May 2010 21:04:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=9498</generator>
		<item>
		<title>Arduino Goodness : Watterott S65-Shield 172&#215;136 pixels 16-bit color display</title>
		<link>http://www.codetorment.com/2009/11/03/arduino-goodness-watterott-s65-shield-16-bit-color-display-with-172x136-pixels/</link>
		<comments>http://www.codetorment.com/2009/11/03/arduino-goodness-watterott-s65-shield-16-bit-color-display-with-172x136-pixels/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 22:51:55 +0000</pubDate>
		<dc:creator>tom</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[game of life]]></category>
		<category><![CDATA[s65]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[sdcard]]></category>
		<category><![CDATA[shield]]></category>

		<guid isPermaLink="false">http://www.codetorment.com/?p=554</guid>
		<description><![CDATA[Santa came early this year and brought me a S65-Shield revision 1.2 from watterott It consists of : - a Siemens S65 16-bit color screen with 172&#215;136 pixels - a rotary switch (left-right-press) - a micro-SD slot (bottom) You can visit the project page to check progress made to the libraries and hardware.The most recent [...]]]></description>
			<content:encoded><![CDATA[<p>Santa came early this year and brought me a S65-Shield revision 1.2 from <a title="Watterott.com" href="https://www.watterott.com/S65-Shield-fuer-Arduino-Duemilanove-Diecimila_1" target="_blank">watterott</a></p>
<div id="attachment_591" class="wp-caption alignnone" style="width: 458px"><a href="http://www.codetorment.com/wp-content/uploads/DSCN9584.JPG"><img class="size-full wp-image-591   " title="Arduino Goodness" src="http://www.codetorment.com/wp-content/uploads/DSCN9584.JPG" alt="Display text" width="448" height="336" /></a><p class="wp-caption-text">S65 displaying random text</p></div>
<p>It consists of :</p>
<p>- a Siemens S65 16-bit color screen with 172&#215;136 pixels</p>
<p>- a rotary switch (left-right-press)</p>
<p>- a micro-SD slot (bottom)<span id="more-554"></span></p>
<div id="attachment_558" class="wp-caption alignnone" style="width: 458px"><a href="http://www.codetorment.com/wp-content/uploads/sd65_bottom.JPG"><img class="size-full wp-image-558 " title="sd65_bottom" src="http://www.codetorment.com/wp-content/uploads/sd65_bottom.JPG" alt=" Arduino Goodness : Watterott S65 Shield 172x136 pixels 16 bit color display" width="448" height="337" /></a><p class="wp-caption-text">S65 bottom</p></div>
<p>You can visit the <a title="S65 Project Page" href="http://www.watterott.net/projects/s65-shield?" target="_blank">project page</a> to check progress made to the libraries and hardware.The most recent library is <a title="S65 v0.08 library download" href="http://www.watterott.net/arduino/s65-shield_v008.zip" target="_blank">v0.08</a> . It&#8217;s actually more like 3 libraries:  &#8216;S65Display&#8217;, &#8216;RotaryEncoder&#8217; and &#8216;SDCard&#8217;.</p>
<p>You can check the <a title="S65 Library Documentation" href="http://www.codetorment.com/wp-content/uploads/S65_Libraries_Docu.htm" target="_blank">documentation</a> that comes with the libraries to view this <span style="text-decoration: line-through;">baby</span> shields&#8217; possibilities. So far this shield seems to be a bargain (compaired to other display-shields out there) selling at only €35 that&#8217;s equal to $51.36600 or 4640.5276 Japanese  Yen or 149.793533 Polish Zloty or your virginity if you&#8217;re misfortuned enough to live in one of those countries, anyhow.</p>
<p>It has some pretty long headers which make it easy to mount on top of the tallest board you own.</p>
<div id="attachment_559" class="wp-caption alignnone" style="width: 458px"><a href="http://www.codetorment.com/wp-content/uploads/sd65_side.JPG"><img class="size-full wp-image-559  " title="sd65_side" src="http://www.codetorment.com/wp-content/uploads/sd65_side.JPG" alt="S65 mating with Duemilanove" width="448" height="335" /></a><p class="wp-caption-text">S65 mating with Duemilanove</p></div>
<p>I don&#8217;t have a microSD card at hand so I can&#8217;t test the SDCard library for now. Which sucks since you can load images stored on the microSD and display them on the screen. You can also use the images for buttons, icons, etc in your sketches&#8230; how cool is that?</p>
<p>Here&#8217;s an example of the awsome S65-Shield in action on an Arduino Duemilanove with 328 Atmel running a Game of Life sketch. I am not the author of this code, he gave me the code for testing and learning purposes. I just added the rotary delay. <span style="text-decoration: line-through;">Maybe he&#8217;ll give his consent later so I can post the code online.</span> Foo Joku gave his consent, the code is posted after the video.</p>
<p>The display and colors look much better in real life, this video was shot with an old digital camera in bad light conditions.</p>
<p><object style="width: 480px; height: 360px;" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="360" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=7421217&#038;server=vimeo.com&#038;show_title=1&#038;show_byline=1&#038;show_portrait=0&#038;color=&#038;fullscreen=1" /><embed style="width: 480px; height: 360px;" type="application/x-shockwave-flash" width="480" height="360" src="http://vimeo.com/moogaloop.swf?clip_id=7421217&#038;server=vimeo.com&#038;show_title=1&#038;show_byline=1&#038;show_portrait=0&#038;color=&#038;fullscreen=1"></embed></object></p>
<pre>GOL code:
<pre class="brush: cpp;">
#include &lt;S65Display.h&gt;
#include &lt;RotaryEncoder.h&gt;

#define GRID_X 28
#define GRID_Y 20

#define GRID_X_OFFSET 4
#define GRID_Y_OFFSET 6

#define COLOUR_SWITCH_INTERVAL 30

#define MAX_GENERATIONS 250

S65Display lcd;
RotaryEncoder encoder;

uint8_t grid[2][GRID_X][GRID_Y];
uint8_t current_grid = 0;

uint8_t generations = 0;
uint8_t r = 255,g = 0, b = 0;

// Encoder must be serviced regularly.
ISR(TIMER2_OVF_vect)
{
 TCNT2 -= 250; //1000 Hz
 encoder.service();
}

void setup()
{
 lcd.init(4);
 encoder.init();
 // More encoder stuff
 //init Timer2
 TCCR2B  = (1&lt;&lt;CS22); //clk=F_CPU/64
 TCNT2   = 0x00;
 TIMSK2 |= (1&lt;&lt;TOIE2); //enable overflow interupt

 sei();
 initGrid();
 lcd.clear(0);
 drawGrid();
}

void loop()
{
 //delay(50);
 checkEncoder();
 runGrid();
 drawGrid();
 generations++;
 if (generations &gt; MAX_GENERATIONS || cmpGrid()) {
 generations = 0;
 initGrid();
 }
 cycleColour();
 cycleColour();
 cycleColour();
}

int cmpGrid()
{
 int i, j;
 for (i=0; i &lt; GRID_Y; i++) {
 for (j=0; j &lt; GRID_X; j++) {
 if (grid[0][i][j] != grid[1][i][j]) { return 0; }
 }
 }
 return 1;
}

void initGrid()
{
 int i, j;
 int t;
 lcd.clear(0);
 current_grid = 0;
 for (i = 0; i &lt; GRID_X; i++) {
 for (j = 0; j &lt; GRID_Y; j++) {

 if ((uint8_t)random(255) % 3 == 0) {
 grid[0][i][j] = 1;
 } else {
 grid[0][i][j] = 0;
 }
 }
 }
}

void runGrid()
{
 uint8_t x, y;
 int count;
 char string[2] = {0,0};
 uint8_t value = 0;
 uint8_t new_grid;

 new_grid = 1 - current_grid;
 for (y = 0; y &lt; GRID_Y; y++) {
 for (x = 0; x &lt; GRID_X; x++) {
 count = count_neighbours(x, y);
 string[0] = count+48;
 if (count &lt; 2 || count &gt; 3) { value = 0; }
 else if (count == 3) { value = 3; }
 else { value = grid[current_grid][x][y]; }
 grid[new_grid][x][y] = value;
 }
 }
 current_grid = new_grid;
}

int count_neighbours(int x, int y)
{
 int i, j;
 int sx;
 int result = 0;

 x--;
 y--;
 for (i = 0; i &lt; 3; i++) {
 if (y &lt; 0 || y &gt; (GRID_Y - 1)) { continue; }
 for (j = 0; j &lt; 3; j++) {
 if (x &lt; 0 || x &gt; (GRID_X - 1)) { continue; }
 if (i==1 &amp;&amp; j == 1) { x++; continue; } // skip centre
 if (grid[current_grid][x][y]) { result++; }
 x++;
 }
 y++;
 x -= 3;
 }
 return result;
}

void drawGrid()
{
 uint8_t  x,  y;
 uint8_t cx, cy;
 uint8_t grid_next_colour = 0;
 cx = GRID_X_OFFSET;
 cy = GRID_Y_OFFSET;
 for (y = 0; y &lt; GRID_Y; y++) {
 cx = GRID_X_OFFSET;
 for (x = 0; x &lt; GRID_X; x++) {
 if (grid[1-current_grid][x][y] != grid[current_grid][x][y]) {
 if(grid[current_grid][x][y]) {
 lcd.drawRect(cx+1, cy+1, cx+5, cy+5, RGB(r,g,b));
 } else {
 lcd.drawRect(cx, cy, cx+6, cy+6, 0);
 }
 }
 cx += 6;
 }
 cy += 6;
 }
}

inline void cycleColour()
{
 if (!b &amp;&amp; r)  { r-=5; g+=5; }
 else if (g) { g-=5; b+=5; }
 else if (b) { b-=5; r+=5; }
}

void checkEncoder(void)
{
 int8_t press;
 press = encoder.sw();

 if ( !press ) { return; }

 if (SW_PRESSED == press || SW_PRESSEDLONG == press) {
 initGrid();
 lcd.clear(0);
 }
}
</pre>
<p> <a title="Home" href="http://www.codetorment.com/" target="_self">Back to homepage</a></pre>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://www.codetorment.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://www.codetorment.com/2009/11/03/arduino-goodness-watterott-s65-shield-16-bit-color-display-with-172x136-pixels/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
