|
@ -1,10 +1,16 @@ |
|
|
|
|
|
|
|
|
#include "../config.h" |
|
|
#include "../config.h" |
|
|
#include <stdint.h> |
|
|
#include <stdint.h> |
|
|
#include "../random/prng.h" |
|
|
#include "../random/prng.h" |
|
|
#include "../pixel.h" |
|
|
#include "../pixel.h" |
|
|
#include "../util.h" |
|
|
#include "../util.h" |
|
|
|
|
|
|
|
|
|
|
|
#ifndef MATRIX_CYCLES |
|
|
|
|
|
#define MATRIX_CYCLES 500 |
|
|
|
|
|
#endif |
|
|
|
|
|
#ifndef MATRIX_STREAMER_NUM |
|
|
|
|
|
#define MATRIX_STREAMER_NUM 30 |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
typedef struct{ |
|
|
typedef struct{ |
|
|
pixel start; |
|
|
pixel start; |
|
@ -31,8 +37,8 @@ inline static void set_bright(pixel_matrix_t *matrix, uint8_t x, uint8_t y, uint |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void matrix() { |
|
|
void matrix() { |
|
|
unsigned int counter = 500; /* run 500 cycles */ |
|
|
unsigned int counter = MATRIX_CYCLES; |
|
|
streamer streamers[STREAMER_NUM]; |
|
|
streamer streamers[MATRIX_STREAMER_NUM]; |
|
|
pixel_matrix_t matrix_bright; |
|
|
pixel_matrix_t matrix_bright; |
|
|
unsigned char x, y; |
|
|
unsigned char x, y; |
|
|
unsigned char index = 0; |
|
|
unsigned char index = 0; |
|
@ -45,10 +51,10 @@ void matrix() { |
|
|
for(x=0;x<NUM_COLS;x++) |
|
|
for(x=0;x<NUM_COLS;x++) |
|
|
for(y=0;y<NUM_ROWS/4;y++) |
|
|
for(y=0;y<NUM_ROWS/4;y++) |
|
|
matrix_bright[x][y]=0; |
|
|
matrix_bright[x][y]=0; |
|
|
|
|
|
|
|
|
for(i=0;i<streamer_num;i++){ |
|
|
for(i=0;i<streamer_num;i++){ |
|
|
streamer str = streamers[i]; |
|
|
streamer str = streamers[i]; |
|
|
|
|
|
|
|
|
unsigned char bright = 0xFF; draw = 0; |
|
|
unsigned char bright = 0xFF; draw = 0; |
|
|
for(j=(str.len/8);j!=0xFF;j--){ /* Draw streamer */ |
|
|
for(j=(str.len/8);j!=0xFF;j--){ /* Draw streamer */ |
|
|
if(j+str.start.y<NUM_ROWS){ |
|
|
if(j+str.start.y<NUM_ROWS){ |
|
@ -56,12 +62,12 @@ void matrix() { |
|
|
draw = 1; |
|
|
draw = 1; |
|
|
if(bright > (get_bright(&matrix_bright, str.start.x, str.start.y+j)<<6) ){ |
|
|
if(bright > (get_bright(&matrix_bright, str.start.x, str.start.y+j)<<6) ){ |
|
|
set_bright(&matrix_bright, str.start.x, str.start.y+j, bright>>6); |
|
|
set_bright(&matrix_bright, str.start.x, str.start.y+j, bright>>6); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
bright-=((bright>>5)*str.decay); |
|
|
bright-=((bright>>5)*str.decay); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
str.len+=str.speed/2; |
|
|
str.len+=str.speed/2; |
|
|
streamers[i] = str; |
|
|
streamers[i] = str; |
|
|
if(!draw){ |
|
|
if(!draw){ |
|
@ -70,25 +76,25 @@ void matrix() { |
|
|
} |
|
|
} |
|
|
streamer_num--; |
|
|
streamer_num--; |
|
|
i--; |
|
|
i--; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for(y=NUM_ROWS;y--;) |
|
|
for(y=NUM_ROWS;y--;) |
|
|
for(x=NUM_COLS;x--;){ |
|
|
for(x=NUM_COLS;x--;){ |
|
|
setpixel((pixel){x,y}, get_bright(&matrix_bright,x,y)); |
|
|
setpixel((pixel){x,y}, get_bright(&matrix_bright,x,y)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
unsigned char nsc; |
|
|
unsigned char nsc; |
|
|
for(nsc=0;nsc<6;nsc++){ |
|
|
for(nsc=0;nsc<6;nsc++){ |
|
|
if(streamer_num<STREAMER_NUM){ |
|
|
if(streamer_num<MATRIX_STREAMER_NUM){ |
|
|
unsigned char sy = random8()%(2*NUM_ROWS); |
|
|
unsigned char sy = random8()%(2*NUM_ROWS); |
|
|
if (sy>NUM_ROWS-1) sy=0; |
|
|
if (sy>NUM_ROWS-1) sy=0; |
|
|
streamers[streamer_num] = (streamer){{random8()%NUM_COLS, sy}, 0, (random8()%8)+12, index++,(random8()%16)+3}; |
|
|
streamers[streamer_num] = (streamer){{random8()%NUM_COLS, sy}, 0, (random8()%8)+12, index++,(random8()%16)+3}; |
|
|
streamer_num++; |
|
|
streamer_num++; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
wait(60); |
|
|
wait(60); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|