From cdbbcb2a73fd4a8d4b3c65fd7e0f6ec273537e5b Mon Sep 17 00:00:00 2001 From: Sebastian Zietz Date: Thu, 29 Sep 2011 20:20:56 +0200 Subject: v2 --- _3x3Matrix.pde | 97 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 81 insertions(+), 16 deletions(-) diff --git a/_3x3Matrix.pde b/_3x3Matrix.pde index 6a2a147..377eda2 100644 --- a/_3x3Matrix.pde +++ b/_3x3Matrix.pde @@ -6,18 +6,66 @@ */ #define ROW 3 #define COL 0 -#define ROWCNT 3 -#define COLCNT 3 +#define ROWCNT 7 +#define COLCNT 13 +#define CHARWIDTH 5 +#define FRAMELEN 10 #define DELAY 3 -int frame[3][3] = { - {0, 0, 0}, - {0, 0, 0}, - {0, 0, 0}, +int frame[COLCNT][ROWCNT] = {0}; + +/*const int frame_A[ROWCNT][CHARWIDTH] = { + {0, 0, 1, 0, 0}, + {0, 0, 1, 0, 0}, + {0, 1, 0, 1, 0}, + {0, 1, 0, 1, 0}, + {1, 1, 1, 1, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, +};*/ + +/*const int frame_C[CHARWIDTH][ROWCNT] = { + {0, 0, 1, 1, 1}, + {0, 1, 1, 0, 0}, + {1, 1, 0, 0, 0}, + {1, 0, 0, 0, 0}, + {1, 1, 0, 0, 0}, + {0, 1, 1, 0, 0}, + {0, 0, 1, 1, 1}, }; -int framenr = 0; +const int frame_H[ROWCNT][CHARWIDTH] = { + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 1, 1, 1, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, + {1, 0, 0, 0, 1}, +}; + +const int frame_L[ROWCNT][CHARWIDTH] = { + {1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0}, + {1, 0, 0, 0, 0}, + {1, 1, 1, 1, 1}, +};*/ + +const int frame_MINUS[CHARWIDTH][ROWCNT] = { + {0, 0, 0, 1, 0, 0, 0}, + {0, 0, 0, 1, 0, 0, 0}, + {0, 0, 0, 1, 0, 0, 0}, + {0, 0, 0, 1, 0, 0, 0}, + {0, 0, 0, 1, 0, 0, 0}, +}; + +const int emptyCol[ROWCNT] = {0}; + +unsigned long int framenr = 0; int rownr = 0; void setup() { // initialize the digital pin as an output. @@ -29,16 +77,33 @@ void setup() { pinMode(COL + i, OUTPUT); } +void setCol(int c, const int data[ROWCNT]) { + int r; + + if (c > 0 && c <= COLCNT) { + for (r = 0; r < ROWCNT; r++) + frame[c][r] = data[r]; + } +} + +void setChar(int c, const int data[CHARWIDTH][ROWCNT]) { + int i; + for (i = 0; i < CHARWIDTH; i++) + setCol(c+i, data[i]); +} + +void clearFrame() { + int i = 0; + for (i = 0; i < COLCNT; i++) + setCol(i, emptyCol); +} + void nextFrame() { - frame[0][0] = (framenr % 100) < 50; - frame[0][1] = (framenr % 100) < 50; - frame[0][2] = (framenr % 100) < 50; - frame[1][0] = (framenr % 100) < 50; - frame[1][1] = (framenr % 100) >= 50; - frame[1][2] = (framenr % 100) < 50; - frame[2][0] = (framenr % 100) < 50; - frame[2][1] = (framenr % 100) < 50; - frame[2][2] = (framenr % 100) < 50; + int c; + int f2 = (framenr/FRAMELEN) % (COLCNT+CHARWIDTH); + + clearFrame(); + setChar(COLCNT-f2, frame_MINUS); } void loop() { -- cgit v1.2.3