2 * LED Matrix library for http://www.seeedstudio.com/depot/ultrathin-16x32-red-led-matrix-panel-p-1582.html
3 * The LED Matrix panel has 32x16 pixels. Several panel can be combined together as a large screen.
5 * Coordinate & Connection (Arduino -> panel 0 -> panel 1 -> ...)
7 * +--------+--------+--------+ +--------+--------+
8 * | 5 | 4 | 3 | | 1 | 0 |
9 * | | | | | | |<----- Arduino
10 * +--------+--------+--------+ +--------+--------+
11 * | 2 | 1 | 0 | (64, 16)
12 * | | | |<----- Arduino
13 * +--------+--------+--------+
20 #include <avr/pgmspace.h>
21 #include "LEDMatrix.h"
24 #define WIDTH 64*1 // 2 panels * 64
27 // LEDMatrix(a, b, c, d, oe, r1, stb, clk);
28 LEDMatrix matrix(4, 5, 6, 7, 9, 11, 10, 13);
30 // Display Buffer 128 = 64 * 16 / 8
31 uint8_t displaybuf[WIDTH * HEIGHT / 8];
33 uint8_t displaybuf_w[((WIDTH/8)+1) * HEIGHT];
38 void MatrixWriteCharacter(int x,int y, char character)
42 //Serial.println(character);
44 for(int i=0; i<8; i++) {
45 uint8_t *pDst = displaybuf_w + (i+y) * ((WIDTH / 8) + 1) + x ;
46 *pDst = (font_8x8[character - 0x20][i]);
49 for(int i=0; i<16; i++) {
50 cell[i] = pgm_read_byte_near(&font_8x16[(character - 0x20)][i]);
53 //uint8_t *pDst = displaybuf_w + (y) * ((WIDTH / 8) + 1) + x ;
54 uint8_t *pDst = displaybuf_w + x ;
57 for(int j=0; j<8; j++) {
60 for(int i=0; i<8; i++) {
62 if ( cell[i] & mask ) {
73 for(int j=0; j<8; j++) {
75 for(int i=8; i<16; i++) {
77 if ( cell[i] & mask ) {
91 void matrixPrint(String c) {
94 //Serial.println(c.length());
95 for (int i=0 ; i<c.length() ; i++) {
96 MatrixWriteCharacter(i,3,c[i]);
99 //Serial.print(" -> ");
100 //Serial.println(c[i]);
107 matrix.begin(displaybuf, WIDTH, HEIGHT);
110 //matrixPrint("12345678");
111 // uint8_t *pDst = displaybuf + y * (WIDTH / 8) + x / 8;
112 memset(displaybuf_w, 0, sizeof(displaybuf_w));
115 void matrixDelay(int x) {
116 for (int y=0; y<x; y++) { matrix.scan(); }
120 String poruka="X XX XOX XOOX XOoOX XOooOX XOoIoOX XOoiioOX ";
121 //String poruka=" Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras blandit libero id ex dapibus suscipit. Proin vitae cursus eros. Ut porttitor congue metus at viverra. In consectetur ex massa.";
125 for (int p=0; p<poruka.length() ; p++) {
126 matrixPrint(poruka.substring(p,p+(WIDTH/8)+1));
127 for (int o=0; o<8; o++) {
128 uint8_t *src = displaybuf_w;
129 uint8_t *dest = displaybuf;
132 for (int y = 0; y < HEIGHT; y++ ) {
133 for (int x = 0; x < (WIDTH/8); x++) {
134 *(dest + i) = ( *(src + j) << o ) | (( *(src + j + 1) & ( 0xff << 8 - o ) ) >> 8 - o );
140 if ( x == 0 ) matrix.scan();
143 j++; // skip off-screen character used for smooth scroll