Skip to content
PanMan edited this page Jun 11, 2019 · 2 revisions

In order to use the class you must have the following header files included in your program:-

#include <FastLED.h>
#include <LEDMatrix.h>

You must declare an instance of the cLEDMatrix class as this is used to declare and modify the LED data according to the matrix dimensions, layout and origin. Personally I use defines to make this clearer in the code, such as:-

#define MATRIX_WIDTH 68
#define MATRIX_HEIGHT 7
#define MATRIX_TYPE HORIZONTAL_ZIGZAG_MATRIX
cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;

You can get the memory address and size of the led array for the "addLeds" call as follows:-

FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds[0], leds.Size());

There are four matrix types defined at the top of the LEDMatrix header file. The type refers to led wiring order and direction. It is also possible to reverse the X and/or Y axis by using a negative (-) sign before the width/height values:-

cLEDMatrix<MATRIX_WIDTH, -MATRIX_HEIGHT, MATRIX_TYPE> leds;

In the above example this would move the Y origin to the opposite end, so would be used where the first led is at the top but you still want Y origin to be at the bottom.

If you want to add multiple strips on individual pins (here 3-8):

cLEDMatrix<-MATRIX_WIDTH, -MATRIX_HEIGHT, MATRIX_TYPE> leds;

  //And then adding all strips:
  FastLED.addLeds<LED_TYPE, 3,COLOR_ORDER>(leds[0], 0, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip);
  FastLED.addLeds<LED_TYPE, 4,COLOR_ORDER>(leds[0], NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip);
  FastLED.addLeds<LED_TYPE, 5,COLOR_ORDER>(leds[0], 2*NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip);
  FastLED.addLeds<LED_TYPE, 6,COLOR_ORDER>(leds[0], 3*NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip);
  FastLED.addLeds<LED_TYPE, 7,COLOR_ORDER>(leds[0], 4*NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip);
  FastLED.addLeds<LED_TYPE, 8,COLOR_ORDER>(leds[0], 5*NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP).setCorrection(TypicalLEDStrip);
Clone this wiki locally