Step 7Draw a frame
unsigned char green_vals[][8] PROGMEM = { { 0x01, 0xff, 0x80, 0xff, etc...unsigned char red_vals[][8] PROGMEM = { { 0x01, 0x02, 0x03, 0x04, etc...remember that the matrix is only 8 leds across, meaning that each entry in those arrays corresponds to a complete description of an entire row. so looping through 8 of them in succession is a frame...
for (i=0; i<8; i++){ set_frame( red_vals[ 0 ][ i ], green_vals[ 0 ][ i ], (1<<i) ); show_frame( TIME_TO_SHOW_LINE );}except that won't work, because of PROGMEM up there... just call pgm_read_byte() on red_vals and green_vals to fix it.
set_frame( pgm_read_byte( &red_vals[ 0 ][ i ] ), pgm_read_byte( &green_vals[ 0 ][ i ] ), (1<<i) );
the set_frame() function is pretty simple:
/* send frame line data to shift registers and set appropriate grounder pin */void set_frame ( unsigned char red, unsigned char green, unsigned char gnd ){ /* just a loop variable */ unsigned char i = 0; /* set up red, loop through all 8 bits */ for (i=0; i<8; i++) { if ( red & (1<<i) ) PORTB |= red_ser; // if it's a one then serial pin hi else PORTB &= ~red_ser; // otherwise make sure it's low if ( green & (1<<i) ) PORTB |= green_ser; // if it's a one then pin hi else PORTB &= ~green_ser; // otherwise make sure it's low PORTB |= ser_sck; // clock up PORTB &= ~ser_sck; // clock down } PORTB &= ~red_ser; // be sure to leave red's ser line low PORTB &= ~green_ser; // leave green serial pin low /* set the grounder pin for this frame line to low */ PORTD = ~gnd; // upsidedown logic... }| « Previous Step | Download PDFView All Steps | Next Step » |
![]() |
Add Comment
|










































