Skip to content

Commit

Permalink
added code for one line led display
Browse files Browse the repository at this point in the history
  • Loading branch information
guyzmo committed May 8, 2012
1 parent 962b41b commit df227e5
Showing 1 changed file with 230 additions and 0 deletions.
230 changes: 230 additions & 0 deletions LeLoopOneLineLedDisplay.pde
@@ -0,0 +1,230 @@
/* Le Loop Dumped LedMatrix code controller
* this code is adapted to a 1987 led matrix display based on 4094 8bit shifters and darlington arrays
*
*/

// 76x8

#define OE 2 // GRAY OUTPUT ENABLE
#define DATA 4 // PINK DATA
#define STR 6 // ORANGE STROBE
#define CLK 8 // YELLOW CLOCK

#define DELAY 0

const uint8_t Fond5x7_nbchar = 96;
const uint8_t Font5x7_nbcols = 5;
const uint8_t Font5x7_nblines = 7;

const uint8_t Font5x7[96][5] = {
0x00, 0x00, 0x00, 0x00, 0x00,// (space) 32
0x00, 0x00, 0x5F, 0x00, 0x00,// ! 33
0x00, 0x07, 0x00, 0x07, 0x00,// " 34
0x14, 0x7F, 0x14, 0x7F, 0x14,// # 35
0x24, 0x2A, 0x7F, 0x2A, 0x12,// $ 36
0x23, 0x13, 0x08, 0x64, 0x62,// % 37
0x36, 0x49, 0x55, 0x22, 0x50,// & 38
0x00, 0x05, 0x03, 0x00, 0x00,// ' 39
0x00, 0x1C, 0x22, 0x41, 0x00,// ( 40
0x00, 0x41, 0x22, 0x1C, 0x00,// ) 41
0x08, 0x2A, 0x1C, 0x2A, 0x08,// * 42
0x08, 0x08, 0x3E, 0x08, 0x08,// + 43
0x00, 0x50, 0x30, 0x00, 0x00,// , 44
0x08, 0x08, 0x08, 0x08, 0x08,// - 45
0x00, 0x60, 0x60, 0x00, 0x00,// . 46
0x20, 0x10, 0x08, 0x04, 0x02,// / 47
0x3E, 0x51, 0x49, 0x45, 0x3E,// 0 48
0x00, 0x42, 0x7F, 0x40, 0x00,// 1 49
0x42, 0x61, 0x51, 0x49, 0x46,// 2 50
0x21, 0x41, 0x45, 0x4B, 0x31,// 3 51
0x18, 0x14, 0x12, 0x7F, 0x10,// 4 52
0x27, 0x45, 0x45, 0x45, 0x39,// 5 53
0x3C, 0x4A, 0x49, 0x49, 0x30,// 6 54
0x01, 0x71, 0x09, 0x05, 0x03,// 7 55
0x36, 0x49, 0x49, 0x49, 0x36,// 8 56
0x06, 0x49, 0x49, 0x29, 0x1E,// 9 57
0x00, 0x36, 0x36, 0x00, 0x00,// : 58
0x00, 0x56, 0x36, 0x00, 0x00,// ; 59
0x00, 0x08, 0x14, 0x22, 0x41,// < 60
0x14, 0x14, 0x14, 0x14, 0x14,// = 61
0x41, 0x22, 0x14, 0x08, 0x00,// > 62
0x02, 0x01, 0x51, 0x09, 0x06,// ? 63
0x32, 0x49, 0x79, 0x41, 0x3E,// @ 64
0x7E, 0x11, 0x11, 0x11, 0x7E,// A 65
0x7F, 0x49, 0x49, 0x49, 0x36,// B 66
0x3E, 0x41, 0x41, 0x41, 0x22,// C 67
0x7F, 0x41, 0x41, 0x22, 0x1C,// D 68
0x7F, 0x49, 0x49, 0x49, 0x41,// E 69
0x7F, 0x09, 0x09, 0x01, 0x01,// F 70
0x3E, 0x41, 0x41, 0x51, 0x32,// G 71
0x7F, 0x08, 0x08, 0x08, 0x7F,// H 72
0x00, 0x41, 0x7F, 0x41, 0x00,// I 73
0x20, 0x40, 0x41, 0x3F, 0x01,// J 74
0x7F, 0x08, 0x14, 0x22, 0x41,// K 75
0x7F, 0x40, 0x40, 0x40, 0x40,// L 76
0x7F, 0x02, 0x04, 0x02, 0x7F,// M 77
0x7F, 0x04, 0x08, 0x10, 0x7F,// N 78
0x3E, 0x41, 0x41, 0x41, 0x3E,// O 79
0x7F, 0x09, 0x09, 0x09, 0x06,// P 80
0x3E, 0x41, 0x51, 0x21, 0x5E,// Q 81
0x7F, 0x09, 0x19, 0x29, 0x46,// R 82
0x46, 0x49, 0x49, 0x49, 0x31,// S 83
0x01, 0x01, 0x7F, 0x01, 0x01,// T 84
0x3F, 0x40, 0x40, 0x40, 0x3F,// U 85
0x1F, 0x20, 0x40, 0x20, 0x1F,// V 86
0x7F, 0x20, 0x18, 0x20, 0x7F,// W 87
0x63, 0x14, 0x08, 0x14, 0x63,// X 88
0x03, 0x04, 0x78, 0x04, 0x03,// Y 89
0x61, 0x51, 0x49, 0x45, 0x43,// Z 90
0x00, 0x00, 0x7F, 0x41, 0x41,// [ 91
0x02, 0x04, 0x08, 0x10, 0x20,// "\" 92
0x41, 0x41, 0x7F, 0x00, 0x00,// ] 93
0x04, 0x02, 0x01, 0x02, 0x04,// ^ 94
0x40, 0x40, 0x40, 0x40, 0x40,// _ 95
0x00, 0x01, 0x02, 0x04, 0x00,// ` 96
0x20, 0x54, 0x54, 0x54, 0x78,// a 97
0x7F, 0x48, 0x44, 0x44, 0x38,// b 98
0x38, 0x44, 0x44, 0x44, 0x20,// c 99
0x38, 0x44, 0x44, 0x48, 0x7F,// d 100
0x38, 0x54, 0x54, 0x54, 0x18,// e 101
0x08, 0x7E, 0x09, 0x01, 0x02,// f 102
0x08, 0x14, 0x54, 0x54, 0x3C,// g 103
0x7F, 0x08, 0x04, 0x04, 0x78,// h 104
0x00, 0x44, 0x7D, 0x40, 0x00,// i 105
0x20, 0x40, 0x44, 0x3D, 0x00,// j 106
0x00, 0x7F, 0x10, 0x28, 0x44,// k 107
0x00, 0x41, 0x7F, 0x40, 0x00,// l 108
0x7C, 0x04, 0x18, 0x04, 0x78,// m 109
0x7C, 0x08, 0x04, 0x04, 0x78,// n 110
0x38, 0x44, 0x44, 0x44, 0x38,// o 111
0x7C, 0x14, 0x14, 0x14, 0x08,// p 112
0x08, 0x14, 0x14, 0x18, 0x7C,// q 113
0x7C, 0x08, 0x04, 0x04, 0x08,// r 114
0x48, 0x54, 0x54, 0x54, 0x20,// s 115
0x04, 0x3F, 0x44, 0x40, 0x20,// t 116
0x3C, 0x40, 0x40, 0x20, 0x7C,// u 117
0x1C, 0x20, 0x40, 0x20, 0x1C,// v 118
0x3C, 0x40, 0x30, 0x40, 0x3C,// w 119
0x44, 0x28, 0x10, 0x28, 0x44,// x 120
0x0C, 0x50, 0x50, 0x50, 0x3C,// y 121
0x44, 0x64, 0x54, 0x4C, 0x44,// z 122
0x00, 0x08, 0x36, 0x41, 0x00,// { 123
0x00, 0x00, 0x7F, 0x00, 0x00,// | 124
0x00, 0x41, 0x36, 0x08, 0x00,// } 125
// EXTRA CHARS
0x08, 0x08, 0x2A, 0x1C, 0x08,// ->
0x08, 0x1C, 0x2A, 0x08, 0x08 // <-
};

class LeLoopMatrix {
private:
int matrix[8][72];

void tick_clock() {
digitalWrite(CLK,LOW);
delay(DELAY);
digitalWrite(CLK,HIGH);
delay(DELAY);
}

public:
void setup() {
pinMode(STR, OUTPUT); // ORANGE (STROBE)
pinMode(CLK, OUTPUT); // YELLOW (CLK)
pinMode(OE, OUTPUT); // GRAY (OUTPUT ENABLE)
pinMode(DATA, OUTPUT); // PINK (DATA)
// default values
digitalWrite(2, HIGH);
digitalWrite(4, LOW);
digitalWrite(6, HIGH);
digitalWrite(8, HIGH);
// reset buffer
reset_matrix();
}

void reset_matrix() {
for (int i=0;i<8;++i)
for (int j=0;j<72;++j)
matrix[i][j] = 0;
}

void set_pixel(int i, int j, int val) {
matrix[i][j] = val;
}

void display() {
for (int i=71;i!=0;--i) {
for (int j=0;j<8;++j) {
if (matrix[j][i]!=0) {
Serial.print("#");
digitalWrite(DATA,HIGH);
tick_clock();
} else {
Serial.print("_");
digitalWrite(DATA,LOW);
tick_clock();
}
}
Serial.println(" ");
}
}

void display(char c) {
if (c >= 32 && c <= 127) {
for (int col=0;col<5;++col) {
Serial.print('.');
for (int mask=(1<<6);mask>0;mask>>=1) {
if ((Font5x7[c-32][col]&mask) != 0) {
Serial.print("#");
digitalWrite(DATA,HIGH);
tick_clock();
} else {
Serial.print("_");
digitalWrite(DATA,LOW);
tick_clock();
}
}
Serial.print(".");
digitalWrite(DATA,LOW);
tick_clock();
Serial.println();
}
for (int i=0;i<8;++i) {
digitalWrite(DATA,LOW);
tick_clock();
}
}
Serial.println();
}
} leloop_matrix;

class SerialUpdater {
private:
LeLoopMatrix* matrix;

public:
void setup(LeLoopMatrix* disp) {
Serial.begin(9600);
Serial.println("coin");
matrix = disp;
}

void update_buffer() {
while (Serial.available()) {
char c = Serial.read();
matrix->display(c);
}

}

} serial_updater;

void setup () {
serial_updater.setup(&leloop_matrix);
leloop_matrix.setup();
leloop_matrix.display();
}

void loop () {
serial_updater.update_buffer();
}

0 comments on commit df227e5

Please sign in to comment.