Skip to content

marcmerlin/LEDMatrix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LEDMatrix


Travis build GitHub version FastLED 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 Contents Espruino Pico OLED NFC

Single Matrix (Example)


Parameters

Parameter Description
Parameter 1 width of matrix
Parameter 2 height of matrix
Parameter 3 MatrixType_t = matrix layout type
enum MatrixType_t { HORIZONTAL_MATRIX,
                    VERTICAL_MATRIX,
                    HORIZONTAL_ZIGZAG_MATRIX,
                    VERTICAL_ZIGZAG_MATRIX };

enum BlockType_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
#define DATA_PIN            D5

#define COLOR_ORDER         GRB
#define CHIPSET             WS2812B

// initial matrix layout (to get led strip index by x/y)
#define MATRIX_WIDTH   11
#define MATRIX_HEIGHT  11
#define MATRIX_TYPE    HORIZONTAL_ZIGZAG_MATRIX
#define MATRIX_SIZE    (MATRIX_WIDTH*MATRIX_HEIGHT)
#define NUMPIXELS      MATRIX_SIZE

// create our matrix based on matrix definition
cLEDMatrix<MATRIX_WIDTH, MATRIX_HEIGHT, MATRIX_TYPE> leds;

Initialize FastLED

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

Tile Matrix (Example)


Parameters

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

enum BlockType_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
#define DATA_PIN            D2
#define CLOCK_PIN           D1
#define DATA2_PIN           D4
#define CLOCK2_PIN          D3

#define COLOR_ORDER         BGR
#define CHIPSET             APA102

#define MATRIX_TILE_WIDTH   16 // width of EACH NEOPIXEL MATRIX (not total display)
#define MATRIX_TILE_HEIGHT  8 // height of each matrix
#define MATRIX_TILE_H       1  // number of matrices arranged horizontally
#define MATRIX_TILE_V       8  // number of matrices arranged vertically
#define MATRIX_SIZE         (MATRIX_WIDTH*MATRIX_HEIGHT)
#define MATRIX_PANEL        (MATRIX_WIDTH*MATRIX_HEIGHT)

#define MATRIX_WIDTH        (MATRIX_TILE_WIDTH*MATRIX_TILE_H)
#define MATRIX_HEIGHT       (MATRIX_TILE_HEIGHT*MATRIX_TILE_V)

#define NUM_LEDS            (MATRIX_WIDTH*MATRIX_HEIGHT)

// create our matrix based on matrix definition
cLEDMatrix<MATRIX_TILE_WIDTH, MATRIX_TILE_HEIGHT, HORIZONTAL_ZIGZAG_MATRIX, MATRIX_TILE_H, MATRIX_TILE_V, VERTICAL_BLOCKS> leds;

Initialize FastLED

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

Initialize FastLED (multiple controller)

void setup() {
  // 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

virtual uint16_t mXY(uint16_t x, uint16_t y)
void SetLEDArray(struct CRGB *pLED)

void ShiftLeft(void)
void ShiftRight(void)
void ShiftDown(void)
void ShiftUp(void)

struct CRGB *operator[](int n)
struct CRGB &operator()(int16_t x, int16_t y)
struct CRGB &operator()(int16_t i)

int Size()
int Width()
int Height()

void HorizontalMirror(bool FullHeight = true)
void VerticalMirror()
void QuadrantMirror()
void QuadrantRotateMirror()
void TriangleTopMirror(bool FullHeight = true)
void TriangleBottomMirror(bool FullHeight = true)
void QuadrantTopTriangleMirror()
void QuadrantBottomTriangleMirror()

void DrawPixel(int16_t x, int16_t y, CRGB color)
void DrawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, CRGB color)
void DrawRectangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, CRGB color)
void DrawCircle(int16_t xc, int16_t yc, uint16_t r, CRGB color)
void DrawFilledRectangle(int16_t x0, int16_t y0, int16_t x1, int16_t y1, CRGB color)
void DrawFilledCircle(int16_t xc, int16_t yc, uint16_t r, CRGB color)

Packages

No packages published

Languages

  • C++ 94.1%
  • Shell 5.9%