Conway's game of life applied to the mbed and an RA8875 LCD.

Dependencies:   LifeRules mbed RA8875

Inspired by a forum discussion on the mbed site, this version was scaled to support up to a 480x272 display - in a monochrome mode, or at a lower resolution in color (the color shows simple animation for birthing and dying cells).

Leveraging the LifeRules class, the game can be easily adapted to other displays - whether monochrome or color.

By default, this version allocates memory from the Ethernet ram banks, so avoids the memory limitations of some designs.

It should be simple to adapt it to any display - color or b&w, high or low resolution.

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Sat Jan 23 17:26:49 2016 +0000
Parent:
6:4d62d10e2c1d
Child:
8:d0e048eef5db
Commit message:
Library updates

Changed in this revision

RA8875.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/RA8875.lib	Sat Dec 19 16:02:21 2015 +0000
+++ b/RA8875.lib	Sat Jan 23 17:26:49 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/WiredHome/code/RA8875/#0b084475d5a9
+http://mbed.org/users/WiredHome/code/RA8875/#fc60bfa0199f
--- a/main.cpp	Sat Dec 19 16:02:21 2015 +0000
+++ b/main.cpp	Sat Jan 23 17:26:49 2016 +0000
@@ -1,9 +1,9 @@
 // game of life implementation inspired by this forum thread
 // http://mbed.org/forum/helloworld/topic/4822/
 // 
-#include "mbed.h"
-#include "RA8875.h"
-#include "LifeRules.h"
+#include "mbed.h"       // v112
+#include "RA8875.h"     // v102
+#include "LifeRules.h"  // v3
 
 // Define the life-map size
 #define LIFE_W 150
@@ -94,19 +94,19 @@
                 color_t p;
                 switch (lifeState) {
                     case Life::dead:
-                        p = Black;
+                        p = RGB(0,0,0);
                         break;
                     case Life::dying:
-                        p = RGB(64,0,0);
+                        p = RGB(192,0,0);
                         break;
                     case Life::living:
-                        p = Charcoal;
+                        p = RGB(64,255,64);
                         break;
                     case Life::birthing:
-                        p = Blue;
+                        p = RGB(0,0,192);
                         break;
                     default:
-                        p = Orange;
+                        p = RGB(192,192,0); // Should never see this one...
                         ERR(" lifeState = %d\r\n", lifeState);
                         break;
                 }
@@ -153,6 +153,8 @@
     life.DestroyAllLife();
     INFO("Life destroyed");
 
+    lcd.foreground(RGB(255,255,255));
+    
     //pc.printf("choice value = %d\n\r",choice); //for debugging
     lcd.puts("Please Select Starting Configuration:\r\n");
     lcd.puts(" 0 = Glider     1 = Random\r\n"
--- a/mbed.bld	Sat Dec 19 16:02:21 2015 +0000
+++ b/mbed.bld	Sat Jan 23 17:26:49 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/6f327212ef96
\ No newline at end of file