diff options
author | Nils Schneider <nils.schneider@gmail.com> | 2011-11-06 19:07:23 +0100 |
---|---|---|
committer | Nils Schneider <nils.schneider@gmail.com> | 2011-11-06 19:07:23 +0100 |
commit | d79e7340e8b21fea4b0c28236314a5025879af50 (patch) | |
tree | a48a10d42db33a198c8efc540e8659b38964b716 /Matrix_5x6 | |
parent | ee190ae483edf7ebf5d27a698054ea71daf1779f (diff) | |
download | ledmatrix-d79e7340e8b21fea4b0c28236314a5025879af50.tar ledmatrix-d79e7340e8b21fea4b0c28236314a5025879af50.zip |
framebuffer + fading
Diffstat (limited to 'Matrix_5x6')
-rw-r--r-- | Matrix_5x6/Charlie/Charlie.pde | 84 |
1 files changed, 75 insertions, 9 deletions
diff --git a/Matrix_5x6/Charlie/Charlie.pde b/Matrix_5x6/Charlie/Charlie.pde index a0d2b73..ee7f5dd 100644 --- a/Matrix_5x6/Charlie/Charlie.pde +++ b/Matrix_5x6/Charlie/Charlie.pde @@ -11,19 +11,85 @@ charliePin ledi[] = { {0, 1} , {1, 0} , {2, 0} , {3, 0} , {4, 0} , {5, 0}, {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*/ } -void loop(){ - int i; - for (i=0; i<30; i++){ - charlieplex.charlieWrite(ledi[i],HIGH); - delay(an); - charlieplex.clear(); - delay(aus); - } - +void zufall_fading() { + clrscr(); + int x, y; + for (x=0; x<6; x++) + for (y=0; y<5; y++) + scr[x][y] = random(30) + 2; + + int i=30; + + while (i--) { + drawscr(2); + fadescr_down(); + } + +} + +void zufall_fading2() { + clrscr(); + int x, y; + for (x=0; x<6; x++) + for (y=0; y<5; y++) + scr[x][y] = - random(30) - 2; + + int i=50; + + while (i--) { + drawscr(2); + fadescr_up(); + } + + +} +void loop() { + zufall_fading2(); } |