├── .github
├── ISSUE_TEMPLATE.md
├── PULL_REQUEST_TEMPLATE.md
└── workflows
│ └── githubci.yml
├── .gitignore
├── Adafruit_DotStarMatrix.cpp
├── Adafruit_DotStarMatrix.h
├── COPYING
├── README.md
├── examples
├── dotstar_wing
│ └── dotstar_wing.ino
├── matrixtest
│ └── matrixtest.pde
└── tiletest
│ └── tiletest.pde
├── extras
└── gamma.c
├── gamma.h
└── library.properties
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Thank you for opening an issue on an Adafruit Arduino library repository. To
2 | improve the speed of resolution please review the following guidelines and
3 | common troubleshooting steps below before creating the issue:
4 |
5 | - **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
6 | the forums at http://forums.adafruit.com to ask questions and troubleshoot why
7 | something isn't working as expected. In many cases the problem is a common issue
8 | that you will more quickly receive help from the forum community. GitHub issues
9 | are meant for known defects in the code. If you don't know if there is a defect
10 | in the code then start with troubleshooting on the forum first.
11 |
12 | - **If following a tutorial or guide be sure you didn't miss a step.** Carefully
13 | check all of the steps and commands to run have been followed. Consult the
14 | forum if you're unsure or have questions about steps in a guide/tutorial.
15 |
16 | - **For Arduino projects check these very common issues to ensure they don't apply**:
17 |
18 | - For uploading sketches or communicating with the board make sure you're using
19 | a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
20 | very hard to tell the difference between a data and charge cable! Try using the
21 | cable with other devices or swapping to another cable to confirm it is not
22 | the problem.
23 |
24 | - **Be sure you are supplying adequate power to the board.** Check the specs of
25 | your board and plug in an external power supply. In many cases just
26 | plugging a board into your computer is not enough to power it and other
27 | peripherals.
28 |
29 | - **Double check all soldering joints and connections.** Flakey connections
30 | cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
31 |
32 | - **Ensure you are using an official Arduino or Adafruit board.** We can't
33 | guarantee a clone board will have the same functionality and work as expected
34 | with this code and don't support them.
35 |
36 | If you're sure this issue is a defect in the code and checked the steps above
37 | please fill in the following fields to provide enough troubleshooting information.
38 | You may delete the guideline and text above to just leave the following details:
39 |
40 | - Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
41 |
42 | - Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
43 | VERSION HERE**
44 |
45 | - List the steps to reproduce the problem below (if possible attach a sketch or
46 | copy the sketch code in too): **LIST REPRO STEPS BELOW**
47 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Thank you for creating a pull request to contribute to Adafruit's GitHub code!
2 | Before you open the request please review the following guidelines and tips to
3 | help it be more easily integrated:
4 |
5 | - **Describe the scope of your change--i.e. what the change does and what parts
6 | of the code were modified.** This will help us understand any risks of integrating
7 | the code.
8 |
9 | - **Describe any known limitations with your change.** For example if the change
10 | doesn't apply to a supported platform of the library please mention it.
11 |
12 | - **Please run any tests or examples that can exercise your modified code.** We
13 | strive to not break users of the code and running tests/examples helps with this
14 | process.
15 |
16 | Thank you again for contributing! We will try to test and integrate the change
17 | as soon as we can, but be aware we have many GitHub repositories to manage and
18 | can't immediately respond to every request. There is no need to bump or check in
19 | on a pull request (it will clutter the discussion of the request).
20 |
21 | Also don't be worried if the request is closed or not integrated--sometimes the
22 | priorities of Adafruit's GitHub code (education, ease of use) might not match the
23 | priorities of the pull request. Don't fret, the open source community thrives on
24 | forks and GitHub makes it easy to keep your changes in a forked repo.
25 |
26 | After reviewing the guidelines above you can delete this text from the pull request.
27 |
--------------------------------------------------------------------------------
/.github/workflows/githubci.yml:
--------------------------------------------------------------------------------
1 | name: Arduino Library CI
2 |
3 | on: [pull_request, push, repository_dispatch]
4 |
5 | jobs:
6 | build:
7 | runs-on: ubuntu-latest
8 |
9 | steps:
10 | - uses: actions/setup-python@v4
11 | with:
12 | python-version: '3.x'
13 | - uses: actions/checkout@v3
14 | - uses: actions/checkout@v3
15 | with:
16 | repository: adafruit/ci-arduino
17 | path: ci
18 |
19 | - name: pre-install
20 | run: bash ci/actions_install.sh
21 |
22 | - name: test platforms
23 | run: python3 ci/build_platform.py main_platforms
24 |
25 | - name: clang
26 | run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
27 |
28 | - name: doxygen
29 | env:
30 | GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
31 | PRETTYNAME : "Adafruit DotStarMatrix"
32 | run: bash ci/doxy_gen_and_deploy.sh
33 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Our handy .gitignore for automation ease
2 | Doxyfile*
3 | doxygen_sqlite3.db
4 | html
5 |
--------------------------------------------------------------------------------
/Adafruit_DotStarMatrix.cpp:
--------------------------------------------------------------------------------
1 | /*!
2 | * @file Adafruit_DotStarMatrix.cpp
3 | *
4 | * @mainpage GFX-compatible layer for DotStar matrices.
5 | *
6 | * @section intro_sec Introduction
7 | *
8 | * Arduino library to control single and tiled matrices of APA102-based
9 | * RGB LED devices such as displays assembled from DotStar strips, making
10 | * them compatible with the Adafruit_GFX graphics library.
11 | *
12 | * Adafruit invests time and resources providing this open source code,
13 | * please support Adafruit and open-source hardware by purchasing
14 | * products from Adafruit!
15 | *
16 | * @section dependencies Dependencies
17 | *
18 | * This library depends on Adafruit_DotStar
20 | * and Adafruit_GFX
22 | * being present on your system. Please make sure you have installed the
23 | * latest versions before using this library.
24 | *
25 | * @section author Author
26 | *
27 | * Written by Phil Burgess / Paint Your Dragon for Adafruit Industries.
28 | *
29 | * @section license License
30 | *
31 | * This file is part of the Adafruit DotStarMatrix library.
32 | *
33 | * DotStarMatrix is free software: you can redistribute it and/or modify
34 | * it under the terms of the GNU Lesser General Public License as
35 | * published by the Free Software Foundation, either version 3 of
36 | * the License, or (at your option) any later version.
37 | *
38 | * DotStarMatrix is distributed in the hope that it will be useful,
39 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
40 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 | * GNU Lesser General Public License for more details.
42 | *
43 | * You should have received a copy of the GNU Lesser General Public
44 | * License along with DotStarMatrix. If not, see
45 | * .
46 | *
47 | */
48 |
49 | #include "gamma.h"
50 | #include
51 | #include
52 | #ifdef __AVR__
53 | #include
54 | #elif defined(ESP8266)
55 | #include
56 | #else
57 | #ifndef pgm_read_byte
58 | #define pgm_read_byte(addr) \
59 | (*(const unsigned char *)(addr)) ///< PROGMEM concept doesn't apply on ESP8266
60 | #endif
61 | #endif
62 |
63 | #ifndef _swap_uint16_t
64 | #define _swap_uint16_t(a, b) \
65 | { \
66 | uint16_t t = a; \
67 | a = b; \
68 | b = t; \
69 | } ///< Swap contents of two uint16_t variables
70 | #endif
71 |
72 | // Constructor for single matrix w/hardware SPI:
73 | Adafruit_DotStarMatrix::Adafruit_DotStarMatrix(int w, int h, uint8_t matrixType,
74 | uint8_t ledType)
75 | : Adafruit_GFX(w, h), Adafruit_DotStar(w * h, ledType), type(matrixType),
76 | matrixWidth(w), matrixHeight(h), tilesX(0), tilesY(0), remapFn(NULL) {}
77 |
78 | // Constructor for single matrix w/bitbang SPI:
79 | Adafruit_DotStarMatrix::Adafruit_DotStarMatrix(int w, int h, uint8_t d,
80 | uint8_t c, uint8_t matrixType,
81 | uint8_t ledType)
82 | : Adafruit_GFX(w, h), Adafruit_DotStar(w * h, d, c, ledType),
83 | type(matrixType), matrixWidth(w), matrixHeight(h), tilesX(0), tilesY(0),
84 | remapFn(NULL) {}
85 |
86 | // Constructor for tiled matrices w/hardware SPI:
87 | Adafruit_DotStarMatrix::Adafruit_DotStarMatrix(uint8_t mW, uint8_t mH,
88 | uint8_t tX, uint8_t tY,
89 | uint8_t matrixType,
90 | uint8_t ledType)
91 | : Adafruit_GFX(mW * tX, mH * tY),
92 | Adafruit_DotStar(mW * mH * tX * tY, ledType), type(matrixType),
93 | matrixWidth(mW), matrixHeight(mH), tilesX(tX), tilesY(tY), remapFn(NULL) {
94 | }
95 |
96 | // Constructor for tiled matrices w/bitbang SPI:
97 | Adafruit_DotStarMatrix::Adafruit_DotStarMatrix(uint8_t mW, uint8_t mH,
98 | uint8_t tX, uint8_t tY,
99 | uint8_t d, uint8_t c,
100 | uint8_t matrixType,
101 | uint8_t ledType)
102 | : Adafruit_GFX(mW * tX, mH * tY),
103 | Adafruit_DotStar(mW * mH * tX * tY, d, c, ledType), type(matrixType),
104 | matrixWidth(mW), matrixHeight(mH), tilesX(tX), tilesY(tY), remapFn(NULL) {
105 | }
106 |
107 | // Expand 16-bit input color (Adafruit_GFX colorspace) to 24-bit (DotStar)
108 | // (w/gamma adjustment)
109 | static uint32_t expandColor(uint16_t color) {
110 | return ((uint32_t)pgm_read_byte(&gamma5[color >> 11]) << 16) |
111 | ((uint32_t)pgm_read_byte(&gamma6[(color >> 5) & 0x3F]) << 8) |
112 | pgm_read_byte(&gamma5[color & 0x1F]);
113 | }
114 |
115 | // Downgrade 24-bit color to 16-bit (add reverse gamma lookup here?)
116 | uint16_t Adafruit_DotStarMatrix::Color(uint8_t r, uint8_t g, uint8_t b) {
117 | return ((uint16_t)(r & 0xF8) << 8) | ((uint16_t)(g & 0xFC) << 3) | (b >> 3);
118 | }
119 |
120 | // Pass raw color value to set/enable passthrough
121 | void Adafruit_DotStarMatrix::setPassThruColor(uint32_t c) {
122 | passThruColor = c;
123 | passThruFlag = true;
124 | }
125 |
126 | // Call without a value to reset (disable passthrough)
127 | void Adafruit_DotStarMatrix::setPassThruColor(void) { passThruFlag = false; }
128 |
129 | void Adafruit_DotStarMatrix::drawPixel(int16_t x, int16_t y, uint16_t color) {
130 |
131 | if ((x < 0) || (y < 0) || (x >= _width) || (y >= _height))
132 | return;
133 |
134 | int16_t t;
135 | switch (rotation) {
136 | case 1:
137 | t = x;
138 | x = WIDTH - 1 - y;
139 | y = t;
140 | break;
141 | case 2:
142 | x = WIDTH - 1 - x;
143 | y = HEIGHT - 1 - y;
144 | break;
145 | case 3:
146 | t = x;
147 | x = y;
148 | y = HEIGHT - 1 - t;
149 | break;
150 | }
151 |
152 | int tileOffset = 0, pixelOffset;
153 |
154 | if (remapFn) { // Custom X/Y remapping function
155 | pixelOffset = (*remapFn)(x, y);
156 | } else { // Standard single matrix or tiled matrices
157 |
158 | uint8_t corner = type & DS_MATRIX_CORNER;
159 | uint16_t minor, major, majorScale;
160 |
161 | if (tilesX) { // Tiled display, multiple matrices
162 | uint16_t tile;
163 |
164 | minor = x / matrixWidth; // Tile # X/Y; presume row major to
165 | major = y / matrixHeight, // start (will swap later if needed)
166 | x = x - (minor * matrixWidth); // Pixel X/Y within tile
167 | y = y - (major * matrixHeight); // (-* is less math than modulo)
168 |
169 | // Determine corner of entry, flip axes if needed
170 | if (type & DS_TILE_RIGHT)
171 | minor = tilesX - 1 - minor;
172 | if (type & DS_TILE_BOTTOM)
173 | major = tilesY - 1 - major;
174 |
175 | // Determine actual major axis of tiling
176 | if ((type & DS_TILE_AXIS) == DS_TILE_ROWS) {
177 | majorScale = tilesX;
178 | } else {
179 | _swap_uint16_t(major, minor);
180 | majorScale = tilesY;
181 | }
182 |
183 | // Determine tile number
184 | if ((type & DS_TILE_SEQUENCE) == DS_TILE_PROGRESSIVE) {
185 | // All tiles in same order
186 | tile = major * majorScale + minor;
187 | } else {
188 | // Zigzag; alternate rows change direction. On these rows,
189 | // this also flips the starting corner of the matrix for the
190 | // pixel math later.
191 | if (major & 1) {
192 | corner ^= DS_MATRIX_CORNER;
193 | tile = (major + 1) * majorScale - 1 - minor;
194 | } else {
195 | tile = major * majorScale + minor;
196 | }
197 | }
198 |
199 | // Index of first pixel in tile
200 | tileOffset = tile * matrixWidth * matrixHeight;
201 |
202 | } // else no tiling (handle as single tile)
203 |
204 | // Find pixel number within tile
205 | minor = x; // Presume row major to start (will swap later if needed)
206 | major = y;
207 |
208 | // Determine corner of entry, flip axes if needed
209 | if (corner & DS_MATRIX_RIGHT)
210 | minor = matrixWidth - 1 - minor;
211 | if (corner & DS_MATRIX_BOTTOM)
212 | major = matrixHeight - 1 - major;
213 |
214 | // Determine actual major axis of matrix
215 | if ((type & DS_MATRIX_AXIS) == DS_MATRIX_ROWS) {
216 | majorScale = matrixWidth;
217 | } else {
218 | _swap_uint16_t(major, minor);
219 | majorScale = matrixHeight;
220 | }
221 |
222 | // Determine pixel number within tile/matrix
223 | if ((type & DS_MATRIX_SEQUENCE) == DS_MATRIX_PROGRESSIVE) {
224 | // All lines in same order
225 | pixelOffset = major * majorScale + minor;
226 | } else {
227 | // Zigzag; alternate rows change direction.
228 | if (major & 1)
229 | pixelOffset = (major + 1) * majorScale - 1 - minor;
230 | else
231 | pixelOffset = major * majorScale + minor;
232 | }
233 | }
234 |
235 | setPixelColor(tileOffset + pixelOffset,
236 | passThruFlag ? passThruColor : expandColor(color));
237 | }
238 |
239 | void Adafruit_DotStarMatrix::fillScreen(uint16_t color) {
240 | uint16_t i, n;
241 | uint32_t c;
242 |
243 | c = passThruFlag ? passThruColor : expandColor(color);
244 | n = numPixels();
245 | for (i = 0; i < n; i++)
246 | setPixelColor(i, c);
247 | }
248 |
249 | void Adafruit_DotStarMatrix::setRemapFunction(uint16_t (*fn)(uint16_t,
250 | uint16_t)) {
251 | remapFn = fn;
252 | }
253 |
--------------------------------------------------------------------------------
/Adafruit_DotStarMatrix.h:
--------------------------------------------------------------------------------
1 | /*!
2 | * @file Adafruit_DotStarMatrix.h
3 | *
4 | * Arduino library to control single and tiled matrices of APA102-based
5 | * RGB LED devices such as displays assembled from DotStar strips, making
6 | * them compatible with the Adafruit_GFX graphics library.
7 | *
8 | * Adafruit invests time and resources providing this open source code,
9 | * please support Adafruit and open-source hardware by purchasing
10 | * products from Adafruit!
11 | *
12 | * Written by Phil Burgess / Paint Your Dragon for Adafruit Industries.
13 | *
14 | * This file is part of the Adafruit DotStarMatrix library.
15 | *
16 | * DotStarMatrix is free software: you can redistribute it and/or modify
17 | * it under the terms of the GNU Lesser General Public License as
18 | * published by the Free Software Foundation, either version 3 of
19 | * the License, or (at your option) any later version.
20 | *
21 | * DotStarMatrix is distributed in the hope that it will be useful,
22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 | * GNU Lesser General Public License for more details.
25 | *
26 | * You should have received a copy of the GNU Lesser General Public
27 | * License along with DotStarMatrix. If not, see
28 | * .
29 | *
30 | */
31 |
32 | #ifndef _ADAFRUIT_DSMATRIX_H_
33 | #define _ADAFRUIT_DSMATRIX_H_
34 |
35 | #if ARDUINO >= 100
36 | #include
37 | #else
38 | #include
39 | #include
40 | #endif
41 | #include
42 | #include
43 |
44 | // Matrix layout information is passed in the 'matrixType' parameter for
45 | // each constructor (the parameter immediately following is the LED type
46 | // from Adafruit_DotStar.h).
47 |
48 | // These define the layout for a single 'unified' matrix (e.g. one made
49 | // from DotStar strips), or for the pixels within each matrix of a tiled
50 | // display.
51 |
52 | #define DS_MATRIX_TOP 0x00 ///< Pixel 0 is at top of matrix
53 | #define DS_MATRIX_BOTTOM 0x01 ///< Pixel 0 is at bottom of matrix
54 | #define DS_MATRIX_LEFT 0x00 ///< Pixel 0 is at left of matrix
55 | #define DS_MATRIX_RIGHT 0x02 ///< Pixel 0 is at right of matrix
56 | #define DS_MATRIX_CORNER 0x03 ///< Bitmask for pixel 0 matrix corner
57 | #define DS_MATRIX_ROWS 0x00 ///< Matrix is row major (horizontal)
58 | #define DS_MATRIX_COLUMNS 0x04 ///< Matrix is column major (vertical)
59 | #define DS_MATRIX_AXIS 0x04 ///< Bitmask for row/column layout
60 | #define DS_MATRIX_PROGRESSIVE 0x00 ///< Same pixel order across each line
61 | #define DS_MATRIX_ZIGZAG 0x08 ///< Pixel order reverses between lines
62 | #define DS_MATRIX_SEQUENCE 0x08 ///< Bitmask for pixel line order
63 |
64 | // These apply only to tiled displays (multiple matrices):
65 |
66 | #define DS_TILE_TOP 0x00 ///< First tile is at top of matrix
67 | #define DS_TILE_BOTTOM 0x10 ///< First tile is at bottom of matrix
68 | #define DS_TILE_LEFT 0x00 ///< First tile is at left of matrix
69 | #define DS_TILE_RIGHT 0x20 ///< First tile is at right of matrix
70 | #define DS_TILE_CORNER 0x30 ///< Bitmask for first tile corner
71 | #define DS_TILE_ROWS 0x00 ///< Tiles ordered in rows
72 | #define DS_TILE_COLUMNS 0x40 ///< Tiles ordered in columns
73 | #define DS_TILE_AXIS 0x40 ///< Bitmask for tile H/V orientation
74 | #define DS_TILE_PROGRESSIVE 0x00 ///< Same tile order across each line
75 | #define DS_TILE_ZIGZAG 0x80 ///< Tile order reverses between lines
76 | #define DS_TILE_SEQUENCE 0x80 ///< Bitmask for tile line order
77 |
78 | /**
79 | * @brief Class for using DotStar matrices with the GFX graphics library.
80 | */
81 | class Adafruit_DotStarMatrix : public Adafruit_GFX, public Adafruit_DotStar {
82 |
83 | public:
84 | /**
85 | * @brief Construct a single (non-tiled) matrix using hardware SPI out.
86 | * @param w Matrix width in pixels.
87 | * @param h Matrix height in pixels.
88 | * @param matrixType Matrix layout - add together DS_MATRIX_* values
89 | * to declare orientation, rotation, etc.
90 | * @param ledType DotStar LED type, similar to Adafruit_DotStar
91 | * constructor (e.g. DOTSTAR_RGB).
92 | */
93 | Adafruit_DotStarMatrix(int w, int h, uint8_t matrixType, uint8_t ledType);
94 |
95 | /**
96 | * @brief Construct a single (non-tiled) matrix using software (bitbang)
97 | * SPI out.
98 | * @param w Matrix width in pixels.
99 | * @param h Matrix height in pixels.
100 | * @param d Arduino pin number for SPI data out.
101 | * @param c Arduino pin number for SPI clock out.
102 | * @param matrixType Matrix layout - add together DS_MATRIX_* values
103 | * to declare orientation, rotation, etc.
104 | * @param ledType DotStar LED type, similar to Adafruit_DotStar
105 | * constructor (e.g. DOTSTAR_RGB).
106 | */
107 | Adafruit_DotStarMatrix(int w, int h, uint8_t d, uint8_t c, uint8_t matrixType,
108 | uint8_t ledType);
109 |
110 | /**
111 | * @brief Construct a tiled matrix using hardware SPI out.
112 | * @param matrixW Individual sub-matrix (tile) width in pixels.
113 | * @param matrixH Individual sub-matrix (tile) height in pixels.
114 | * @param tX Number of tiles on the X (horizontal) axis.
115 | * @param tY Number of tiles on the Y (vertical) axis.
116 | * @param matrixType Tiled matrix layout - add together DS_MATRIX_* and
117 | * DS_TILE_* values to declare orientation, rotation,
118 | * etc.
119 | * @param ledType DotStar LED type, similar to Adafruit_DotStar
120 | * constructor (e.g. DOTSTAR_RGB).
121 | */
122 | Adafruit_DotStarMatrix(uint8_t matrixW, uint8_t matrixH, uint8_t tX,
123 | uint8_t tY, uint8_t matrixType, uint8_t ledType);
124 |
125 | /**
126 | * @brief Construct a tiled matrix using software (bitbang) SPI out.
127 | * @param matrixW Individual sub-matrix (tile) width in pixels.
128 | * @param matrixH Individual sub-matrix (tile) height in pixels.
129 | * @param tX Number of tiles on the X (horizontal) axis.
130 | * @param tY Number of tiles on the Y (vertical) axis.
131 | * @param d Arduino pin number for SPI data out.
132 | * @param c Arduino pin number for SPI clock out.
133 | * @param matrixType Tiled matrix layout - add together DS_MATRIX_* and
134 | * DS_TILE_* values to declare orientation, rotation,
135 | * etc.
136 | * @param ledType DotStar LED type, similar to Adafruit_DotStar
137 | * constructor (e.g. DOTSTAR_RGB).
138 | */
139 | // Constructor for tiled matrices w/bitbang SPI:
140 | Adafruit_DotStarMatrix(uint8_t matrixW, uint8_t matrixH, uint8_t tX,
141 | uint8_t tY, uint8_t d, uint8_t c, uint8_t matrixType,
142 | uint8_t ledType);
143 |
144 | /**
145 | * @brief Pixel-drawing function for Adafruit_GFX.
146 | * @param x Pixel column (0 = left edge, unless rotation used).
147 | * @param y Pixel row (0 = top edge, unless rotation used).
148 | * @param color Pixel color in 16-bit '565' RGB format.
149 | */
150 | void drawPixel(int16_t x, int16_t y, uint16_t color);
151 |
152 | /**
153 | * @brief Fill matrix with a single color.
154 | * @param color Pixel color in 16-bit '565' RGB format.
155 | */
156 | void fillScreen(uint16_t color);
157 |
158 | /**
159 | * @brief Pass-through is a kludge that lets you override the current
160 | * drawing color with a 'raw' RGB (or RGBW) value that's issued
161 | * directly to pixel(s), side-stepping the 16-bit color limitation
162 | * of Adafruit_GFX. This is not without some limitations of its
163 | * own -- for example, it won't work in conjunction with the
164 | * background color feature when drawing text or bitmaps (you'll
165 | * just get a solid rect of color), only 'transparent'
166 | * text/bitmaps. Also, no gamma correction.
167 | * Remember to UNSET the passthrough color immediately when done
168 | * with it (call with no value)!
169 | * @param c Pixel color in packed 32-bit 0RGB or WRGB format.
170 | */
171 | void setPassThruColor(uint32_t c);
172 |
173 | /**
174 | * @brief Stop using pass-through color, return to normal 16-bit color
175 | * usage.
176 | */
177 | void setPassThruColor(void);
178 |
179 | /**
180 | * @brief Register a function for mapping X/Y coordinates to absolute
181 | * pixel indices (for unusual layouts if if DS_MATRIX_* and
182 | * DS_TILE_* settings do not provide sufficient control).
183 | * @param fn Pointer to function that accepts two uint16_t arguments
184 | * (column and row), returns absolute pixel index.
185 | */
186 | void setRemapFunction(uint16_t (*fn)(uint16_t, uint16_t));
187 |
188 | /**
189 | * @brief Quantize a 24-bit RGB color value to 16-bit '565' format.
190 | * @param r Red component (0 to 255).
191 | * @param g Green component (0 to 255).
192 | * @param b Blue component (0 to 255).
193 | * @return uint16_t Quantized color for GFX drawing functions.
194 | */
195 | static uint16_t Color(uint8_t r, uint8_t g, uint8_t b);
196 |
197 | private:
198 | const uint8_t type;
199 | const uint8_t matrixWidth, matrixHeight, tilesX, tilesY;
200 | uint16_t (*remapFn)(uint16_t x, uint16_t y);
201 |
202 | uint32_t passThruColor;
203 | boolean passThruFlag = false;
204 | };
205 |
206 | #endif // _ADAFRUIT_DSMATRIX_H_
207 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 |
2 | GNU GENERAL PUBLIC LICENSE
3 | Version 3, 29 June 2007
4 |
5 | Copyright (C) 2007 Free Software Foundation, Inc.
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The GNU General Public License is a free, copyleft license for
12 | software and other kinds of works.
13 |
14 | The licenses for most software and other practical works are designed
15 | to take away your freedom to share and change the works. By contrast,
16 | the GNU General Public License is intended to guarantee your freedom to
17 | share and change all versions of a program--to make sure it remains free
18 | software for all its users. We, the Free Software Foundation, use the
19 | GNU General Public License for most of our software; it applies also to
20 | any other work released this way by its authors. You can apply it to
21 | your programs, too.
22 |
23 | When we speak of free software, we are referring to freedom, not
24 | price. Our General Public Licenses are designed to make sure that you
25 | have the freedom to distribute copies of free software (and charge for
26 | them if you wish), that you receive source code or can get it if you
27 | want it, that you can change the software or use pieces of it in new
28 | free programs, and that you know you can do these things.
29 |
30 | To protect your rights, we need to prevent others from denying you
31 | these rights or asking you to surrender the rights. Therefore, you have
32 | certain responsibilities if you distribute copies of the software, or if
33 | you modify it: responsibilities to respect the freedom of others.
34 |
35 | For example, if you distribute copies of such a program, whether
36 | gratis or for a fee, you must pass on to the recipients the same
37 | freedoms that you received. You must make sure that they, too, receive
38 | or can get the source code. And you must show them these terms so they
39 | know their rights.
40 |
41 | Developers that use the GNU GPL protect your rights with two steps:
42 | (1) assert copyright on the software, and (2) offer you this License
43 | giving you legal permission to copy, distribute and/or modify it.
44 |
45 | For the developers' and authors' protection, the GPL clearly explains
46 | that there is no warranty for this free software. For both users' and
47 | authors' sake, the GPL requires that modified versions be marked as
48 | changed, so that their problems will not be attributed erroneously to
49 | authors of previous versions.
50 |
51 | Some devices are designed to deny users access to install or run
52 | modified versions of the software inside them, although the manufacturer
53 | can do so. This is fundamentally incompatible with the aim of
54 | protecting users' freedom to change the software. The systematic
55 | pattern of such abuse occurs in the area of products for individuals to
56 | use, which is precisely where it is most unacceptable. Therefore, we
57 | have designed this version of the GPL to prohibit the practice for those
58 | products. If such problems arise substantially in other domains, we
59 | stand ready to extend this provision to those domains in future versions
60 | of the GPL, as needed to protect the freedom of users.
61 |
62 | Finally, every program is threatened constantly by software patents.
63 | States should not allow patents to restrict development and use of
64 | software on general-purpose computers, but in those that do, we wish to
65 | avoid the special danger that patents applied to a free program could
66 | make it effectively proprietary. To prevent this, the GPL assures that
67 | patents cannot be used to render the program non-free.
68 |
69 | The precise terms and conditions for copying, distribution and
70 | modification follow.
71 |
72 | TERMS AND CONDITIONS
73 |
74 | 0. Definitions.
75 |
76 | "This License" refers to version 3 of the GNU General Public License.
77 |
78 | "Copyright" also means copyright-like laws that apply to other kinds of
79 | works, such as semiconductor masks.
80 |
81 | "The Program" refers to any copyrightable work licensed under this
82 | License. Each licensee is addressed as "you". "Licensees" and
83 | "recipients" may be individuals or organizations.
84 |
85 | To "modify" a work means to copy from or adapt all or part of the work
86 | in a fashion requiring copyright permission, other than the making of an
87 | exact copy. The resulting work is called a "modified version" of the
88 | earlier work or a work "based on" the earlier work.
89 |
90 | A "covered work" means either the unmodified Program or a work based
91 | on the Program.
92 |
93 | To "propagate" a work means to do anything with it that, without
94 | permission, would make you directly or secondarily liable for
95 | infringement under applicable copyright law, except executing it on a
96 | computer or modifying a private copy. Propagation includes copying,
97 | distribution (with or without modification), making available to the
98 | public, and in some countries other activities as well.
99 |
100 | To "convey" a work means any kind of propagation that enables other
101 | parties to make or receive copies. Mere interaction with a user through
102 | a computer network, with no transfer of a copy, is not conveying.
103 |
104 | An interactive user interface displays "Appropriate Legal Notices"
105 | to the extent that it includes a convenient and prominently visible
106 | feature that (1) displays an appropriate copyright notice, and (2)
107 | tells the user that there is no warranty for the work (except to the
108 | extent that warranties are provided), that licensees may convey the
109 | work under this License, and how to view a copy of this License. If
110 | the interface presents a list of user commands or options, such as a
111 | menu, a prominent item in the list meets this criterion.
112 |
113 | 1. Source Code.
114 |
115 | The "source code" for a work means the preferred form of the work
116 | for making modifications to it. "Object code" means any non-source
117 | form of a work.
118 |
119 | A "Standard Interface" means an interface that either is an official
120 | standard defined by a recognized standards body, or, in the case of
121 | interfaces specified for a particular programming language, one that
122 | is widely used among developers working in that language.
123 |
124 | The "System Libraries" of an executable work include anything, other
125 | than the work as a whole, that (a) is included in the normal form of
126 | packaging a Major Component, but which is not part of that Major
127 | Component, and (b) serves only to enable use of the work with that
128 | Major Component, or to implement a Standard Interface for which an
129 | implementation is available to the public in source code form. A
130 | "Major Component", in this context, means a major essential component
131 | (kernel, window system, and so on) of the specific operating system
132 | (if any) on which the executable work runs, or a compiler used to
133 | produce the work, or an object code interpreter used to run it.
134 |
135 | The "Corresponding Source" for a work in object code form means all
136 | the source code needed to generate, install, and (for an executable
137 | work) run the object code and to modify the work, including scripts to
138 | control those activities. However, it does not include the work's
139 | System Libraries, or general-purpose tools or generally available free
140 | programs which are used unmodified in performing those activities but
141 | which are not part of the work. For example, Corresponding Source
142 | includes interface definition files associated with source files for
143 | the work, and the source code for shared libraries and dynamically
144 | linked subprograms that the work is specifically designed to require,
145 | such as by intimate data communication or control flow between those
146 | subprograms and other parts of the work.
147 |
148 | The Corresponding Source need not include anything that users
149 | can regenerate automatically from other parts of the Corresponding
150 | Source.
151 |
152 | The Corresponding Source for a work in source code form is that
153 | same work.
154 |
155 | 2. Basic Permissions.
156 |
157 | All rights granted under this License are granted for the term of
158 | copyright on the Program, and are irrevocable provided the stated
159 | conditions are met. This License explicitly affirms your unlimited
160 | permission to run the unmodified Program. The output from running a
161 | covered work is covered by this License only if the output, given its
162 | content, constitutes a covered work. This License acknowledges your
163 | rights of fair use or other equivalent, as provided by copyright law.
164 |
165 | You may make, run and propagate covered works that you do not
166 | convey, without conditions so long as your license otherwise remains
167 | in force. You may convey covered works to others for the sole purpose
168 | of having them make modifications exclusively for you, or provide you
169 | with facilities for running those works, provided that you comply with
170 | the terms of this License in conveying all material for which you do
171 | not control copyright. Those thus making or running the covered works
172 | for you must do so exclusively on your behalf, under your direction
173 | and control, on terms that prohibit them from making any copies of
174 | your copyrighted material outside their relationship with you.
175 |
176 | Conveying under any other circumstances is permitted solely under
177 | the conditions stated below. Sublicensing is not allowed; section 10
178 | makes it unnecessary.
179 |
180 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
181 |
182 | No covered work shall be deemed part of an effective technological
183 | measure under any applicable law fulfilling obligations under article
184 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
185 | similar laws prohibiting or restricting circumvention of such
186 | measures.
187 |
188 | When you convey a covered work, you waive any legal power to forbid
189 | circumvention of technological measures to the extent such circumvention
190 | is effected by exercising rights under this License with respect to
191 | the covered work, and you disclaim any intention to limit operation or
192 | modification of the work as a means of enforcing, against the work's
193 | users, your or third parties' legal rights to forbid circumvention of
194 | technological measures.
195 |
196 | 4. Conveying Verbatim Copies.
197 |
198 | You may convey verbatim copies of the Program's source code as you
199 | receive it, in any medium, provided that you conspicuously and
200 | appropriately publish on each copy an appropriate copyright notice;
201 | keep intact all notices stating that this License and any
202 | non-permissive terms added in accord with section 7 apply to the code;
203 | keep intact all notices of the absence of any warranty; and give all
204 | recipients a copy of this License along with the Program.
205 |
206 | You may charge any price or no price for each copy that you convey,
207 | and you may offer support or warranty protection for a fee.
208 |
209 | 5. Conveying Modified Source Versions.
210 |
211 | You may convey a work based on the Program, or the modifications to
212 | produce it from the Program, in the form of source code under the
213 | terms of section 4, provided that you also meet all of these conditions:
214 |
215 | a) The work must carry prominent notices stating that you modified
216 | it, and giving a relevant date.
217 |
218 | b) The work must carry prominent notices stating that it is
219 | released under this License and any conditions added under section
220 | 7. This requirement modifies the requirement in section 4 to
221 | "keep intact all notices".
222 |
223 | c) You must license the entire work, as a whole, under this
224 | License to anyone who comes into possession of a copy. This
225 | License will therefore apply, along with any applicable section 7
226 | additional terms, to the whole of the work, and all its parts,
227 | regardless of how they are packaged. This License gives no
228 | permission to license the work in any other way, but it does not
229 | invalidate such permission if you have separately received it.
230 |
231 | d) If the work has interactive user interfaces, each must display
232 | Appropriate Legal Notices; however, if the Program has interactive
233 | interfaces that do not display Appropriate Legal Notices, your
234 | work need not make them do so.
235 |
236 | A compilation of a covered work with other separate and independent
237 | works, which are not by their nature extensions of the covered work,
238 | and which are not combined with it such as to form a larger program,
239 | in or on a volume of a storage or distribution medium, is called an
240 | "aggregate" if the compilation and its resulting copyright are not
241 | used to limit the access or legal rights of the compilation's users
242 | beyond what the individual works permit. Inclusion of a covered work
243 | in an aggregate does not cause this License to apply to the other
244 | parts of the aggregate.
245 |
246 | 6. Conveying Non-Source Forms.
247 |
248 | You may convey a covered work in object code form under the terms
249 | of sections 4 and 5, provided that you also convey the
250 | machine-readable Corresponding Source under the terms of this License,
251 | in one of these ways:
252 |
253 | a) Convey the object code in, or embodied in, a physical product
254 | (including a physical distribution medium), accompanied by the
255 | Corresponding Source fixed on a durable physical medium
256 | customarily used for software interchange.
257 |
258 | b) Convey the object code in, or embodied in, a physical product
259 | (including a physical distribution medium), accompanied by a
260 | written offer, valid for at least three years and valid for as
261 | long as you offer spare parts or customer support for that product
262 | model, to give anyone who possesses the object code either (1) a
263 | copy of the Corresponding Source for all the software in the
264 | product that is covered by this License, on a durable physical
265 | medium customarily used for software interchange, for a price no
266 | more than your reasonable cost of physically performing this
267 | conveying of source, or (2) access to copy the
268 | Corresponding Source from a network server at no charge.
269 |
270 | c) Convey individual copies of the object code with a copy of the
271 | written offer to provide the Corresponding Source. This
272 | alternative is allowed only occasionally and noncommercially, and
273 | only if you received the object code with such an offer, in accord
274 | with subsection 6b.
275 |
276 | d) Convey the object code by offering access from a designated
277 | place (gratis or for a charge), and offer equivalent access to the
278 | Corresponding Source in the same way through the same place at no
279 | further charge. You need not require recipients to copy the
280 | Corresponding Source along with the object code. If the place to
281 | copy the object code is a network server, the Corresponding Source
282 | may be on a different server (operated by you or a third party)
283 | that supports equivalent copying facilities, provided you maintain
284 | clear directions next to the object code saying where to find the
285 | Corresponding Source. Regardless of what server hosts the
286 | Corresponding Source, you remain obligated to ensure that it is
287 | available for as long as needed to satisfy these requirements.
288 |
289 | e) Convey the object code using peer-to-peer transmission, provided
290 | you inform other peers where the object code and Corresponding
291 | Source of the work are being offered to the general public at no
292 | charge under subsection 6d.
293 |
294 | A separable portion of the object code, whose source code is excluded
295 | from the Corresponding Source as a System Library, need not be
296 | included in conveying the object code work.
297 |
298 | A "User Product" is either (1) a "consumer product", which means any
299 | tangible personal property which is normally used for personal, family,
300 | or household purposes, or (2) anything designed or sold for incorporation
301 | into a dwelling. In determining whether a product is a consumer product,
302 | doubtful cases shall be resolved in favor of coverage. For a particular
303 | product received by a particular user, "normally used" refers to a
304 | typical or common use of that class of product, regardless of the status
305 | of the particular user or of the way in which the particular user
306 | actually uses, or expects or is expected to use, the product. A product
307 | is a consumer product regardless of whether the product has substantial
308 | commercial, industrial or non-consumer uses, unless such uses represent
309 | the only significant mode of use of the product.
310 |
311 | "Installation Information" for a User Product means any methods,
312 | procedures, authorization keys, or other information required to install
313 | and execute modified versions of a covered work in that User Product from
314 | a modified version of its Corresponding Source. The information must
315 | suffice to ensure that the continued functioning of the modified object
316 | code is in no case prevented or interfered with solely because
317 | modification has been made.
318 |
319 | If you convey an object code work under this section in, or with, or
320 | specifically for use in, a User Product, and the conveying occurs as
321 | part of a transaction in which the right of possession and use of the
322 | User Product is transferred to the recipient in perpetuity or for a
323 | fixed term (regardless of how the transaction is characterized), the
324 | Corresponding Source conveyed under this section must be accompanied
325 | by the Installation Information. But this requirement does not apply
326 | if neither you nor any third party retains the ability to install
327 | modified object code on the User Product (for example, the work has
328 | been installed in ROM).
329 |
330 | The requirement to provide Installation Information does not include a
331 | requirement to continue to provide support service, warranty, or updates
332 | for a work that has been modified or installed by the recipient, or for
333 | the User Product in which it has been modified or installed. Access to a
334 | network may be denied when the modification itself materially and
335 | adversely affects the operation of the network or violates the rules and
336 | protocols for communication across the network.
337 |
338 | Corresponding Source conveyed, and Installation Information provided,
339 | in accord with this section must be in a format that is publicly
340 | documented (and with an implementation available to the public in
341 | source code form), and must require no special password or key for
342 | unpacking, reading or copying.
343 |
344 | 7. Additional Terms.
345 |
346 | "Additional permissions" are terms that supplement the terms of this
347 | License by making exceptions from one or more of its conditions.
348 | Additional permissions that are applicable to the entire Program shall
349 | be treated as though they were included in this License, to the extent
350 | that they are valid under applicable law. If additional permissions
351 | apply only to part of the Program, that part may be used separately
352 | under those permissions, but the entire Program remains governed by
353 | this License without regard to the additional permissions.
354 |
355 | When you convey a copy of a covered work, you may at your option
356 | remove any additional permissions from that copy, or from any part of
357 | it. (Additional permissions may be written to require their own
358 | removal in certain cases when you modify the work.) You may place
359 | additional permissions on material, added by you to a covered work,
360 | for which you have or can give appropriate copyright permission.
361 |
362 | Notwithstanding any other provision of this License, for material you
363 | add to a covered work, you may (if authorized by the copyright holders of
364 | that material) supplement the terms of this License with terms:
365 |
366 | a) Disclaiming warranty or limiting liability differently from the
367 | terms of sections 15 and 16 of this License; or
368 |
369 | b) Requiring preservation of specified reasonable legal notices or
370 | author attributions in that material or in the Appropriate Legal
371 | Notices displayed by works containing it; or
372 |
373 | c) Prohibiting misrepresentation of the origin of that material, or
374 | requiring that modified versions of such material be marked in
375 | reasonable ways as different from the original version; or
376 |
377 | d) Limiting the use for publicity purposes of names of licensors or
378 | authors of the material; or
379 |
380 | e) Declining to grant rights under trademark law for use of some
381 | trade names, trademarks, or service marks; or
382 |
383 | f) Requiring indemnification of licensors and authors of that
384 | material by anyone who conveys the material (or modified versions of
385 | it) with contractual assumptions of liability to the recipient, for
386 | any liability that these contractual assumptions directly impose on
387 | those licensors and authors.
388 |
389 | All other non-permissive additional terms are considered "further
390 | restrictions" within the meaning of section 10. If the Program as you
391 | received it, or any part of it, contains a notice stating that it is
392 | governed by this License along with a term that is a further
393 | restriction, you may remove that term. If a license document contains
394 | a further restriction but permits relicensing or conveying under this
395 | License, you may add to a covered work material governed by the terms
396 | of that license document, provided that the further restriction does
397 | not survive such relicensing or conveying.
398 |
399 | If you add terms to a covered work in accord with this section, you
400 | must place, in the relevant source files, a statement of the
401 | additional terms that apply to those files, or a notice indicating
402 | where to find the applicable terms.
403 |
404 | Additional terms, permissive or non-permissive, may be stated in the
405 | form of a separately written license, or stated as exceptions;
406 | the above requirements apply either way.
407 |
408 | 8. Termination.
409 |
410 | You may not propagate or modify a covered work except as expressly
411 | provided under this License. Any attempt otherwise to propagate or
412 | modify it is void, and will automatically terminate your rights under
413 | this License (including any patent licenses granted under the third
414 | paragraph of section 11).
415 |
416 | However, if you cease all violation of this License, then your
417 | license from a particular copyright holder is reinstated (a)
418 | provisionally, unless and until the copyright holder explicitly and
419 | finally terminates your license, and (b) permanently, if the copyright
420 | holder fails to notify you of the violation by some reasonable means
421 | prior to 60 days after the cessation.
422 |
423 | Moreover, your license from a particular copyright holder is
424 | reinstated permanently if the copyright holder notifies you of the
425 | violation by some reasonable means, this is the first time you have
426 | received notice of violation of this License (for any work) from that
427 | copyright holder, and you cure the violation prior to 30 days after
428 | your receipt of the notice.
429 |
430 | Termination of your rights under this section does not terminate the
431 | licenses of parties who have received copies or rights from you under
432 | this License. If your rights have been terminated and not permanently
433 | reinstated, you do not qualify to receive new licenses for the same
434 | material under section 10.
435 |
436 | 9. Acceptance Not Required for Having Copies.
437 |
438 | You are not required to accept this License in order to receive or
439 | run a copy of the Program. Ancillary propagation of a covered work
440 | occurring solely as a consequence of using peer-to-peer transmission
441 | to receive a copy likewise does not require acceptance. However,
442 | nothing other than this License grants you permission to propagate or
443 | modify any covered work. These actions infringe copyright if you do
444 | not accept this License. Therefore, by modifying or propagating a
445 | covered work, you indicate your acceptance of this License to do so.
446 |
447 | 10. Automatic Licensing of Downstream Recipients.
448 |
449 | Each time you convey a covered work, the recipient automatically
450 | receives a license from the original licensors, to run, modify and
451 | propagate that work, subject to this License. You are not responsible
452 | for enforcing compliance by third parties with this License.
453 |
454 | An "entity transaction" is a transaction transferring control of an
455 | organization, or substantially all assets of one, or subdividing an
456 | organization, or merging organizations. If propagation of a covered
457 | work results from an entity transaction, each party to that
458 | transaction who receives a copy of the work also receives whatever
459 | licenses to the work the party's predecessor in interest had or could
460 | give under the previous paragraph, plus a right to possession of the
461 | Corresponding Source of the work from the predecessor in interest, if
462 | the predecessor has it or can get it with reasonable efforts.
463 |
464 | You may not impose any further restrictions on the exercise of the
465 | rights granted or affirmed under this License. For example, you may
466 | not impose a license fee, royalty, or other charge for exercise of
467 | rights granted under this License, and you may not initiate litigation
468 | (including a cross-claim or counterclaim in a lawsuit) alleging that
469 | any patent claim is infringed by making, using, selling, offering for
470 | sale, or importing the Program or any portion of it.
471 |
472 | 11. Patents.
473 |
474 | A "contributor" is a copyright holder who authorizes use under this
475 | License of the Program or a work on which the Program is based. The
476 | work thus licensed is called the contributor's "contributor version".
477 |
478 | A contributor's "essential patent claims" are all patent claims
479 | owned or controlled by the contributor, whether already acquired or
480 | hereafter acquired, that would be infringed by some manner, permitted
481 | by this License, of making, using, or selling its contributor version,
482 | but do not include claims that would be infringed only as a
483 | consequence of further modification of the contributor version. For
484 | purposes of this definition, "control" includes the right to grant
485 | patent sublicenses in a manner consistent with the requirements of
486 | this License.
487 |
488 | Each contributor grants you a non-exclusive, worldwide, royalty-free
489 | patent license under the contributor's essential patent claims, to
490 | make, use, sell, offer for sale, import and otherwise run, modify and
491 | propagate the contents of its contributor version.
492 |
493 | In the following three paragraphs, a "patent license" is any express
494 | agreement or commitment, however denominated, not to enforce a patent
495 | (such as an express permission to practice a patent or covenant not to
496 | sue for patent infringement). To "grant" such a patent license to a
497 | party means to make such an agreement or commitment not to enforce a
498 | patent against the party.
499 |
500 | If you convey a covered work, knowingly relying on a patent license,
501 | and the Corresponding Source of the work is not available for anyone
502 | to copy, free of charge and under the terms of this License, through a
503 | publicly available network server or other readily accessible means,
504 | then you must either (1) cause the Corresponding Source to be so
505 | available, or (2) arrange to deprive yourself of the benefit of the
506 | patent license for this particular work, or (3) arrange, in a manner
507 | consistent with the requirements of this License, to extend the patent
508 | license to downstream recipients. "Knowingly relying" means you have
509 | actual knowledge that, but for the patent license, your conveying the
510 | covered work in a country, or your recipient's use of the covered work
511 | in a country, would infringe one or more identifiable patents in that
512 | country that you have reason to believe are valid.
513 |
514 | If, pursuant to or in connection with a single transaction or
515 | arrangement, you convey, or propagate by procuring conveyance of, a
516 | covered work, and grant a patent license to some of the parties
517 | receiving the covered work authorizing them to use, propagate, modify
518 | or convey a specific copy of the covered work, then the patent license
519 | you grant is automatically extended to all recipients of the covered
520 | work and works based on it.
521 |
522 | A patent license is "discriminatory" if it does not include within
523 | the scope of its coverage, prohibits the exercise of, or is
524 | conditioned on the non-exercise of one or more of the rights that are
525 | specifically granted under this License. You may not convey a covered
526 | work if you are a party to an arrangement with a third party that is
527 | in the business of distributing software, under which you make payment
528 | to the third party based on the extent of your activity of conveying
529 | the work, and under which the third party grants, to any of the
530 | parties who would receive the covered work from you, a discriminatory
531 | patent license (a) in connection with copies of the covered work
532 | conveyed by you (or copies made from those copies), or (b) primarily
533 | for and in connection with specific products or compilations that
534 | contain the covered work, unless you entered into that arrangement,
535 | or that patent license was granted, prior to 28 March 2007.
536 |
537 | Nothing in this License shall be construed as excluding or limiting
538 | any implied license or other defenses to infringement that may
539 | otherwise be available to you under applicable patent law.
540 |
541 | 12. No Surrender of Others' Freedom.
542 |
543 | If conditions are imposed on you (whether by court order, agreement or
544 | otherwise) that contradict the conditions of this License, they do not
545 | excuse you from the conditions of this License. If you cannot convey a
546 | covered work so as to satisfy simultaneously your obligations under this
547 | License and any other pertinent obligations, then as a consequence you may
548 | not convey it at all. For example, if you agree to terms that obligate you
549 | to collect a royalty for further conveying from those to whom you convey
550 | the Program, the only way you could satisfy both those terms and this
551 | License would be to refrain entirely from conveying the Program.
552 |
553 | 13. Use with the GNU Affero General Public License.
554 |
555 | Notwithstanding any other provision of this License, you have
556 | permission to link or combine any covered work with a work licensed
557 | under version 3 of the GNU Affero General Public License into a single
558 | combined work, and to convey the resulting work. The terms of this
559 | License will continue to apply to the part which is the covered work,
560 | but the special requirements of the GNU Affero General Public License,
561 | section 13, concerning interaction through a network will apply to the
562 | combination as such.
563 |
564 | 14. Revised Versions of this License.
565 |
566 | The Free Software Foundation may publish revised and/or new versions of
567 | the GNU General Public License from time to time. Such new versions will
568 | be similar in spirit to the present version, but may differ in detail to
569 | address new problems or concerns.
570 |
571 | Each version is given a distinguishing version number. If the
572 | Program specifies that a certain numbered version of the GNU General
573 | Public License "or any later version" applies to it, you have the
574 | option of following the terms and conditions either of that numbered
575 | version or of any later version published by the Free Software
576 | Foundation. If the Program does not specify a version number of the
577 | GNU General Public License, you may choose any version ever published
578 | by the Free Software Foundation.
579 |
580 | If the Program specifies that a proxy can decide which future
581 | versions of the GNU General Public License can be used, that proxy's
582 | public statement of acceptance of a version permanently authorizes you
583 | to choose that version for the Program.
584 |
585 | Later license versions may give you additional or different
586 | permissions. However, no additional obligations are imposed on any
587 | author or copyright holder as a result of your choosing to follow a
588 | later version.
589 |
590 | 15. Disclaimer of Warranty.
591 |
592 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
593 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
594 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
595 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
596 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
597 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
598 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
599 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
600 |
601 | 16. Limitation of Liability.
602 |
603 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
604 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
605 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
606 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
607 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
608 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
609 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
610 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
611 | SUCH DAMAGES.
612 |
613 | 17. Interpretation of Sections 15 and 16.
614 |
615 | If the disclaimer of warranty and limitation of liability provided
616 | above cannot be given local legal effect according to their terms,
617 | reviewing courts shall apply local law that most closely approximates
618 | an absolute waiver of all civil liability in connection with the
619 | Program, unless a warranty or assumption of liability accompanies a
620 | copy of the Program in return for a fee.
621 |
622 | END OF TERMS AND CONDITIONS
623 |
624 |
625 |
626 | LGPL ADDENDUM:
627 |
628 |
629 |
630 | GNU LESSER GENERAL PUBLIC LICENSE
631 | Version 3, 29 June 2007
632 |
633 | Copyright (C) 2007 Free Software Foundation, Inc.
634 | Everyone is permitted to copy and distribute verbatim copies
635 | of this license document, but changing it is not allowed.
636 |
637 |
638 | This version of the GNU Lesser General Public License incorporates
639 | the terms and conditions of version 3 of the GNU General Public
640 | License, supplemented by the additional permissions listed below.
641 |
642 | 0. Additional Definitions.
643 |
644 | As used herein, "this License" refers to version 3 of the GNU Lesser
645 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
646 | General Public License.
647 |
648 | "The Library" refers to a covered work governed by this License,
649 | other than an Application or a Combined Work as defined below.
650 |
651 | An "Application" is any work that makes use of an interface provided
652 | by the Library, but which is not otherwise based on the Library.
653 | Defining a subclass of a class defined by the Library is deemed a mode
654 | of using an interface provided by the Library.
655 |
656 | A "Combined Work" is a work produced by combining or linking an
657 | Application with the Library. The particular version of the Library
658 | with which the Combined Work was made is also called the "Linked
659 | Version".
660 |
661 | The "Minimal Corresponding Source" for a Combined Work means the
662 | Corresponding Source for the Combined Work, excluding any source code
663 | for portions of the Combined Work that, considered in isolation, are
664 | based on the Application, and not on the Linked Version.
665 |
666 | The "Corresponding Application Code" for a Combined Work means the
667 | object code and/or source code for the Application, including any data
668 | and utility programs needed for reproducing the Combined Work from the
669 | Application, but excluding the System Libraries of the Combined Work.
670 |
671 | 1. Exception to Section 3 of the GNU GPL.
672 |
673 | You may convey a covered work under sections 3 and 4 of this License
674 | without being bound by section 3 of the GNU GPL.
675 |
676 | 2. Conveying Modified Versions.
677 |
678 | If you modify a copy of the Library, and, in your modifications, a
679 | facility refers to a function or data to be supplied by an Application
680 | that uses the facility (other than as an argument passed when the
681 | facility is invoked), then you may convey a copy of the modified
682 | version:
683 |
684 | a) under this License, provided that you make a good faith effort to
685 | ensure that, in the event an Application does not supply the
686 | function or data, the facility still operates, and performs
687 | whatever part of its purpose remains meaningful, or
688 |
689 | b) under the GNU GPL, with none of the additional permissions of
690 | this License applicable to that copy.
691 |
692 | 3. Object Code Incorporating Material from Library Header Files.
693 |
694 | The object code form of an Application may incorporate material from
695 | a header file that is part of the Library. You may convey such object
696 | code under terms of your choice, provided that, if the incorporated
697 | material is not limited to numerical parameters, data structure
698 | layouts and accessors, or small macros, inline functions and templates
699 | (ten or fewer lines in length), you do both of the following:
700 |
701 | a) Give prominent notice with each copy of the object code that the
702 | Library is used in it and that the Library and its use are
703 | covered by this License.
704 |
705 | b) Accompany the object code with a copy of the GNU GPL and this license
706 | document.
707 |
708 | 4. Combined Works.
709 |
710 | You may convey a Combined Work under terms of your choice that,
711 | taken together, effectively do not restrict modification of the
712 | portions of the Library contained in the Combined Work and reverse
713 | engineering for debugging such modifications, if you also do each of
714 | the following:
715 |
716 | a) Give prominent notice with each copy of the Combined Work that
717 | the Library is used in it and that the Library and its use are
718 | covered by this License.
719 |
720 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
721 | document.
722 |
723 | c) For a Combined Work that displays copyright notices during
724 | execution, include the copyright notice for the Library among
725 | these notices, as well as a reference directing the user to the
726 | copies of the GNU GPL and this license document.
727 |
728 | d) Do one of the following:
729 |
730 | 0) Convey the Minimal Corresponding Source under the terms of this
731 | License, and the Corresponding Application Code in a form
732 | suitable for, and under terms that permit, the user to
733 | recombine or relink the Application with a modified version of
734 | the Linked Version to produce a modified Combined Work, in the
735 | manner specified by section 6 of the GNU GPL for conveying
736 | Corresponding Source.
737 |
738 | 1) Use a suitable shared library mechanism for linking with the
739 | Library. A suitable mechanism is one that (a) uses at run time
740 | a copy of the Library already present on the user's computer
741 | system, and (b) will operate properly with a modified version
742 | of the Library that is interface-compatible with the Linked
743 | Version.
744 |
745 | e) Provide Installation Information, but only if you would otherwise
746 | be required to provide such information under section 6 of the
747 | GNU GPL, and only to the extent that such information is
748 | necessary to install and execute a modified version of the
749 | Combined Work produced by recombining or relinking the
750 | Application with a modified version of the Linked Version. (If
751 | you use option 4d0, the Installation Information must accompany
752 | the Minimal Corresponding Source and Corresponding Application
753 | Code. If you use option 4d1, you must provide the Installation
754 | Information in the manner specified by section 6 of the GNU GPL
755 | for conveying Corresponding Source.)
756 |
757 | 5. Combined Libraries.
758 |
759 | You may place library facilities that are a work based on the
760 | Library side by side in a single library together with other library
761 | facilities that are not Applications and are not covered by this
762 | License, and convey such a combined library under terms of your
763 | choice, if you do both of the following:
764 |
765 | a) Accompany the combined library with a copy of the same work based
766 | on the Library, uncombined with any other library facilities,
767 | conveyed under the terms of this License.
768 |
769 | b) Give prominent notice with the combined library that part of it
770 | is a work based on the Library, and explaining where to find the
771 | accompanying uncombined form of the same work.
772 |
773 | 6. Revised Versions of the GNU Lesser General Public License.
774 |
775 | The Free Software Foundation may publish revised and/or new versions
776 | of the GNU Lesser General Public License from time to time. Such new
777 | versions will be similar in spirit to the present version, but may
778 | differ in detail to address new problems or concerns.
779 |
780 | Each version is given a distinguishing version number. If the
781 | Library as you received it specifies that a certain numbered version
782 | of the GNU Lesser General Public License "or any later version"
783 | applies to it, you have the option of following the terms and
784 | conditions either of that published version or of any later version
785 | published by the Free Software Foundation. If the Library as you
786 | received it does not specify a version number of the GNU Lesser
787 | General Public License, you may choose any version of the GNU Lesser
788 | General Public License ever published by the Free Software Foundation.
789 |
790 | If the Library as you received it specifies that a proxy can decide
791 | whether future versions of the GNU Lesser General Public License shall
792 | apply, that proxy's public statement of acceptance of any version is
793 | permanent authorization for you to choose that version for the
794 | Library.
795 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Adafruit_DotStarMatrix. [](https://github.com/adafruit/Adafruit_DotStarMatrix/actions)
2 |
3 | Adafruit_GFX-compatible library for DotStar matrices and grids. Controls single and tiled DotStar matrices or grids assembled from DotStar LED strip. Requires Adafruit_DotStar and Adafruit_GFX libraries.
4 |
5 | After downloading, rename folder to 'Adafruit_DotStarMatrix' and install in Arduino Libraries folder. Restart Arduino IDE, then open File->Sketchbook->Library->Adafruit_DotStarMatrix->matrixtest sketch.
6 |
--------------------------------------------------------------------------------
/examples/dotstar_wing/dotstar_wing.ino:
--------------------------------------------------------------------------------
1 | // Adafruit_DotStarMatrix example for single DotStar LED matrix.
2 | // Scrolls 'Adafruit' across the matrix.
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #if defined(ESP8266)
11 | #define DATAPIN 13
12 | #define CLOCKPIN 14
13 | #elif defined(ARDUINO_ADAFRUIT_FEATHER_ESP32C6)
14 | #define DATAPIN 0
15 | #define CLOCKPIN 15
16 | #elif defined(__AVR_ATmega328P__)
17 | #define DATAPIN 2
18 | #define CLOCKPIN 4
19 | #elif defined(ARDUINO_NRF52832_FEATHER)
20 | #define DATAPIN 7
21 | #define CLOCKPIN 16
22 | #elif defined(TEENSYDUINO)
23 | #define DATAPIN 9
24 | #define CLOCKPIN 5
25 | #elif defined(ARDUINO_ARCH_WICED)
26 | #define DATAPIN PA4
27 | #define CLOCKPIN PB5
28 | #elif defined(ESP32) && !defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
29 | #define DATAPIN 27
30 | #define CLOCKPIN 13
31 | #else // // 32u4, M0, M4, esp32-s2, nrf52840 and 328p
32 | #define DATAPIN 11
33 | #define CLOCKPIN 13
34 | #endif
35 |
36 | #define SHIFTDELAY 100
37 | #define BRIGHTNESS 20
38 |
39 | // MATRIX DECLARATION:
40 | // Parameter 1 = width of DotStar matrix
41 | // Parameter 2 = height of matrix
42 | // Parameter 3 = pin number (most are valid)
43 | // Parameter 4 = matrix layout flags, add together as needed:
44 | // DS_MATRIX_TOP, DS_MATRIX_BOTTOM, DS_MATRIX_LEFT, DS_MATRIX_RIGHT:
45 | // Position of the FIRST LED in the matrix; pick two, e.g.
46 | // DS_MATRIX_TOP + DS_MATRIX_LEFT for the top-left corner.
47 | // DS_MATRIX_ROWS, DS_MATRIX_COLUMNS: LEDs are arranged in horizontal
48 | // rows or in vertical columns, respectively; pick one or the other.
49 | // DS_MATRIX_PROGRESSIVE, DS_MATRIX_ZIGZAG: all rows/columns proceed
50 | // in the same order, or alternate lines reverse direction; pick one.
51 | // See example below for these values in action.
52 | // Parameter 5 = pixel type:
53 | // DOTSTAR_BRG Pixels are wired for BRG bitstream (most DotStar items)
54 | // DOTSTAR_GBR Pixels are wired for GBR bitstream (some older DotStars)
55 | // DOTSTAR_BGR Pixels are wired for BGR bitstream (APA102-2020 DotStars)
56 |
57 | Adafruit_DotStarMatrix matrix = Adafruit_DotStarMatrix(
58 | 12, 6, DATAPIN, CLOCKPIN,
59 | DS_MATRIX_BOTTOM + DS_MATRIX_LEFT +
60 | DS_MATRIX_ROWS + DS_MATRIX_PROGRESSIVE,
61 | DOTSTAR_BGR);
62 |
63 | const uint16_t primaryColors[] = {
64 | matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255)
65 | };
66 |
67 | const uint16_t adaColors[] = {
68 | matrix.Color(255, 0, 0), //A red
69 | matrix.Color(255, 125, 0), //D orange
70 | matrix.Color(200, 255, 0), //A yellowish
71 | matrix.Color(0, 255, 0), //F green
72 | matrix.Color(0, 255, 225), //R blue
73 | matrix.Color(150, 0, 255), //U purple
74 | matrix.Color(255, 0, 220), //I pink
75 | matrix.Color(255, 65, 0), //T reddish
76 | matrix.Color(255, 220, 0) //! orange/yellow
77 | };
78 |
79 | char adafruit[] = "ADAFRUIT!";
80 |
81 | void setup() {
82 | Serial.begin(115200);
83 |
84 | // uncomment to have wait
85 | //while (!Serial) delay(500);
86 |
87 | Serial.println("\nDotstar Matrix Wing");
88 | matrix.begin();
89 | matrix.setFont(&TomThumb);
90 | matrix.setTextWrap(false);
91 | matrix.setBrightness(BRIGHTNESS);
92 |
93 | for (byte i = 0; i < 3; i++) {
94 | matrix.fillScreen(primaryColors[i]);
95 | matrix.show();
96 | delay(500);
97 | }
98 | }
99 |
100 | int x = matrix.width();
101 | int pass = 0;
102 |
103 | void loop() {
104 | matrix.fillScreen(0);
105 | matrix.setCursor(x, 5);
106 | for (byte i = 0; i < strlen(adafruit); i++) {
107 | // set the color
108 | matrix.setTextColor(adaColors[i]);
109 | // write the letter
110 | matrix.print(adafruit[i]);
111 | }
112 |
113 | if (--x < -50) {
114 | x = matrix.width();
115 | }
116 |
117 | matrix.show();
118 | delay(SHIFTDELAY);
119 | }
120 |
--------------------------------------------------------------------------------
/examples/matrixtest/matrixtest.pde:
--------------------------------------------------------------------------------
1 | // Adafruit_DotStarMatrix example for single DotStar LED matrix.
2 | // Scrolls 'Howdy' across the matrix.
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #ifndef PSTR
9 | #define PSTR // Make Arduino Due happy
10 | #endif
11 |
12 | #define DATAPIN 4
13 | #define CLOCKPIN 5
14 |
15 | // MATRIX DECLARATION:
16 | // Parameter 1 = width of DotStar matrix
17 | // Parameter 2 = height of matrix
18 | // Parameter 3 = pin number (most are valid)
19 | // Parameter 4 = matrix layout flags, add together as needed:
20 | // DS_MATRIX_TOP, DS_MATRIX_BOTTOM, DS_MATRIX_LEFT, DS_MATRIX_RIGHT:
21 | // Position of the FIRST LED in the matrix; pick two, e.g.
22 | // DS_MATRIX_TOP + DS_MATRIX_LEFT for the top-left corner.
23 | // DS_MATRIX_ROWS, DS_MATRIX_COLUMNS: LEDs are arranged in horizontal
24 | // rows or in vertical columns, respectively; pick one or the other.
25 | // DS_MATRIX_PROGRESSIVE, DS_MATRIX_ZIGZAG: all rows/columns proceed
26 | // in the same order, or alternate lines reverse direction; pick one.
27 | // See example below for these values in action.
28 | // Parameter 5 = pixel type:
29 | // DOTSTAR_BRG Pixels are wired for BRG bitstream (most DotStar items)
30 | // DOTSTAR_GBR Pixels are wired for GBR bitstream (some older DotStars)
31 |
32 | Adafruit_DotStarMatrix matrix = Adafruit_DotStarMatrix(
33 | 8, 8, DATAPIN, CLOCKPIN,
34 | DS_MATRIX_TOP + DS_MATRIX_RIGHT +
35 | DS_MATRIX_COLUMNS + DS_MATRIX_PROGRESSIVE,
36 | DOTSTAR_BRG);
37 | //Adafruit_DotStarMatrix matrix = Adafruit_DotStarMatrix(
38 | // 8, 8,
39 | // DS_MATRIX_TOP + DS_MATRIX_RIGHT +
40 | // DS_MATRIX_COLUMNS + DS_MATRIX_PROGRESSIVE,
41 | // DOTSTAR_BRG);
42 |
43 | const uint16_t colors[] = {
44 | matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };
45 |
46 | void setup() {
47 | matrix.begin();
48 | matrix.setTextWrap(false);
49 | matrix.setBrightness(40);
50 | matrix.setTextColor(colors[0]);
51 | }
52 |
53 | int x = matrix.width();
54 | int pass = 0;
55 |
56 | void loop() {
57 | matrix.fillScreen(0);
58 | matrix.setCursor(x, 0);
59 | matrix.print(F("Howdy"));
60 | if(--x < -36) {
61 | x = matrix.width();
62 | if(++pass >= 3) pass = 0;
63 | matrix.setTextColor(colors[pass]);
64 | }
65 | matrix.show();
66 | delay(100);
67 | }
68 |
--------------------------------------------------------------------------------
/examples/tiletest/tiletest.pde:
--------------------------------------------------------------------------------
1 | // Adafruit_DotStarMatrix example for tiled DotStar matrices. Scrolls
2 | // 'Howdy' across three 10x8 DotStar grids that were created using
3 | // DotStar 60 LEDs per meter flex strip.
4 |
5 | #include
6 | #include
7 | #include
8 | #include
9 | #ifndef PSTR
10 | #define PSTR // Make Arduino Due happy
11 | #endif
12 |
13 | #define DATAPIN 4
14 | #define CLOCKPIN 5
15 |
16 | // MATRIX DECLARATION:
17 | // Parameter 1 = width of EACH DOTSTAR MATRIX (not total display)
18 | // Parameter 2 = height of each matrix
19 | // Parameter 3 = number of matrices arranged horizontally
20 | // Parameter 4 = number of matrices arranged vertically
21 | // Parameter 5 = pin number (most are valid)
22 | // Parameter 6 = matrix layout flags, add together as needed:
23 | // DS_MATRIX_TOP, DS_MATRIX_BOTTOM, DS_MATRIX_LEFT, DS_MATRIX_RIGHT:
24 | // Position of the FIRST LED in the FIRST MATRIX; pick two, e.g.
25 | // DS_MATRIX_TOP + DS_MATRIX_LEFT for the top-left corner.
26 | // DS_MATRIX_ROWS, DS_MATRIX_COLUMNS: LEDs WITHIN EACH MATRIX are
27 | // arranged in horizontal rows or in vertical columns, respectively;
28 | // pick one or the other.
29 | // DS_MATRIX_PROGRESSIVE, DS_MATRIX_ZIGZAG: all rows/columns WITHIN
30 | // EACH MATRIX proceed in the same order, or alternate lines reverse
31 | // direction; pick one.
32 | // DS_TILE_TOP, DS_TILE_BOTTOM, DS_TILE_LEFT, DS_TILE_RIGHT:
33 | // Position of the FIRST MATRIX (tile) in the OVERALL DISPLAY; pick
34 | // two, e.g. DS_TILE_TOP + DS_TILE_LEFT for the top-left corner.
35 | // DS_TILE_ROWS, DS_TILE_COLUMNS: the matrices in the OVERALL DISPLAY
36 | // are arranged in horizontal rows or in vertical columns, respectively;
37 | // pick one or the other.
38 | // DS_TILE_PROGRESSIVE, DS_TILE_ZIGZAG: the ROWS/COLUMS OF MATRICES
39 | // (tiles) in the OVERALL DISPLAY proceed in the same order for every
40 | // line, or alternate lines reverse direction; pick one. When using
41 | // zig-zag order, the orientation of the matrices in alternate rows
42 | // will be rotated 180 degrees (this is normal -- simplifies wiring).
43 | // See example below for these values in action.
44 | // Parameter 7 = pixel type:
45 | // DOTSTAR_BRG Pixels are wired for BRG bitstream (most DotStar items)
46 | // DOTSTAR_GBR Pixels are wired for GBR bitstream (some older DotStars)
47 |
48 | // Example with three 10x8 matrices (created using DotStar flex strip --
49 | // these grids are not a ready-made product). In this application we'd
50 | // like to arrange the three matrices side-by-side in a wide display.
51 | // The first matrix (tile) will be at the left, and the first pixel within
52 | // that matrix is at the top left. The matrices use zig-zag line ordering.
53 | // There's only one row here, so it doesn't matter if we declare it in row
54 | // or column order. The pixels expect BRG color data.
55 | // IMPORTANT: when using tiled matrices, cast the first two arguments to
56 | // (uint8_t) as shown here. This avoids ambiguity between certain combos
57 | // of single/tiled hard/soft SPI. Do NOT cast for single matrices.
58 | Adafruit_DotStarMatrix matrix = Adafruit_DotStarMatrix(
59 | (uint8_t)10, (uint8_t)8, 3, 1, DATAPIN, CLOCKPIN,
60 | DS_TILE_TOP + DS_TILE_LEFT + DS_TILE_ROWS + DS_TILE_PROGRESSIVE +
61 | DS_MATRIX_TOP + DS_MATRIX_LEFT + DS_MATRIX_ROWS + DS_MATRIX_ZIGZAG,
62 | DOTSTAR_BRG);
63 | //Adafruit_DotStarMatrix matrix = Adafruit_DotStarMatrix(
64 | // (uint8_t)10, (uint8_t)8, 3, 1,
65 | // DS_TILE_TOP + DS_TILE_LEFT + DS_TILE_ROWS + DS_TILE_PROGRESSIVE +
66 | // DS_MATRIX_TOP + DS_MATRIX_LEFT + DS_MATRIX_ROWS + DS_MATRIX_ZIGZAG,
67 | // DOTSTAR_BRG);
68 |
69 | const uint16_t colors[] = {
70 | matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(0, 0, 255) };
71 |
72 | void setup() {
73 | matrix.begin();
74 | matrix.setTextWrap(false);
75 | matrix.setBrightness(40);
76 | matrix.setTextColor(colors[0]);
77 | }
78 |
79 | int x = matrix.width();
80 | int pass = 0;
81 |
82 | void loop() {
83 | matrix.fillScreen(0);
84 | matrix.setCursor(x, 0);
85 | matrix.print(F("Howdy"));
86 | if(--x < -36) {
87 | x = matrix.width();
88 | if(++pass >= 3) pass = 0;
89 | matrix.setTextColor(colors[pass]);
90 | }
91 | matrix.show();
92 | delay(100);
93 | }
94 |
--------------------------------------------------------------------------------
/extras/gamma.c:
--------------------------------------------------------------------------------
1 | // THIS IS NOT ARDUINO CODE -- DON'T INCLUDE IN YOUR SKETCH. It's a
2 | // command-line tool that outputs a gamma correction table to stdout;
3 | // redirect or copy and paste the results into header file for the
4 | // DotStarMatrix library code.
5 | // Optional 1 parameter: bit depth (default=5, for 32 output levels).
6 |
7 | #include
8 | #include
9 | #include
10 |
11 | #define GAMMA 2.6
12 |
13 | int planes = 5;
14 |
15 | int main(int argc, char *argv[]) {
16 | int i, maxval;
17 |
18 | if (argc > 1)
19 | planes = atoi(argv[1]);
20 |
21 | maxval = (1 << planes) - 1;
22 |
23 | (void)printf("#ifndef _GAMMA_H_\n"
24 | "#define _GAMMA_H_\n"
25 | "\n"
26 | "#ifdef __AVR\n"
27 | " #include \n"
28 | "#else\n"
29 | " #ifndef PROGMEM\n"
30 | " #define PROGMEM\n"
31 | " #endif\n"
32 | "#endif\n"
33 | "\n"
34 | "static const uint8_t PROGMEM\n"
35 | " gamma%d[] = {\n"
36 | " ",
37 | planes);
38 |
39 | for (i = 0; i <= maxval; i++) {
40 | (void)printf(
41 | "%3d",
42 | (int)(pow((float)i / (float)maxval, GAMMA) * (float)255.0 + 0.5));
43 | if (i < maxval)
44 | (void)printf(((i & 15) == 15) ? ",\n " : ",");
45 | }
46 |
47 | (void)puts("\n};\n\n"
48 | "#endif // _GAMMA_H_");
49 |
50 | return 0;
51 | }
52 |
--------------------------------------------------------------------------------
/gamma.h:
--------------------------------------------------------------------------------
1 | #ifndef _GAMMA_H_
2 | #define _GAMMA_H_
3 |
4 | #ifdef __AVR
5 | #include
6 | #elif defined(ESP8266)
7 | #include
8 | #else
9 | #ifndef PROGMEM
10 | #define PROGMEM
11 | #endif
12 | #endif
13 |
14 | static const unsigned char PROGMEM
15 | gamma5[] = {0x00, 0x01, 0x02, 0x03, 0x05, 0x07, 0x09, 0x0b,
16 | 0x0e, 0x11, 0x14, 0x18, 0x1d, 0x22, 0x28, 0x2e,
17 | 0x36, 0x3d, 0x46, 0x4f, 0x59, 0x64, 0x6f, 0x7c,
18 | 0x89, 0x97, 0xa6, 0xb6, 0xc7, 0xd9, 0xeb, 0xff},
19 | gamma6[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x08, 0x09, 0x0a,
20 | 0x0b, 0x0d, 0x0e, 0x10, 0x12, 0x13, 0x15, 0x17, 0x19, 0x1b,
21 | 0x1d, 0x20, 0x22, 0x25, 0x27, 0x2a, 0x2d, 0x30, 0x33, 0x37,
22 | 0x3a, 0x3e, 0x41, 0x45, 0x49, 0x4d, 0x52, 0x56, 0x5b, 0x5f,
23 | 0x64, 0x69, 0x6e, 0x74, 0x79, 0x7f, 0x85, 0x8b, 0x91, 0x97,
24 | 0x9d, 0xa4, 0xab, 0xb2, 0xb9, 0xc0, 0xc7, 0xcf, 0xd6, 0xde,
25 | 0xe6, 0xee, 0xf7, 0xff};
26 |
27 | #endif // _GAMMA_H_
28 |
--------------------------------------------------------------------------------
/library.properties:
--------------------------------------------------------------------------------
1 | name=Adafruit DotStarMatrix
2 | version=1.0.9
3 | author=Adafruit
4 | maintainer=Adafruit
5 | sentence=Adafruit_GFX-compatible library for DotStar grids
6 | paragraph=Adafruit_GFX-compatible library for DotStar grids
7 | category=Display
8 | url=https://github.com/adafruit/Adafruit_DotStarMatrix
9 | architectures=*
10 | depends=Adafruit DotStar, Adafruit GFX Library
11 |
--------------------------------------------------------------------------------