Adafruit NeoMatrix
Adafruit_NeoMatrix.h
Go to the documentation of this file.
1 
33 #ifndef _ADAFRUIT_NEOMATRIX_H_
34 #define _ADAFRUIT_NEOMATRIX_H_
35 
36 #if ARDUINO >= 100
37 #include <Arduino.h>
38 #else
39 #include <WProgram.h>
40 #include <pins_arduino.h>
41 #endif
42 #include <Adafruit_GFX.h>
43 #include <Adafruit_NeoPixel.h>
44 
45 // Matrix layout information is passed in the 'matrixType' parameter for
46 // each constructor (the parameter immediately following is the LED type
47 // from NeoPixel.h).
48 
49 // These define the layout for a single 'unified' matrix (e.g. one made
50 // from NeoPixel strips, or a single NeoPixel shield), or for the pixels
51 // within each matrix of a tiled display (e.g. multiple NeoPixel shields).
52 
53 #define NEO_MATRIX_TOP 0x00
54 #define NEO_MATRIX_BOTTOM 0x01
55 #define NEO_MATRIX_LEFT 0x00
56 #define NEO_MATRIX_RIGHT 0x02
57 #define NEO_MATRIX_CORNER 0x03
58 #define NEO_MATRIX_ROWS 0x00
59 #define NEO_MATRIX_COLUMNS 0x04
60 #define NEO_MATRIX_AXIS 0x04
61 #define NEO_MATRIX_PROGRESSIVE 0x00
62 #define NEO_MATRIX_ZIGZAG 0x08
63 #define NEO_MATRIX_SEQUENCE 0x08
64 
65 // These apply only to tiled displays (multiple matrices):
66 
67 #define NEO_TILE_TOP 0x00
68 #define NEO_TILE_BOTTOM 0x10
69 #define NEO_TILE_LEFT 0x00
70 #define NEO_TILE_RIGHT 0x20
71 #define NEO_TILE_CORNER 0x30
72 #define NEO_TILE_ROWS 0x00
73 #define NEO_TILE_COLUMNS 0x40
74 #define NEO_TILE_AXIS 0x40
75 #define NEO_TILE_PROGRESSIVE 0x00
76 #define NEO_TILE_ZIGZAG 0x80
77 #define NEO_TILE_SEQUENCE 0x80
78 
79 
82 class Adafruit_NeoMatrix : public Adafruit_GFX, public Adafruit_NeoPixel {
83 
84 public:
95  Adafruit_NeoMatrix(int w, int h, uint8_t pin = 6,
96  uint8_t matrixType = NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
98  neoPixelType ledType = NEO_GRB + NEO_KHZ800);
99 
113  Adafruit_NeoMatrix(uint8_t matrixW, uint8_t matrixH, uint8_t tX, uint8_t tY,
114  uint8_t pin = 6,
115  uint8_t matrixType = NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
118  neoPixelType ledType = NEO_GRB + NEO_KHZ800);
119 
120  virtual ~Adafruit_NeoMatrix() {
121  } // Virtual destructor to allow better memory management
122 
129  void drawPixel(int16_t x, int16_t y, uint16_t color);
130 
135  void fillScreen(uint16_t color);
136 
150  void setPassThruColor(uint32_t c);
151 
156  void setPassThruColor(void);
157 
165  void setRemapFunction(uint16_t (*fn)(uint16_t, uint16_t));
166 
174  static uint16_t Color(uint8_t r, uint8_t g, uint8_t b);
175 
176 private:
177  const uint8_t type;
178  const uint8_t matrixWidth, matrixHeight, tilesX, tilesY;
179  uint16_t (*remapFn)(uint16_t x, uint16_t y);
180 
181  uint32_t passThruColor;
182  boolean passThruFlag = false;
183 };
184 
185 #endif // _ADAFRUIT_NEOMATRIX_H_
#define NEO_MATRIX_LEFT
Pixel 0 is at left of matrix.
Definition: Adafruit_NeoMatrix.h:55
void setRemapFunction(uint16_t(*fn)(uint16_t, uint16_t))
Register a function for mapping X/Y coordinates to absolute pixel indices (for unusual layouts if if ...
Definition: Adafruit_NeoMatrix.cpp:236
Adafruit_NeoMatrix(int w, int h, uint8_t pin=6, uint8_t matrixType=NEO_MATRIX_TOP+NEO_MATRIX_LEFT+NEO_MATRIX_ROWS, neoPixelType ledType=NEO_GRB+NEO_KHZ800)
Construct a single (non-tiled) matrix.
Definition: Adafruit_NeoMatrix.cpp:80
#define NEO_MATRIX_ROWS
Matrix is row major (horizontal)
Definition: Adafruit_NeoMatrix.h:58
#define NEO_TILE_ROWS
Tiles ordered in rows.
Definition: Adafruit_NeoMatrix.h:72
void fillScreen(uint16_t color)
Fill matrix with a single color.
Definition: Adafruit_NeoMatrix.cpp:226
#define NEO_MATRIX_TOP
Pixel 0 is at top of matrix.
Definition: Adafruit_NeoMatrix.h:53
#define NEO_TILE_TOP
First tile is at top of matrix.
Definition: Adafruit_NeoMatrix.h:67
#define NEO_TILE_LEFT
First tile is at left of matrix.
Definition: Adafruit_NeoMatrix.h:69
static uint16_t Color(uint8_t r, uint8_t g, uint8_t b)
Quantize a 24-bit RGB color value to 16-bit &#39;565&#39; format.
Definition: Adafruit_NeoMatrix.cpp:103
void drawPixel(int16_t x, int16_t y, uint16_t color)
Pixel-drawing function for Adafruit_GFX.
Definition: Adafruit_NeoMatrix.cpp:116
void setPassThruColor(void)
Stop using pass-through color, return to normal 16-bit color usage.
Definition: Adafruit_NeoMatrix.cpp:114
Class for using NeoPixel matrices with the GFX graphics library.
Definition: Adafruit_NeoMatrix.h:82