summaryrefslogtreecommitdiffstats
path: root/Matrix_5x6/TP-Matrix/TP-Matrix.pde
diff options
context:
space:
mode:
Diffstat (limited to 'Matrix_5x6/TP-Matrix/TP-Matrix.pde')
-rw-r--r--Matrix_5x6/TP-Matrix/TP-Matrix.pde174
1 files changed, 174 insertions, 0 deletions
diff --git a/Matrix_5x6/TP-Matrix/TP-Matrix.pde b/Matrix_5x6/TP-Matrix/TP-Matrix.pde
new file mode 100644
index 0000000..e5c3069
--- /dev/null
+++ b/Matrix_5x6/TP-Matrix/TP-Matrix.pde
@@ -0,0 +1,174 @@
+/*
+5x6 LEDs Text scroller
+Frank Bartels 2010
+ */
+
+#define leaner 1 // 0:std 1:normal 2:lean
+//char myoutstring[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ ";
+//char myoutstring[]="0123456789 ";
+char myoutstring[]="META MEUTE ";
+//char myoutstring[]="TOPPOINT KIEL FRICKL 27C3 ";
+int myoutstringpos=0;
+
+#define NledPins 6
+int ledPins[NledPins] = { 7,6,5,4,3,2 };
+
+int i, j, k, x,y,xx,yy, lum=0,newscr=0,tmp;
+int scrollx,scrolly;
+#define SCRdx 5
+#define SCRdy 6
+#define OSf 4 // oversampling factor <=5, sonst Speicher voll!
+
+// int=2 ByteFRICKL FRICKL
+int scr[SCRdx][SCRdy]; // (real) screen
+int vscr[SCRdx*OSf][SCRdy*OSf]; // virtual (high res) screen
+
+#define CFONTwidth 0x5 // (font constant)
+#define CFONTwidth2 0x7 // with std space between chars std=7
+#define CFONTstart 0x20
+#define CFONTend 0x5b
+char cfont[]=
+{ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x20
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x21
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x22
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x23
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x24
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x25
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x26
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x27
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x28
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x29
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x2a
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x2b
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x2c
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x2d
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x2e
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x2f
+ //0x1e, 0x31, 0x29, 0x25, 0x1e, // 0x30 0
+ 0x1e, 0x21, 0x2d, 0x21, 0x1e, // 0x30 0
+ 0x00, 0x22, 0x3f, 0x20, 0x00, // 0x31 1
+ 0x22, 0x31, 0x29, 0x29, 0x26, // 0x32 2
+ 0x12, 0x21, 0x25, 0x25, 0x1a, // 0x33 3
+ 0x18, 0x14, 0x12, 0x3f, 0x10, // 0x34 4
+ 0x22, 0x25, 0x25, 0x25, 0x18, // 0x35 5
+ //0x1e, 0x29, 0x29, 0x29, 0x1a, // 0x36 6
+ 0x1e, 0x25, 0x25, 0x25, 0x18, // 0x36 6
+ 0x01, 0x01, 0x31, 0x0d, 0x03, // 0x37 7
+ 0x1a, 0x25, 0x25, 0x25, 0x1a, // 0x38 8
+ 0x06, 0x29, 0x29, 0x29, 0x1e, // 0x39 9
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x3a
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x3b
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x3c
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x3d
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x3e
+ 0x00, 0x00, 0x00, 0x00, 0x00, // 0x3f
+
+ 0x00, 0x00, 0x00, 0x00, 0x00, // SPACE (0x40 or 0x20)
+ 0x38, 0x16, 0x11, 0x16, 0x38, // A (0x41)
+ 0x3f, 0x25, 0x25, 0x26, 0x18, // B (0x42)
+ 0x1e, 0x21, 0x21, 0x21, 0x12, // C
+ 0x3f, 0x21, 0x21, 0x21, 0x1e, // D
+ 0x3f, 0x25, 0x25, 0x25, 0x21, // E
+ 0x3f, 0x05, 0x05, 0x05, 0x01, // F
+ 0x1e, 0x21, 0x21, 0x29, 0x1a, // G
+ 0x3f, 0x08, 0x08, 0x08, 0x3f, // H
+ 0x00, 0x21, 0x3f, 0x21, 0x00, // I
+ 0x00, 0x11, 0x21, 0x1f, 0x00, // J
+ 0x3f, 0x08, 0x14, 0x14, 0x22, // K
+ 0x3f, 0x20, 0x20, 0x20, 0x20, // L
+ 0x3f, 0x02, 0x0c, 0x02, 0x3f, // M
+ 0x3f, 0x02, 0x04, 0x08, 0x3f, // N
+ 0x1e, 0x21, 0x21, 0x21, 0x1e, // O
+ 0x3f, 0x09, 0x09, 0x09, 0x06, // P
+ 0x1e, 0x21, 0x29, 0x11, 0x2e, // Q
+ 0x3f, 0x09, 0x09, 0x19, 0x26, // R
+ 0x22, 0x25, 0x25, 0x25, 0x18, // S
+ 0x01, 0x01, 0x3f, 0x01, 0x01, // T
+ 0x1f, 0x20, 0x20, 0x20, 0x1f, // U
+ 0x03, 0x0c, 0x30, 0x0c, 0x03, // V
+ 0x3f, 0x10, 0x0c, 0x10, 0x3f, // W
+ 0x31, 0x0a, 0x04, 0x0a, 0x31, // X
+ 0x01, 0x02, 0x3c, 0x02, 0x01, // Y
+ 0x31, 0x29, 0x25, 0x23, 0x21, // Z
+};
+
+volatile int dummy;
+
+void setup()
+{ for (int i=0; i<NledPins; i++)
+ pinMode(ledPins[i], INPUT);
+}
+
+void vscr2scr()
+{ int x,y,xx,yy,xxx,yyy,sum;
+ for(x=0; x<SCRdx; x++)
+ { xxx=x*OSf;
+ for(y=0; y<SCRdy; y++)
+ { yyy=y*OSf;
+ sum=0;
+ for(xx=0; xx<OSf; xx++) for(yy=0; yy<OSf; yy++) sum+=vscr[xxx+xx][yyy+yy];
+ scr[x][y]=sum/OSf/OSf;
+ }
+ }
+}
+
+#define ANIMm (20)
+int lum2=0;
+void loop()
+{ newscr++;
+ if (newscr%(ANIMm)==0)
+ { //int p0=myoutstringpos/OSf;
+
+ //int p0=myoutstringpos/(OSf-1); // Zeichen nur (OSf-1)/OSf breit ausgeben
+ //int p0=myoutstringpos/(OSf-leaner); // Zeichen nur (OSf-1)/OSf breit ausgeben
+ int p0=myoutstringpos*42/100; // Zeichen nur (OSf-1)/OSf breit ausgeben
+
+ int p2=p0/CFONTwidth2;
+ char c=myoutstring[p2];
+ if (c==0) { myoutstringpos=0; p0=0; p2=p0/CFONTwidth2; c=myoutstring[p2]; }
+ int p1=p0%CFONTwidth2;
+ int bits=0;
+ if (c==0x20) c=0x40; // 0x40 is SPACE !
+ if (p1<CFONTwidth && c<CFONTend) bits=cfont[(c-CFONTstart)*CFONTwidth+p1];
+ for (int b=1, p=0; b<0x40 && p<OSf*6; b*=2, p+=OSf) if (bits&b)
+ for(y=0; y<OSf; y++) vscr[OSf*SCRdx-1][p+y]=256;
+ myoutstringpos++;
+
+ for(y=0; y<SCRdy*OSf; y++)
+ { for(x=0; x<SCRdx*OSf-1; x++) vscr[x][y]=vscr[x+1][y];
+ vscr[SCRdx*OSf-1][y]=0; // clear
+ }
+ vscr2scr();
+ }
+
+ lum+=16; if (lum>254) lum=0;
+
+ int xx=-1;
+ int yy=-1;
+ for (int y=0; y<NledPins; y++)
+ { digitalWrite(ledPins[y], LOW);
+ pinMode(ledPins[y], OUTPUT);
+ for (int x=0; x<NledPins; x++)
+ if (x==y)
+ { xx=(xx+1)%NledPins;
+ yy++;
+ }
+ else
+ { xx=(xx+1)%NledPins;
+ lum2= (lum2+23) & 0xFF;
+ //if (xx==0 && yy==0)
+ //if (xx==yy)
+ //if (scr[yy][xx]>lum2) // (real) screen
+ //if (scr[yy][xx]+48<lum2) // inverted
+ if (scr[yy][xx]-48 > lum2*13/16) // good for font scroll
+ { //digitalWrite(ledPins[x], LOW); // digitalWrite(ledPins[y], LOW); (ganz unten)
+ pinMode(ledPins[x], OUTPUT);
+ //for (int ll=0; ll!=10; ll++) for (int l=0; l!=0x7fff; l++) dummy=l;
+ for (int l=0; l!=0x80; l++) dummy=l;
+ pinMode(ledPins[x], INPUT);
+ }
+ }
+ pinMode(ledPins[y], INPUT);
+ digitalWrite(ledPins[y], HIGH);
+ }
+}