Wolfram 1D cellular automata - 640x480 vga

Dependencies:   fastlib mbed vga640x480g

Files at this revision

API Documentation at this revision

Comitter:
JLS
Date:
Mon Feb 27 20:55:25 2012 +0000
Commit message:

Changed in this revision

fastlib.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
vga640x480g.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 106895e78e6d fastlib.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/fastlib.lib	Mon Feb 27 20:55:25 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Ivop/code/fastlib/#bc492a93e116
diff -r 000000000000 -r 106895e78e6d main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Feb 27 20:55:25 2012 +0000
@@ -0,0 +1,65 @@
+#include "mbed.h"
+#include "vga640x480g.h"
+
+void DisplayState(int s[],int len, int row);
+
+int main() {
+
+    init_vga();
+
+    vga_cls();
+    
+    int iteration = 479;
+    int lenght = 639;
+
+    int rules[8] = {1,1,1,0,1,0,0,1};
+
+    int row = 0;
+  
+    int state[lenght];
+    int newstate[lenght];
+    int i,j,k;
+ 
+ while(1) {
+  
+    for (i=0;i<lenght;i++)
+  
+        state[i]= int (rand()%2);
+
+    for (i=0;i<iteration;i++) {
+
+    for (j=0;j<lenght;j++) newstate[j] = 0;
+
+    for (j=0;j<lenght;j++) {
+
+        k = 4*state[(j-1+lenght)%lenght] + 2*state[j] + state[(j+1)%lenght];
+        newstate[j] = rules[k];
+      }
+
+    for (j=0;j<lenght;j++) state[j] = newstate[j];
+        
+        DisplayState(state,lenght,row);
+        row = row + 1;
+        if (row == 480) row = 0;
+   }
+   
+   }
+
+  }    
+  
+  
+void DisplayState(int s[],int len, int row)
+{
+    int i;
+
+    for (i=0;i<len;i++) {
+
+        if (s[i] == 1){
+            vga_plot(i,row,WHITE);
+       }
+         
+        else{
+            vga_plot(i,row,BLACK);
+        }
+      }
+}
\ No newline at end of file
diff -r 000000000000 -r 106895e78e6d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Feb 27 20:55:25 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912
diff -r 000000000000 -r 106895e78e6d vga640x480g.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vga640x480g.lib	Mon Feb 27 20:55:25 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/gertk/code/vga640x480g/#821e34a87609