iregular shaped LED strip screen

Status
Not open for further replies.
Hello everyone, I am trying to build an LED screen shaped as a guitar. I want it to be able to display graphics as if it was a square screen.I am using WS2812 strip and a Teensy 3.1.Is there a way to map out each pixel (see picture). For example. from top left pixel nr. 5 is actually the first pixel, and pixel nr.26 is actually pixel nr. 3. would it be possible to map ot each pixel as pixel nr.1 = x5y1 and pixel nr.26 = x3y2. I am not that good at programming, so how would that look in a sketch??
LEDMapping.jpg
Best regards
Colin Dahlberg
 
You can use a lookup array to do this, such that all of the leds forming the guitar (the blue ones?) are set out in order of receiving data such as: byte guitarArray[] = {5,6,26,27,28,29,30,31,32,49.50...}. You then access the position of theis by simply working through the array in sequence, such as: guitarArray [0] = whateverColour; This would turn the first led in the array, nr 5, whateverColour.

In terms of referencing led x and y location, you would not need to do anything more than know its position in the array. for example, led 26 would be guiterArray[2];
 
Thank you very much mortonkopf, that looks like plan :eek:, would it be possible to add it to this sketch.

#include "FastLED.h"
#define NUM_LEDS 456
#define COLOR_ORDER RGB
const int dataline = 13;

CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(115200);
LEDS.addLeds<WS2812B, dataline>(leds, NUM_LEDS);
}
int serialGlediator() {
while (!Serial.available()) {}
return Serial.read();
}
void loop() {
while (serialGlediator() != 1) {}

for (int i=0; i < NUM_LEDS; i++) {
leds.r = serialGlediator();
leds.g = serialGlediator();
leds.b = serialGlediator();
}
FastSPI_LED.show();
}

Could you maybe give me an idea on how to put it in the sketch.
Thank you very much :)
 
putting it into the sketch will depend on how Glediator outputs. I have not use it. Will it be outputting as if the matrix were the guitar shape, or will it be outputting to all leds, 25 wide by however many high?
 
Last edited:
one way would be to make a mask the sets all non guitarArray pixels/leds to black just before you use the update FastSPI_LED.show(); call. So in effect you send all the glediator 24*19 pixel to all the leds, but then before you call show(), set the ones you don't want to black. This will slow down the update rate a little, but should not be by too much.

Try this:
make an array containing the led number for those that are NOT part of the guitar;
int notGuitar[] = {0,1,2,3,4,7,8,9,10,111,12,13,14,15,16,17,18,19,20,21,22,23,24,25,3,34,35,…};
and just before the show(); do something like:

for (int x=0;x<numberofblackoutLEDS;x++) { leds[notGuitar[x]] =0;}

This is a bit of guess of course, and I don't have the test setup.

Code:
void loop() {
while (serialGlediator() != 1) {} 

for (int i=0; i < NUM_LEDS; i++) {
leds[i].r = serialGlediator();
leds[i].g = serialGlediator();
leds[i].b = serialGlediator();
}

for (int x=0;x<numberofblackoutLEDS;x++) { 
leds[notGuitar[x]] =0;}

FastSPI_LED.show();
}

you would declare your array at the front end of your code before setup().

Code:
#include "FastLED.h"
#define NUM_LEDS 456
#define COLOR_ORDER RGB
const int dataline = 13;

CRGB leds[NUM_LEDS];
int notGuitar[] = {0,1,2,3,4,7,8,9,10,111,12,13,14,15,16,17,18,19,20,21,22,23,24,25,3,34,35,…};
 
Thank you so much for your help mortonkopf. The Glediator is not that important. this is going to be an actual guitar. I think that if I can make an array of the LEDs on the guitar, that would do the trick, I will then just output from a square screen in 24X19 from Glediator the problem is to setup the LEDs on the guitar so they will act like a "square" screen, when graphics is displayed on to it.
See picture. the numbers on the guitar are the numbers the LEDs would hav if it was a sqaure screen, but in reallity they are lust one long strip. So graphics will be distorted when displayed, because they are not setup for the right placements. for example number 176 and 181 will just act as if they were 176 and 177, and so on.LEDMapping.jpg
 
Ah, right, that is starting to make more sense now. you will need to get into some more led location coding in that case.

one way is I think that you could fill a buffer with each frame from the a buffer array. This second buffer would then hold all led info for each frame. After filling the buffer with the led data, you then go through and assign a value from the buffer array to the second array that fits the layout you have, then you use show(). Again, this might slow things down a bit. This is the only way I can see how to select only some of the data from the incoming stream.

A potential way would be to use the the virtual locations set of led position numbers, as if you had the 24*19 array of leds, as discussed above, and walk through that list of locations to assign the led colour value from the buffer. But its a bit of double handling, and a cant get my head around the fact that there must be a simpler, more efficient way.
 
Last edited:
wuuhuuu I actually explained something that people could understand. :D I have had a really hard time trying to fond a way to explain my problem. as I am a totally noob at this I wouldent knov where to start with the programming, could you maybe guide a bit. I really am totally lost and cant seem to find any info on the topic, so any help will be much appreciated.

Best from
Denmark
 
You could try something along the lines of the below, but it is written from memory, and without any test, so there will be a couple of errors:

Code:
#include "FastLED.h"
#define NUM_LEDS 456//this is the matrix size number of leds, not actual number
#define COLOR_ORDER RGB
const int dataline = 13;

int actualLeds =300;//? How many leds do you actually have
CRGB leds[NUM_LEDS];//defines size of storage buffer for full matrix size

void setup() {
Serial.begin(115200); 
LEDS.addLeds<WS2812B, dataline>(leds, NUM_LEDS);
}
int serialGlediator() {
while (!Serial.available()) {}
return Serial.read();
}

int guitarLeds[] = { //this stores the position of the led colour in the incoming data
//this is a 1D array, just set out as below for easy reading
5,6,
26,27,28,29,30,31,32,
49,50,51,52,53,54,55,56,57,66,67,68,
73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,80,91,92,93,94,
96,97,98,99,10,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119
//...etc
};

char colourStore[NUM_LEDS*3]; //this will store the selected data

void loop() {
while (serialGlediator() != 1) {}

for (int x=0; x < NUM_LEDS*3; x+3) { //loop through all incoming data and put into the colourStore array
colourStore[x] = serialGlediator();//first colour byte
colourStore [x+1] = serialGlediator();//second colour byte
colourStore [x+2] = serialGlediator();//third colour byte
}

for (int i=0; i < actualLeds; i++) {//this loops through each of the actual leds, and grabs the value //for r,g,b from colourStore at the given location value (taken from guitarLeds).
leds[i].r = colourStore[guitarLeds[i*3]];
leds[i].g = colourStore[guitarLeds[i*3]+1];
leds[i].b = colourStore[guitarLeds[i*3]+2];

}
FastLED.show();
}
 
One step closer. does this look right. it compiles and uploads but it comes with some errors
Code:
#include "FastLED.h"
#define NUM_LEDS 456//this is the matrix size number of leds, not actual number
#define COLOR_ORDER RGB
const int dataline = 13;

int actualLeds =272;//? How many leds do you actually have
CRGB leds[NUM_LEDS];//defines size of storage buffer for full matrix size

void setup() {
Serial.begin(115200); 
LEDS.addLeds<WS2812B, dataline>(leds, NUM_LEDS);
}
int serialGlediator() {
while (!Serial.available()) {}
return Serial.read();
}
//this is a 1D array, just set out as below for easy reading
int guitarLeds[] = {6,7,
  27,28,29,30,31,32,33,
  50,51,52,53,54,55,56,57,58,66,67,68,69,
  74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
  97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,
  120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,
  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,
  168,169,170,171,172,173,182,183,184,185,189,
  192,193,194,195,196,197,206,207,208,209,
  216,217,218,219,220,221,230,231,232,233,
  240,241,242,243,244,245,254,255,256,257,
  264,265,266,267,268,269,278,279,280,281,285,
  288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,
  313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,
  337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,
  361,362,363,364,365,366,367,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,
  386,387,388,389,390,391,392,393,394,402,403,404,405,
  411,412,413,414,415,416,417,
    436,437,438,439};

char colourStore[NUM_LEDS*3]; //this will store the selected data

void loop() {
while (serialGlediator() != 1) {}

for (int x=0; x < NUM_LEDS*3; x+3) { //loop through all incoming data and put into the colourStore array
colourStore[x] = serialGlediator();//first colour byte
colourStore [x+1] = serialGlediator();//second colour byte
colourStore [x+2] = serialGlediator();//third colour byte
}

for (int i=0; i < actualLeds; i++) {//this loops through each of the actual leds, and grabs the value //for r,g,b from colourStore at the given location value (taken from guitarLeds).
leds[i].r = colourStore[guitarLeds[i*3]];
leds[i].g = colourStore[guitarLeds[i*3]+1];
leds[i].b = colourStore[guitarLeds[i*3]+2];

}
FastSPI_LED.show();
}

and these errors

Guitar_LED.ino: In function 'void loop()':
Guitar_LED.ino:43:32: warning: for increment expression has no effect [-Wunused-value]
Multiple libraries were found for "FastLED.h"
Used: C:\Program Files (x86)\Arduino\hardware\teensy\avr\libraries\FastLED
Not used: C:\Users\Colin\Documents\Arduino\libraries\FastLED-3.0.3
Not used: C:\Users\Colin\Documents\Arduino\libraries\FastLED-archive-FastLED2.1

Sketch uses 14.232 bytes (5%) of program storage space. Maximum is 262.144 bytes.
Global variables use 6.304 bytes (9%) of dynamic memory, leaving 59.232 bytes for local variables. Maximum is 65.536 bytes.
 
Ah, I think that syntax for incrementing a for loop by more than one is not x+3, but x+=3. Anyone?

so
for (int x=0; x < NUM_LEDS*3; x+3) {
should be
for (int x=0; x < NUM_LEDS*3; x+=3) { //? hopefully this is the right syntax

If that is not correct, it would be a simple insert of the line

i=i+3;

at the bottom of the for loop

Also, you have multiple copies of FastLed in your libs,
 
Last edited:
I'm not surprised that it doesnt output anything, there is still some work to do. I will have a test this evening if i get the time, but I am away from any kit at the moment.
the lines below seem wrong, somehow:
leds.r = colourStore[guitarLeds[i*3]];
leds.g = colourStore[guitarLeds[i*3]+1];
leds.b = colourStore[guitarLeds[i*3]+2];
should probably read
leds.r = colourStore[guitarLeds[i*3]];
leds.g = colourStore[guitarLeds[(i*3)+1]];
leds.b = colourStore[guitarLeds[(i*3)+2]];

and
for (int x=0; x < NUM_LEDS*3; x+3)
should probably read
for (int x=0; x < NUM_LEDS; x++)
but I would need to have a better think about it.
 
There is still no output in Glediator, Did I put in the lines correct??

Code:
#include "FastLED.h"
#define NUM_LEDS 456//this is the matrix size number of leds, not actual number
#define COLOR_ORDER RGB
const int dataline = 13;

int actualLeds =272;//? How many leds do you actually have
CRGB leds[NUM_LEDS];//defines size of storage buffer for full matrix size

void setup() {
Serial.begin(115200); 
LEDS.addLeds<WS2812B, dataline>(leds, NUM_LEDS);
}
int serialGlediator() {
while (!Serial.available()) {}
return Serial.read();
}
//this is a 1D array, just set out as below for easy reading
int guitarLeds[] = {6,7,
  27,28,29,30,31,32,33,
  50,51,52,53,54,55,56,57,58,66,67,68,69,
  74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
  97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,
  120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,
  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,
  168,169,170,171,172,173,182,183,184,185,189,
  192,193,194,195,196,197,206,207,208,209,
  216,217,218,219,220,221,230,231,232,233,
  240,241,242,243,244,245,254,255,256,257,
  264,265,266,267,268,269,278,279,280,281,285,
  288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,
  313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,
  337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,
  361,362,363,364,365,366,367,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,
  386,387,388,389,390,391,392,393,394,402,403,404,405,
  411,412,413,414,415,416,417,
    436,437,438,439};

char colourStore[NUM_LEDS*3]; //this will store the selected data

void loop() {
while (serialGlediator() != 1) {}

for (int x=0; x < NUM_LEDS*3; x+=3) { //loop through all incoming data and put into the colourStore array
colourStore[x] = serialGlediator();//first colour byte
colourStore [x+1] = serialGlediator();//second colour byte
colourStore [x+2] = serialGlediator();//third colour byte
}

for (int i=0; i < actualLeds; i++) {//this loops through each of the actual leds, and grabs the value //for r,g,b from colourStore at the given location value (taken from guitarLeds).
leds[i].r = colourStore[guitarLeds[i*3]];
leds[i].g = colourStore[guitarLeds[i*3]+1];
leds[i].b = colourStore[guitarLeds[i*3]+2];
i=i+3;
}
FastSPI_LED.show();
}
 
we have cross posts. Probably better to continue sorting this through pm and post solution to this thread.
 
Dahlberg77, I have sent you a pm with some corrected code. pm back

this might help
Code:
void loop() {
while (serialGlediator() != 1) {} 

for (int i=0; i < NUM_LEDS; i++) {
leds[i].r = serialGlediator();
leds[i].g = serialGlediator();
leds[i].b = serialGlediator();
}
for(int x=0;x<300;x++){//where 300 is the number of actual leds, and guitarleds[] hold the led locations in the //stream
  leds[x]= leds[guitarLeds[x]];
  }
FastLED.show();
}
 
Last edited:
This now works, Glediator to irregular matrix size. The below should generally work with any matrix input, such as pixelcontroller or gladiator. Dahlberg77, chip in if there are any other changes:

Code:
#include "FastLED.h"
#define NUM_LEDS 272 //this is the matrix input size
#define COLOR_ORDER RGB
const int dataline = 13;

//this is a 1D array, just set out as below for easy reading
int guitarLeds[] = {6,10,20,30,40,50,60,70,80,90,100,110,200 };// this is the virtual locations of your leds within the matrix from your output software


CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(115200); 
  FastLED.addLeds<WS2811, 3, RGB>(leds, NUM_LEDS);
}
int serialGlediator() {
while (!Serial.available()) {}
return Serial.read();
}

void loop() {
while (serialGlediator() != 1) {} 

for (int i=0; i < NUM_LEDS; i++) {
leds[i].r = serialGlediator();
leds[i].g = serialGlediator();
leds[i].b = serialGlediator();
}
for(int x=0;x<13;x++){ //where 13 is the number of actual leds - the virtual location of which are in guitarLeds[]
  leds[x]= leds[guitarLeds[x]];
  }
FastLED.show();
}
 
This is the working code I use:), and mortonkopf, youre a Wizz;)


Code:
//
                                                          // chain all the led strips so they face the same
#include "FastLED.h"
#define NUM_LEDS 456                          //Matrix size input 24X19 pixel
#define COLOR_ORDER RGB
const int dataline = 13;
byte colourStore[NUM_LEDS *3];


int guitarLeds[] = {6,7,                         //this is a 1D array, just set out as below for easy reading
  27,28,29,30,31,32,33,
  50,51,52,53,54,55,56,57,58,66,67,68,69,
  74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
  97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,
  120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,
  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,
  168,169,170,171,172,173,182,183,184,185,189,
  192,193,194,195,196,197,206,207,208,209,
  216,217,218,219,220,221,230,231,232,233,
  240,241,242,243,244,245,254,255,256,257,
  264,265,266,267,268,269,278,279,280,281,285,
  288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,
  313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,
  337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,
  361,362,363,364,365,366,367,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,
  386,387,388,389,390,391,392,393,394,402,403,404,405,
  411,412,413,414,415,416,417,
    436,437,438,439};


CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(115200); 
LEDS.addLeds<WS2812B, dataline>(leds, NUM_LEDS);
}
int serialGlediator() {
while (!Serial.available()) {}
return Serial.read();
}
void loop() {
while (serialGlediator() != 1) {} 

for (int i=0; i < NUM_LEDS; i++) {
leds[i].r = serialGlediator();
leds[i].g = serialGlediator();
leds[i].b = serialGlediator();
}
for(int x=0;x<272;x++)                    //272 is the actual led number
{
leds[x]= leds[guitarLeds[x]]; 
}
FastSPI_LED.show();
}
 
lastly, the inclusion of "byte colourStore[NUM_LEDS *3];" can now be removed as it is no longer being used.
 
You might want to add the const keyword in setting up guitarLeds if you don't modify it. On the ARM platforms, this puts the array into read-only program memory, instead of read-write data memory. In addition, since no value is more than 439 or so, you might want to use int16_t to save a little memory. Whether you use static or not is optional (in somethings, particularly at higher optimization levels, you can get better code if the value is declared static which limits the scope to just the current file).

Code:
static const int16_t guitarLeds[] = {6,7,                         //this is a 1D array, just set out as below for easy reading
  27,28,29,30,31,32,33,
  50,51,52,53,54,55,56,57,58,66,67,68,69,
  74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,
  97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,
  120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,
  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,
  168,169,170,171,172,173,182,183,184,185,189,
  192,193,194,195,196,197,206,207,208,209,
  216,217,218,219,220,221,230,231,232,233,
  240,241,242,243,244,245,254,255,256,257,
  264,265,266,267,268,269,278,279,280,281,285,
  288,289,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,308,309,
  313,314,315,316,317,318,319,320,321,322,323,324,325,326,327,328,329,330,331,332,333,
  337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,355,356,357,
  361,362,363,364,365,366,367,369,370,371,372,373,374,375,376,377,378,379,380,381,382,383,
  386,387,388,389,390,391,392,393,394,402,403,404,405,
  411,412,413,414,415,416,417,
    436,437,438,439};
 
Status
Not open for further replies.
Back
Top