Hi! I want to make an impressive display that I will hang on the wall. When I am finished I hope to have a 32x(16-24)LED display that I hope to someday implement Pong on as well as a visualization to sounds the arduino picks up. Right now I am in the beginning stages of just figuring everything out. I'm currently experimenting on an Arduino Uno and 3 8x8 displays, the program I'm writing I want to one day scale up to the Arduino Mega 2560 and the 32x(16-24) array of LEDs. I will also eventually move away from 74HC595 shift registers in favor of TLC5940 LED drivers.
Right now I am stuck trying to have my program take a string, eventually through USART, then map each string character to the proper bitmap. The program writes to the display by turning on the first (bottom of picture) shift register which is the current source to the rows. The bitmap bytes are loaded into the top registers, which are sinking current, and turn on (actually off, so they can sink current) the columns.
Below are some of Bitmap examples. They are loaded into the column registers. The values are opposite what you would expect because they are sinking current. Therefor, to turn an LED on, a 0 instead of a 1 is written.
const prog_uint8_t Smiley[8] = {
B11111111,
B10111011,
B11111111,
B11101111,
B11111111,
B10111011,
B11000111,
B11111111
};
const prog_uint8_t ltrA[8] = {
B11111111,
B11101111,
B11010111,
B10111011,
B10111011,
B10000011,
B10111011,
B10111011
};
const prog_uint8_t ltrB[8] = {
B11111111,
B10000111,
B10111011,
B10111011,
B10000111,
B10111011,
B10111011,
B10000111
};
const prog_uint8_t ltrC[8] = {
B11111111,
B11000111,
B10111011,
B10111111,
B10111111,
B10111011,
B11000111,
B11111111
};
Here is the main code:
int main()
{
init();
zshift.init();
uint32_t last_Tcount;
uint16_t Period = 1500;
while(1)
{
last_Tcount = millis() + Period;
while( last_Tcount >= millis() )
{
zshift.Shift(ltrH, ltrI, Smiley);
}
last_Tcount = millis() + Period;
while( last_Tcount >= millis() )
{ /* THIS IS THE PROBLEM INSTRUCTION BELOW */
zshift.Shift(Smiley, &Alphabet[0], ltrA);
}
}
}
The Shift out to registers code:
void zShiftClass::Shift( const uint8_t disp3[], const uint8_t disp2[], const uint8_t disp1[])
{
for (uint8_t y = 0 ; y < 8 ; y++ ) //For each byte row in the Bitmap
{
uint8_t Registers[] = { disp1[y] , disp2[y] , disp3[y] , 1<<y }; //Byte array of bytes to shift out
LATCH;
for ( uint8_t i = 0; i <= 3 ; i++) //repeat 3 times for each display before latching
{
uint8_t Byte = Registers[i];
zshift.Shift8(Byte);
}
unLATCH;
}
}
void zShiftClass::Shift8(uint8_t value) //shifts out 8 bits at a time
{
for (uint8_t i = 0; i <= 7; i++)
{
if( !!(value&(1<<i)) == true) //If value is not a 1, turn off MOSIMASK
{ SPIPINPORT |= MOSIMASK; }
else
{ SPIPINPORT &= ~MOSIMASK; }
PULSE; //Pulse the Clock
}
}
In order to map a character to the proper bitmap, I figure I need something that will work like below. However, this won't work because I get, "Error: value of type "const prog_uint8_t*" cannot be assigned to an entity of type "uint8_t*" "
uint8_t* Bitmaps::char2bits(uint8_t val) //Character to Proper Segments to light
{
uint8_t* bytes;
if ( val == 'A' ) { bytes = ltrA ; }
else if ( val == 'B' ) { bytes = ltrB; }
else if ( val == 'C' ) { bytes = ltrC; }
.....etc......
return bytes;
}
Because that don't work, I tried a different strategy. I tried to create an array that included the bitmap arrays as subarrays??
const uint8_t Alphabet[] = {
*ltrA , *ltrB, *ltrC
};
This way I was hoping I could call on the letters like so:
uint8_t* Bitmaps::char2bits(uint8_t val) //Character to Proper Segments to light
{
uint8_t* bytes;
if ( val == 'A' ) { bytes = Alphabet[0] ; }
else if ( val == 'B' ) { bytes = Alphabet[1]; }
else if ( val == 'C' ) { bytes = Alphabet[2]; }
.....etc......
return bytes;
But of course that's not working, and before even getting to that more complicated part I tried the instruction below in the main loop to test if I could even call a bitmap using the array properly.
zshift.Shift(Smiley, &Alphabet[0], ltrA);
I was hoping that the &Alphabet[0] would return the ltrA bitmap then display it just as it is displayed on display 3 using the ltrA command next to it. Also, I have no idea if the pointers are right, the combination of pointers I have now was by trial and error to get it to compile successfully.
So using the above command, instead of ltrA being displayed on display 2, I get scrambled stuff:
Does anyone know how to accomplish this? I'm stumped.