Led Array Coding????

Status
Not open for further replies.
I do not know how to code my led display correctly What parameters in the code can I change to rectify this?
I'd also like to know how to code for an odd display like a sphere or big letters or something.

I am using a teensy 3.6, an Octoadapter, ws2811b leds and an array of 35x8 which I hope to increase to 35x35
I am using the Arduino coder app with the teensy program
I am using the sketches in Examples>OctoWS2811>

So currently I still have 35x8 I will later have 35 x 35 hopefully

In the code for Fire there is the section

// The display size and color to use
const unsigned int width = 35;
const unsigned int height = 8;

But when I fill this out correctly only the 1st and 5th line light up at all
When I increase the width by x4 to 140 they all light up but the pattern is wrong.
Are there other parameters I need to change to rectify this? My data set up is the same as this project
https://community.arm.com/iot/embedd...nd-development

Same with rainbow
const int ledsPerStrip = 35

and spectrum analyser
// The display size and color to use
const unsigned int matrix_width = 35;
const unsigned int matrix_height = 8;
const unsigned int myColor = 0x400020;

What are the other parameters I need to change in the code?

Rainbow
*/

#include <OctoWS2811.h>

const int ledsPerStrip = 35;

DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];

const int config = WS2811_GRB | WS2811_800kHz;

OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);

int rainbowColors[180];


void setup() {
pinMode(1, OUTPUT);
digitalWrite(1, HIGH);
for (int i=0; i<180; i++) {
int hue = i * 2;
int saturation = 100;
int lightness = 50;
// pre-compute the 180 rainbow colors
rainbowColors = makeColor(hue, saturation, lightness);
}
digitalWrite(1, LOW);
leds.begin();
}


void loop() {
rainbow(10, 2500);
}


// phaseShift is the shift between each row. phaseShift=0
// causes all rows to show the same colors moving together.
// phaseShift=180 causes each row to be the opposite colors
// as the previous.
//
// cycleTime is the number of milliseconds to shift through
// the entire 360 degrees of the color wheel:
// Red -> Orange -> Yellow -> Green -> Blue -> Violet -> Red
//
void rainbow(int phaseShift, int cycleTime)
{
int color, x, y, offset, wait;

wait = cycleTime * 1000 / ledsPerStrip;
for (color=0; color < 180; color++) {
digitalWrite(1, HIGH);
for (x=0; x < ledsPerStrip; x++) {
for (y=0; y < 8; y++) {
int index = (color + x + y*phaseShift/2) % 180;
leds.setPixel(x + y*ledsPerStrip, rainbowColors[index]);
}
}
leds.show();
digitalWrite(1, LOW);
delayMicroseconds(wait);
}
}
 
What parameters in the code can I change to rectify this?

There is no single easy parameter to change. This example was designed for only 8 strips in the Y direction.

These are the 3 most important lines.

for (y=0; y < 8; y++) {
int index = (color + x + y*phaseShift/2) % 180;
leds.setPixel(x + y*ledsPerStrip, rainbowColors[index]);

The loop is from 0 to 7, hard coded with the number 8. No simple parameter to edit. If you change the number 8, the other two lines to not automatically adapt. You would need to rewrite all 3 of these lines to meet your goals.


I'd also like to know how to code for an odd display like a sphere or big letters or something.

Again, there no quick and easy answers. This is a matter of programming, which is always specific to your particular project. It involves doing work to solve the problem yourself, because there isn't already a solution.

Some of the other OctoWS2811 examples, like Fire and SpectrumAnalyzer have more sophisticated code which is designed to adapt to different LED configurations. Maybe look at those for some ideas. They have an index = xy(x, y) function, which converts the X and Y position on your LEDs to the index number which OctoWS2811 uses. The idea is this one small function can contain all the info about how the LEDs are physically arranged. The rest of the example works in X and Y coordinates.

Perhaps in the future (but not soon... I'm currently very busy developing the USB Host code) I may redesign the Rainbow example. I might even create an example or two to demonstrate mapping a subset of a large rectangular X-Y grid onto a non-rectangular LED arrangement. But even if I do create such an example, it's only that, just an example, a starting point to help you.

Ultimately, Teensy and OctoWS2811 are about DIY electronics. You have to step up to the challenge of actually doing the work to solve your particular project's unique challenges. I can try to create useful examples, and I can try to give you some advice, but you have to actually do your project's work. I can't do it for you.
 
Status
Not open for further replies.
Back
Top