Hi Guys, I am trying to wrap my head around the serpentine layout from

Hi Guys,

I am trying to wrap my head around the serpentine layout from XYMatrix. I am using all the width and height variables as normal but my layout is orientated lengthwise.

Is it possible to change the layout from horizontal to vertical without editing the design functions?

Hi! Sure! If you just want to switch X and Y, change the function “XY” to take the arguments in the order Y, X instead of X,Y.

You can do all sorts of flips and re-orientations be changing the XY function-- without changing the rest of your code.

@Mark_Kriegsman Tried to understand the calculation for the serpentine layout and changed the codes. got the flames to change orientation but the odd and even number changes seem to be wrong. tried switching the serpentine layout to false, still the same problem

pic: http://imgur.com/oacflEJ

code: https://github.com/prakID/LED_60x7M_FastLED/blob/master/Draft_1.ino

Looks like you’re getting close though!

This is the very reason I wrote my LEDMatrix class. It allows you to easily change between horizontal / vertical layouts including zigzags and also allows flipping of X / Y axis. See https://github.com/AaronLiddiment/LEDMatrix

I have a 700 led matrix 14x50 for a megatree. Using saved Jinx/Glediator recordings saved to SD card to replay on matrix. Matrix is vertical zigzag with 0,0 at bottom left. tried using xy table generator posted. works like a charm, but to flip matrix i need to red in all 700 leds from SD into a temp CRGB and then copy to leds array. very slow… works great with few leds, but 700 makes for slow animation. Id like to use the ledmatrix class from Aaron, but it doesnt seem to be working correctly. All matryix types render the same roughly. Am I using it correctly? here is code:

#include <FastLED.h>
//#include <SPI.h>
#include <SdFat.h>

#include <LEDMatrix.h>

#define DATA_PIN 37

SdFat SD;
File fxdata;

#define MATRIX_WIDTH 14 // Set this negative if physical led 0 is opposite to where you want logical 0
#define MATRIX_HEIGHT 50 // Set this negative if physical led 0 is opposite to where you want logical 0
#define MATRIX_TYPE VERTICAL_ZIGZAG_MATRIX // See top of LEDMatrix.h for matrix wiring types

cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;

#define NUM_LEDS 700

void setup()
{
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds[0], sizeof(leds)); //se doc for different LED strips
// Serial.begin(57600); // when using Glediator via usb
FastLED.setBrightness(200);

pinMode(53, OUTPUT); // CS/SS pin as output for SD library to work.
digitalWrite(53, HIGH); // workaround for sdcard failed error…

if (!SD.begin(33, SPI_FULL_SPEED))
{
// Serial.println(“sdcard initialization failed!”);
return;
}
// Serial.println(“sdcard initialization done.”);

}

void loop()
{
fxdata = SD.open(“gled.out”); // read only
if (fxdata)
{
Serial.println(“file open ok”);
}

while (fxdata.available())
{
fxdata.readBytes((char*)leds[0], NUM_LEDS * 3);
FastLED.show();
delay(10);
}
fxdata.close();
}

@Gary_Poduska1
Your mistake is that you are using the C statement ‘size’ rather than my Matrix Class size function.
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds[0], sizeof(leds)); //se doc for different LED strips
Change to
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds[0], leds.Size()); //se doc for different LED strips

Looking at the code though I am not sure why you are using my class as you are directly loading the led data into the led array. This means you will only be able to use data that matches your matrix layout.
If you want to use the flexible nature of my class you should read the data into a char buffer and then transfer it to the matrix using leds(x, y) making sure you inject the data using X/Y’s that match the stored data. Then you could change the parameters for my matrix class to reverse it, flip it etc.