#include #include "font.h" /* Feartures: * "Framebuffer" * Schnecke * Fading * Laufschrift */ /* TODO: * Ameise * Game of Life * Schönere Schrift (-variaten) */ #define NUMBER_OF_PINS 6 byte pins[] = {2,3,4,5,6,7}; Charlieplex charlieplex = Charlieplex(pins,NUMBER_OF_PINS); charliePin ledi[] = { {0, 1} , {1, 0} , {2, 0} , {3, 0} , {4, 0} , {5, 0}, {0, 2} , {1, 2} , {2, 1} , {3, 1} , {4, 1} , {5, 1}, {0, 3} , {1, 3} , {2, 3} , {3, 2} , {4, 2} , {5, 2}, {0, 4} , {1, 4} , {2, 4} , {3, 4} , {4, 3} , {5, 3}, {0, 5} , {1, 5} , {2, 5} , {3, 5} , {4, 5} , {5, 4}, }; int scr[6][5]; void clrscr() { int x, y; for (x=0; x<6; x++) for (y=0; y<5; y++) scr[x][y] = 0; } void drawscr(int c) { int x, y; int s; while (c--) { s = 20; while(s--) for (x=0; x<6; x++) for (y=0; y<5; y++) { charlieplex.charlieWrite(ledi[x+y*6], scr[x][y]>s?HIGH:LOW); charlieplex.clear(); } } } void fadescr_down() { int x, y; for (x=0; x<6; x++) for (y=0; y<5; y++) if (scr[x][y]) scr[x][y] -= 1; } void fadescr_up() { int x, y; for (x=0; x<6; x++) for (y=0; y<5; y++) if (scr[x][y] < 30) scr[x][y] += 1; } int an = 2; int aus = 10; void setup(){ /*nothing*/ } /* zufällige LEDs werden langsam dunkler */ void zufall_fading_down() { clrscr(); int x, y; for (x=0; x<6; x++) for (y=0; y<5; y++) scr[x][y] = random(30); int i=30; while (i--) { drawscr(2); fadescr_down(); } } /* zufällige LEDs werden langsam heller */ void zufall_fading_up() { clrscr(); int x, y; for (x=0; x<6; x++) for (y=0; y<5; y++) scr[x][y] = - random(30); int i=50; while (i--) { drawscr(2); fadescr_up(); } } /* schnecke mit vier startpunkten (0 bis 3) von außen nach innnen mit fading */ void schnecke(int s) { clrscr(); int x, y, d, w = 0; d = s; switch(s) { case 0: x = 0; y = 0; break; case 1: x = 5; y = 0; break; case 2: x = 5; y = 4; break; case 3: x = 0; y = 4; break; } int i; i = 0; while (1) { i++; if (scr[x][y]) break; scr[x][y] = w?20:i+5; drawscr(2); fadescr_down(); switch (d) { case 0: if (x == 5 - w) {d = 1; if (s == 2) w++;} break; case 1: if (y == 4 - w) {d = 2; if (s == 3) w++;} break; case 2: if (x == w) {d = 3; if (s == 0) w++;} break; case 3: if (y == w) {d = 0; if (s == 1) w++;} break; } switch (d) { case 0: x++; break; case 1: y++; break; case 2: x--; break; case 3: y--; break; } } i = 20; while(i--) { fadescr_down(); drawscr(2); } } void shift_scr_left() { int x, y; for (x=0; x<5; x++) for (y=0; y<5; y++) scr[x][y] = scr[x+1][y]; } void lauftext(char *text) { byte c; byte *f; int x, y; x = 5; int i; while (c = *(text++)) { i = 6; while (i--) { if (c > 0x40 && c < 0x5B) { // Buchstaben f = &(font_chars[c-0x41][0]); } else if (c >= 0x30 && c < 0x3A) { // Zahlen f = &(font_numbers[c-0x20][0]); } else if (c == ' ') // Leerzeichen f = &(font_space[0][0]); else if (c == '#') // Füllzeichen f = &(font_block[0][0]); for (y=0; y<5; y++) { scr[x][4-y] = (*(f+y)>>(i+1)&1) * 20; } drawscr(5); if (x > 4) { shift_scr_left(); } else x++; } } } void loop() { // zufall_fading_up(); // zufall_fading_down(); zufall_fading_up(); lauftext(" META MEUTE#"); zufall_fading_down(); schnecke(random(4)); }