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:
Sun Dec 28 23:15:05 2014 +0000
Parent:
3:1139b132f983
Child:
5:1c9223c17976
Commit message:
Minor update for documentation purposes.

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
--- a/RA8875.lib	Thu Apr 24 11:19:56 2014 +0000
+++ b/RA8875.lib	Sun Dec 28 23:15:05 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/WiredHome/code/RA8875/#bd53a9e165a1
+http://mbed.org/users/WiredHome/code/RA8875/#01da2e34283d
--- a/main.cpp	Thu Apr 24 11:19:56 2014 +0000
+++ b/main.cpp	Sun Dec 28 23:15:05 2014 +0000
@@ -120,6 +120,27 @@
     lcd.WindowMax();
 }
 
+int GetScreenCapture(void)
+{
+    char fqfn[50];
+    int i = 0;
+    
+    pc.printf("Screen Capture... ");
+    for (i=1; i< 100; i++) {
+        snprintf(fqfn, sizeof(fqfn), "/local/Screen%02d.bmp", i);
+        FILE * fh = fopen(fqfn, "rb");
+        if (!fh) {
+            lcd.PrintScreen(0,0,480,272,fqfn);
+            pc.printf(" as /local/Screen%02d.bmp\r\n", i);
+            return i;
+        } else {
+            fclose(fh);     // close this and try the next
+        }
+    }
+    return 0;
+}
+
+
 int main()
 {
     pc.baud(460800);    // I like a snappy terminal, so crank it up!
@@ -136,7 +157,7 @@
     lcd.puts(" 0 = Glider     1 = Random\r\n"
              " 2 = Ship       3 = Glider Gun\r\n"
              " 4 = BMP image  5 = Blinker\r\n"
-             " t = test\r\n"
+             " t = test       \r\n"
              " r = reset\r\n"
              );
     
@@ -175,7 +196,8 @@
             gentest();
             break;
     }
-    lcd.puts("\r\nChange Speed:\r\n"
+    lcd.puts("\r\nRuntime Menu:\r\n"
+             " p   = PrintScreen\r\n"
              " +   = faster\r\n"
              " -   = slower\r\n"
              " 0-9 = updates/sec\r\n"
@@ -215,6 +237,8 @@
                 msDelay = 10 * ((1000 / (c - '0'))/10);
         } else if (c == 'r')
             mbed_reset();
+        else if (c == 'p')
+            GetScreenCapture();
         lcd.locate(49, 0);
         if (msDelay < 0) {
             msDelay = -10;