driver for 8x8

Dependents:   poster8x8_ranger

Files at this revision

API Documentation at this revision

Comitter:
cstevens
Date:
Tue Jun 14 13:33:56 2016 +0000
Commit message:
libvrary to drive an 8x8 led matrix

Changed in this revision

8x8.cpp Show annotated file Show diff for this revision Revisions of this file
8x8.h Show annotated file Show diff for this revision Revisions of this file
smiles.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 12e8e6371165 8x8.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/8x8.cpp	Tue Jun 14 13:33:56 2016 +0000
@@ -0,0 +1,37 @@
+#include "8x8.h"
+
+#include "smiles.h"
+
+//define 2 buses for the row and column pins
+BusOut Row(PTC11,PTC10,PTC3,PTB10,PTC0,PTE2,PTE3,PTC5);
+
+BusOut Col(PTC7,PTC6,PTB8,PTC4,PTE5,PTB9,PTE4,PTB11);
+
+// sub to write character to the 8x8 display once - has to be repeated to keep display live
+int write_8x8(int eye,int mth)
+{
+    int rw,i;
+    //write eyes
+    for(i=0; i<4; i++) {
+        rw=0;
+        rw=1<<i;
+        Row=~rw; // this inverts the row code so that only the desired row is low
+        Col=eyes[i+4*eye];
+        wait(0.002);
+
+    }//endfori
+    //write mouth
+    for(i=4; i<8; i++) {
+        rw=0;
+        rw=1<<i;
+        Row=~rw; // this inverts the row code so that only the desired row is low
+        Col=mouth[i-4+4*mth];
+        wait(0.002);
+
+    }//endfori
+
+
+
+
+    return(0);
+}
diff -r 000000000000 -r 12e8e6371165 8x8.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/8x8.h	Tue Jun 14 13:33:56 2016 +0000
@@ -0,0 +1,5 @@
+
+#include "mbed.h"
+
+
+int write_8x8(int eye,int mth); // 8x8 led only has 1 function prototype
diff -r 000000000000 -r 12e8e6371165 smiles.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/smiles.h	Tue Jun 14 13:33:56 2016 +0000
@@ -0,0 +1,26 @@
+//0 happy
+//8 sad
+//16 sleeping
+//24 shouting
+//32 winking
+//40 look left
+// 48 looki right
+// 56 evil
+
+
+int eyes[24]= {
+    0,231,132,0,  //eyes left      0
+    0,231,66,0,   //eyes mid       1
+    0,231,33,0,   //eyes right     2
+    0,165,66,0 ,   //eyes shut      3
+    0,224,71,0,   // wink          4
+    0,129,66,0     //frown          5
+};
+
+int mouth[20]={
+ 0,129,102,24,   // happy           0
+ 0,24,102,129,   //sad              1
+ 0,0,126,0,   //neutral             2
+ 0,192,62,0,   //wry                3
+0,60,66,60    //shout               4
+    };
\ No newline at end of file