mortonkopf
Well-known member
Hello there, this was originally posted in the thread on FastSpi as I could not see the 'post new thread' button, right in front of me. I have now deleted it from there.
I have put together a short adapted piece of code using octows2811 to manage scrolling text by using an index array for alphabet characters. The code just uses a text string as input, grabs the characters in turn, uses the alphabet 2D array to return Hex values describing the column of leds being either on or off, and then movs the whole array on one.
the nuts and bolt are:
The pix array just sets out the starting location for the first column of leds (the right hand most location).
The 2D array array[][] is a way of housing the pixel/led reference numbers.
the alphabet array is the usual 2D situation, and uses one I found online. Really sorry, but cant find it again to be able to give credit where it is due:
I think that the original code using digital write for pins came from here: http://arduino.cc/forum/index.php/topic,8672.0.html
there is a vid at http://orchardelica.com/wp/
any comments on optimising code would be appreciated.
mortonkopf
I have put together a short adapted piece of code using octows2811 to manage scrolling text by using an index array for alphabet characters. The code just uses a text string as input, grabs the characters in turn, uses the alphabet 2D array to return Hex values describing the column of leds being either on or off, and then movs the whole array on one.
the nuts and bolt are:
Code:
////Start of message setup////
char msg[] = "Hi, this is a test for OctoWS2811. Scrolling text using a character lookup table for alphabet. # $ @ * etc... ";
for (int charIndex=0; charIndex < (sizeof(msg)-1); charIndex++) //start of charIndex setup
{
int alphabetIndex = msg[charIndex]- ' ';
if (alphabetIndex < 0) alphabetIndex=0;
bool isOn =0;
for (int col=0; col<6;col++) {
//////////START OF SET METHOD/////////////////
for(int row=0; row<rows ;row++){
if (col<5) isOn = bitRead( alphabets[alphabetIndex][col], row ) == 1;
leds.setPixel(pix[row],isOn*50);
leds.show();delay(del);
}
///////////START OF THE SCROLL METHOD/////////////////////
for(int a=0; a<8; a++){
for(int b=1; b<34;b++){
leds.setPixel(array[a][b]-1,leds.getPixel(array[a][b]));}
}
////////END OF SET AND SCROLL////////////////////
}
}//end of charindex setup
}//end of message setup
The pix array just sets out the starting location for the first column of leds (the right hand most location).
The 2D array array[][] is a way of housing the pixel/led reference numbers.
the alphabet array is the usual 2D situation, and uses one I found online. Really sorry, but cant find it again to be able to give credit where it is due:
Code:
byte alphabets [96] [5] = {
{ 0x00, 0x00, 0x00, 0x00, 0x00 }, // space (0x20)
{ 0x00, 0x00, 0x2F, 0x00, 0x00 }, // !
{ 0x00, 0x07, 0x00, 0x07, 0x00 }, // "
I think that the original code using digital write for pins came from here: http://arduino.cc/forum/index.php/topic,8672.0.html
there is a vid at http://orchardelica.com/wp/
any comments on optimising code would be appreciated.
mortonkopf
Last edited: