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.

Revision:
7:f6d73bba9c4c
Parent:
5:1c9223c17976
Child:
8:d0e048eef5db
--- 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"