Skip to content

Repository files navigation

LEDMatrix


Travis buildGitHub versionFastLED dependencies

A fork of (cLEDMatrix by Aaron Liddiment) and build in some features from (Adafruit-NeoMatrix)

Once you have downloaded the Zip file, it should be extracted into your Arduino Libraries folder and the folder renamed to "LEDMatrix".

The LEDMatrix library builds a giant two-dimensional graphics array which can be used by FastLED. You can then easily draw shapes, text and animation without having to calculate every X/Y pixel position. Larger displays can be formed using tiles of LED strip / matrices - to build one big matrix. Similar to Adafruit-NeoMatrix (see picture below as example).
Table of ContentsEspruino Pico OLED NFC

Single Matrix (Example)


Parameters

ParameterDescription
Parameter 1width of matrix
Parameter 2height of matrix
Parameter 3MatrixType_t = matrix layout type
enumMatrixType_t { HORIZONTAL_MATRIX,
VERTICAL_MATRIX,
HORIZONTAL_ZIGZAG_MATRIX,
VERTICAL_ZIGZAG_MATRIX };
enumBlockType_t { HORIZONTAL_BLOCKS,
VERTICAL_BLOCKS,
HORIZONTAL_ZIGZAG_BLOCKS,
VERTICAL_ZIGZAG_BLOCKS };

Includes

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

Decleration

// Change the next defines to match your matrix type and size#defineDATA_PIN D5
#defineCOLOR_ORDER GRB
#defineCHIPSET WS2812B
// initial matrix layout (to get led strip index by x/y)#defineMATRIX_WIDTH 11
#defineMATRIX_HEIGHT 11
#defineMATRIX_TYPE HORIZONTAL_ZIGZAG_MATRIX
#defineMATRIX_SIZE (MATRIX_WIDTH*MATRIX_HEIGHT)
#defineNUMPIXELS MATRIX_SIZE
// create our matrix based on matrix definitioncLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE>leds;

Initialize FastLED

voidsetup() {
// initial FastLED by using CRGB led source from our matrix classFastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(leds[0], leds.Size()).setCorrection(TypicalSMD5050);
FastLED.setBrightness(127);
FastLED.clear(true);
}

Tile Matrix (Example)


Parameters

ParameterDescription
Parameter 1width of EACH NEOPIXEL MATRIX (not total display)
Parameter 2height of each matrix
Parameter 3MatrixType_t = matrix layout type
Parameter 4number of matrices arranged horizontally
Parameter 5number of matrices arranged vertically
Parameter 6BlockType_t = layout of each matrix tile
enumMatrixType_t { HORIZONTAL_MATRIX,
VERTICAL_MATRIX,
HORIZONTAL_ZIGZAG_MATRIX,
VERTICAL_ZIGZAG_MATRIX };
enumBlockType_t { HORIZONTAL_BLOCKS,
VERTICAL_BLOCKS,
HORIZONTAL_ZIGZAG_BLOCKS,
VERTICAL_ZIGZAG_BLOCKS };

Includes

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

Decleration

// Change the next defines to match your matrix type and size#defineDATA_PIN D2
#defineCLOCK_PIN D1
#defineDATA2_PIN D4
#defineCLOCK2_PIN D3
#defineCOLOR_ORDER BGR
#defineCHIPSET APA102
#defineMATRIX_TILE_WIDTH 16 // width of EACH NEOPIXEL MATRIX (not total display)
#defineMATRIX_TILE_HEIGHT 8 // height of each matrix
#defineMATRIX_TILE_H 1 // number of matrices arranged horizontally
#defineMATRIX_TILE_V 8 // number of matrices arranged vertically
#defineMATRIX_SIZE (MATRIX_WIDTH*MATRIX_HEIGHT)
#defineMATRIX_PANEL (MATRIX_WIDTH*MATRIX_HEIGHT)
#defineMATRIX_WIDTH (MATRIX_TILE_WIDTH*MATRIX_TILE_H)
#defineMATRIX_HEIGHT (MATRIX_TILE_HEIGHT*MATRIX_TILE_V)
#defineNUM_LEDS (MATRIX_WIDTH*MATRIX_HEIGHT)
// create our matrix based on matrix definitioncLEDMatrix<MATRIX_TILE_WIDTH, MATRIX_TILE_HEIGHT, HORIZONTAL_ZIGZAG_MATRIX, MATRIX_TILE_H, MATRIX_TILE_V, VERTICAL_BLOCKS>leds;

Initialize FastLED

voidsetup() {
// initial FastLED by using CRGB led source from our matrix classFastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds[0], leds.Size());
FastLED.setBrightness(127);
FastLED.clear(true);
}

Initialize FastLED (multiple controller)

voidsetup() {
// initial FastLED with multiple controller, by using CRGB led source from each matrix panal FastLED.addLeds<CHIPSET, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds[0], 0, leds.Size()/2).setCorrection(TypicalSMD5050);
FastLED.addLeds<CHIPSET, DATA2_PIN, CLOCK2_PIN, COLOR_ORDER>(leds[0], leds.Size()/2, leds.Size()/2).setCorrection(TypicalSMD5050);
FastLED.setBrightness(127);
FastLED.clear(true);
}

Available Methods

virtualuint16_tmXY(uint16_tx, uint16_ty)
voidSetLEDArray(structCRGB*pLED)
voidShiftLeft(void)
voidShiftRight(void)
voidShiftDown(void)
voidShiftUp(void)
structCRGB*operator[](intn)
structCRGB&operator()(int16_tx, int16_ty)
structCRGB&operator()(int16_ti)
intSize()
intWidth()
intHeight()
voidHorizontalMirror(boolFullHeight= true)
voidVerticalMirror()
voidQuadrantMirror()
voidQuadrantRotateMirror()
voidTriangleTopMirror(boolFullHeight= true)
voidTriangleBottomMirror(boolFullHeight= true)
voidQuadrantTopTriangleMirror()
voidQuadrantBottomTriangleMirror()
voidDrawPixel(int16_tx, int16_ty, CRGBcolor)
voidDrawLine(int16_tx0, int16_ty0, int16_tx1, int16_ty1, CRGBcolor)
voidDrawRectangle(int16_tx0, int16_ty0, int16_tx1, int16_ty1, CRGBcolor)
voidDrawCircle(int16_txc, int16_tyc, uint16_tr, CRGBcolor)
voidDrawFilledRectangle(int16_tx0, int16_ty0, int16_tx1, int16_ty1, CRGBcolor)
voidDrawFilledCircle(int16_txc, int16_tyc, uint16_tr, CRGBcolor)

About

FastLED Flexible Matrix Class

Resources

Stars

16 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages