I'm trying to figure out some POV code. The program takes a color image and displays it, in color on a moving string of LED (for POV). What I can't figure out is how it determines the colors. So, when it processes an image, it outputs the following:
prog_uchar image1[] PROGMEM = {
0x74,0x54,0x2C,0x5E,0x2A,0x00,0x2A,0x5E,0x5E,0x5E,0x7E,0x2A,0x02,0x2A ...};
Then, in the processing code, I see this:
// mask to select 2 bits of color
#define TLEDS 48
#define Rmask 0x60
#define Gmask 0x18
#define Bmask 0x06
uint16_t i,j,k;
uint8_t Gtmp, Rtmp, Btmp;
...
Gtmp = 0;
Rtmp = 0;
Btmp = 0;
...
SPDR = Gtmp;
Gtmp = 0x80 | (uint32_t)((pgm_read_byte_near(&image1[i+j*TLEDS])) & Rmask);
while(!(SPSR & (1<<SPIF)));
SPDR = Rtmp;
Rtmp = 0x80 | ((uint32_t)((pgm_read_byte_near(&image1[i+j*TLEDS])) & Gmask) << 2);
while(!(SPSR & (1<<SPIF)));
SPDR = Btmp;
Btmp = 0x80 | ((uint32_t)((pgm_read_byte_near(&image1[i+j*TLEDS])) & Bmask) << 4);
while(!(SPSR & (1<<SPIF)));
...
Specifically, I'm interested in learning how the colors are figured out. I don't understand the masking part, R = 0x60, G = 0x18, B = 0x06 and then later in the for loop, how each color is set using the data from image1[] and the mask. I don't understand what the data in the image1[] array represents, I'm assuming a color value.
Can someone explain this in layman's terms to me please?