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"
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] = {
32 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33 0x01, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x01, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60,
34 0x01, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0xE0, 0x07, 0x8F, 0xC7, 0xC7, 0xC7, 0xE0,
35 0x00, 0x40, 0x0C, 0xCE, 0x6C, 0x6C, 0x6C, 0xE0, 0x00, 0xE0, 0x0C, 0x0C, 0x6C, 0x6C, 0x6C, 0x60,
36 0x01, 0xF0, 0x07, 0x8C, 0x6F, 0xEF, 0xEC, 0x60, 0x23, 0xF8, 0x00, 0xCC, 0x6C, 0x0C, 0x0C, 0x60,
37 0x33, 0xF8, 0x0C, 0xCE, 0x6C, 0x6C, 0x6C, 0xE0, 0x3B, 0xF8, 0x07, 0x8F, 0xC7, 0xC7, 0xC7, 0xE0,
38 0x3B, 0xF8, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x1B, 0xF8, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00,
39 0x0B, 0xF8, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x07, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 uint8_t displaybuf_w[((WIDTH/8)+1) * HEIGHT];
47 void MatrixWriteCharacter(int x,int y, char character)
51 //Serial.println(character);
53 for(int i=0; i<8; i++) {
54 uint8_t *pDst = displaybuf_w + (i+y) * ((WIDTH / 8) + 1) + x ;
55 *pDst = (font_8x8[character - 0x20][i]);
58 for(int i=0; i<16; i++) {
59 cell[i] = pgm_read_byte_near(&font_8x16[(character - 0x20)][i]);
62 //uint8_t *pDst = displaybuf_w + (y) * ((WIDTH / 8) + 1) + x ;
63 uint8_t *pDst = displaybuf_w + x ;
66 for(int j=0; j<8; j++) {
69 for(int i=0; i<8; i++) {
71 if ( cell[i] & mask ) {
82 for(int j=0; j<8; j++) {
84 for(int i=8; i<16; i++) {
86 if ( cell[i] & mask ) {
100 void matrixPrint(String c) {
103 //Serial.println(c.length());
104 for (int i=0 ; i<c.length() ; i++) {
105 MatrixWriteCharacter(i,3,c[i]);
108 //Serial.print(" -> ");
109 //Serial.println(c[i]);
116 matrix.begin(displaybuf, WIDTH, HEIGHT);
119 //matrixPrint("12345678");
120 // uint8_t *pDst = displaybuf + y * (WIDTH / 8) + x / 8;
121 memset(displaybuf_w, 0, sizeof(displaybuf_w));
124 void matrixDelay(int x) {
125 for (int y=0; y<x; y++) { matrix.scan(); }
133 // String poruka="X XX XOX XOOX XOoOX XOooOX XOoIoOX XOoiioOX ";
134 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.";
136 for (int p=0; p<poruka.length() ; p++) {
138 matrixPrint(poruka.substring(p,p+9));
139 for (int o=0; o<8; o++) {
140 uint8_t *src = displaybuf_w;
141 uint8_t *dest = displaybuf;
144 for (int y = 0; y < HEIGHT; y++ ) {
145 for (int x = 0; x < (WIDTH/8); x++) {
146 *(dest + i) = ( *(src + j) << o ) | (( *(src + j + 1) & ( 0xff << 8 - o ) ) >> 8 - o );