Skip to content

Commit c9817f7

Browse files
committed
Removed old examples, added new!
1 parent 2c3fc8e commit c9817f7

File tree

11 files changed

+694
-382
lines changed

11 files changed

+694
-382
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// colorwheel demo for RGBmatrixPanel library.
2+
// Renders a nice circle of hues on a 32x32 RGB LED matrix.
3+
4+
#include "RGBmatrixPanel.h"
5+
6+
#define A A0
7+
#define B A1
8+
#define C A2
9+
#define D A4 // Skip A3 for compatibility with 16x32 wiring
10+
#define CLK 8 // MUST be on PORTB!
11+
#define LAT A3
12+
#define OE 9
13+
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);
14+
15+
void setup() {
16+
int x, y, hue;
17+
float dx, dy, d;
18+
uint8_t sat, val;
19+
uint16_t c;
20+
21+
matrix.begin();
22+
23+
for(y=0; y < matrix.width(); y++) {
24+
dy = 15.5 - (float)y;
25+
for(x=0; x < matrix.height(); x++) {
26+
dx = 15.5 - (float)x;
27+
d = dx * dx + dy * dy;
28+
if(d <= (16.5 * 16.5)) { // Inside the circle(ish)?
29+
hue = (int)((atan2(-dy, dx) + PI) * 1536.0 / (PI * 2.0));
30+
d = sqrt(d);
31+
if(d > 15.5) {
32+
// Do a little pseudo anti-aliasing along perimeter
33+
sat = 255;
34+
val = (int)((1.0 - (d - 15.5)) * 255.0 + 0.5);
35+
} else
36+
{
37+
// White at center
38+
sat = (int)(d / 15.5 * 255.0 + 0.5);
39+
val = 255;
40+
}
41+
c = matrix.ColorHSV(hue, sat, val, true);
42+
} else {
43+
c = 0;
44+
}
45+
matrix.drawPixel(x, y, c);
46+
}
47+
}
48+
}
49+
50+
void loop() {
51+
// do nothing
52+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// colorwheel_progmem demo for RGBmatrixPanel library.
2+
// Renders a nice circle of hues on a 32x32 RGB LED matrix.
3+
// Uses precomputed image data stored in PROGMEM rather than
4+
// calculating each pixel. Nearly instantaneous! Woo!
5+
6+
#include "RGBmatrixPanel.h"
7+
#include "image.h"
8+
9+
#define A A0
10+
#define B A1
11+
#define C A2
12+
#define D A4 // Skip A3 for compatibility with 16x32 wiring
13+
#define CLK 8 // MUST be on PORTB!
14+
#define LAT A3
15+
#define OE 9
16+
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);
17+
18+
void setup() {
19+
int i, len;
20+
uint8_t *ptr = matrix.backBuffer(); // Get address of matrix data
21+
22+
// Copy each byte from PROGMEM to matrix buffer:
23+
len = sizeof(img);
24+
for(i=0; i<len; i++) ptr[i] = pgm_read_byte(&img[i]);
25+
26+
// Start up matrix AFTER data is copied. The RGBmatrixPanel
27+
// interrupt code ties up about 40% of the CPU time, so starting
28+
// it now allows the prior drawing code to run even faster!
29+
matrix.begin();
30+
}
31+
32+
void loop() {
33+
// do nothing
34+
}
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
// Generated by colorwheel_32x32 and matrix.dumpMatrix()
2+
3+
#include <avr/pgmspace.h>
4+
5+
static PROGMEM prog_uchar img[] = {
6+
0xC2,0xC2,0xC2,0xC2,0xC2,0xC2,0xC2,0xE2,
7+
0xE2,0xC2,0xC2,0xE2,0xC2,0xE2,0xE2,0xCE,
8+
0xAF,0x65,0xE4,0x26,0xE2,0xA1,0x20,0xE3,
9+
0xE0,0xA1,0x23,0x23,0x20,0x20,0x20,0x20,
10+
0xC0,0xC0,0xC0,0xC0,0xC2,0xC2,0xC2,0xC0,
11+
0xC2,0xE0,0xE2,0xE0,0xC8,0xC0,0xCA,0xEA,
12+
0xEA,0xAA,0x22,0x2A,0xE2,0xE2,0xE2,0x22,
13+
0x22,0x22,0x22,0x22,0x22,0x22,0x22,0x22,
14+
0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,0xC0,
15+
0xC0,0xC0,0xC0,0xC2,0xE0,0xEB,0xE9,0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
0x00,0x00,0xCB,0xDB,0xDB,0xDB,0xDB,0xDB,
91+
0xDA,0xCA,0xEA,0xEE,0xFE,0xDF,0xDB,0xFF,
92+
0xDF,0xFB,0xDF,0xDA,0xEE,0x6E,0xA7,0x2F,
93+
0x25,0xAE,0x2E,0x24,0xA6,0xA4,0x00,0x00,
94+
0x00,0x00,0x80,0x88,0x88,0x88,0x88,0x8A,
95+
0x8A,0x8B,0x89,0x89,0x8A,0xA8,0xAE,0xAE,
96+
0x8C,0x88,0xA8,0xAE,0xAF,0xAF,0x2F,0x27,
97+
0x26,0xAE,0xAE,0xAE,0x2E,0x22,0x00,0x00,
98+
0x00,0x00,0x82,0x8A,0x8A,0x8A,0x8A,0x8A,
99+
0x8B,0x8B,0x8B,0x8A,0x8A,0x8B,0x8B,0x8A,
100+
0xAB,0xAF,0xAF,0xAE,0xAE,0xAD,0xAD,0xAD,
101+
0xAF,0x27,0x25,0x27,0x25,0x23,0x00,0x00,
102+
0x00,0x00,0x9A,0xDA,0xDA,0xDA,0xDA,0xDA,
103+
0xDA,0x9B,0x9F,0xBF,0xFE,0xFA,0xDA,0xFE,
104+
0xFA,0xDE,0xFA,0xDA,0xBF,0xB5,0x2D,0xA5,
105+
0x26,0xAE,0xA4,0x26,0x2C,0x2E,0x00,0x00,
106+
0x00,0x00,0x09,0x89,0x89,0x89,0x89,0x89,
107+
0x8B,0x8A,0x8A,0x88,0x88,0x8F,0xAF,0xAD,
108+
0xAB,0x8B,0x8F,0xAC,0xAC,0xAE,0xA7,0x27,
109+
0x27,0xAE,0xAE,0xAE,0xA6,0x06,0x00,0x00,
110+
0x00,0x00,0x0A,0x8A,0x8A,0x8A,0x8A,0x8B,
111+
0x8B,0x8B,0x8A,0x8A,0x8B,0x8A,0x8B,0x8B,
112+
0x8E,0xAE,0xAE,0xAF,0xAF,0xAF,0xAF,0xAF,
113+
0xAD,0x27,0x27,0x25,0x27,0x05,0x00,0x00,
114+
0x00,0x00,0x08,0x0B,0x8B,0x8B,0x8B,0x8B,
115+
0x8B,0x9F,0x9F,0x9F,0xBF,0xBB,0x8F,0x8B,
116+
0xAB,0x8F,0xBB,0xBF,0x9F,0xB7,0x3F,0xA6,
117+
0xAC,0x2C,0xA6,0xA4,0x8E,0x0C,0x00,0x00,
118+
0x00,0x09,0x18,0x18,0x98,0x98,0x98,0x98,
119+
0x98,0x8B,0x8B,0x8B,0x89,0x8F,0xBC,0xBA,
120+
0xBA,0x98,0x8D,0x8F,0xAF,0xAE,0xA6,0x27,
121+
0x2F,0x2F,0xAE,0xAE,0x06,0x04,0x04,0x00,
122+
0x00,0x00,0x0A,0x8A,0x8A,0x8A,0x8B,0x8B,
123+
0x8B,0x8A,0x8A,0x8B,0x8B,0x8A,0x8A,0x8E,
124+
0x8F,0xAF,0xAF,0xAF,0xAD,0xAD,0xAD,0xAF,
125+
0xA7,0xA5,0x27,0x25,0x27,0x05,0x00,0x00,
126+
0x00,0x08,0x08,0x08,0x09,0x8B,0x8B,0x8B,
127+
0x8E,0x8E,0x8E,0x8F,0xAB,0xAB,0x8F,0x8B,
128+
0xAF,0xAB,0x8F,0xAF,0x97,0xBE,0xB4,0x34,
129+
0xAE,0x26,0x24,0x0E,0x0C,0x0C,0x04,0x00,
130+
0x00,0x19,0x19,0x19,0x99,0x99,0x99,0x99,
131+
0x99,0x99,0x9B,0x9A,0x9C,0x9E,0xBD,0xBB,
132+
0xB9,0xBF,0x9E,0x9C,0xAD,0xA5,0xA6,0xA6,
133+
0x2F,0x2F,0x2E,0xA4,0x04,0x04,0x04,0x00,
134+
0x00,0x0A,0x0A,0x0A,0x8A,0x8A,0x8B,0x8B,
135+
0x8A,0x8A,0x8B,0x8B,0x8A,0x8B,0x8B,0x8E,
136+
0x8E,0x8E,0xAE,0xAD,0xAF,0xAF,0xAF,0xAD,
137+
0xA5,0xA7,0xA5,0x27,0x05,0x05,0x07,0x00,
138+
0x00,0x18,0x18,0x18,0x18,0x18,0x9A,0x9A,
139+
0x9E,0x9E,0x9E,0x9A,0x9A,0xAE,0xBE,0x9B,
140+
0x9F,0xBA,0x8E,0xA6,0xAE,0x9E,0xB6,0x3E,
141+
0x2C,0xA4,0x8E,0x0C,0x0C,0x04,0x04,0x00,
142+
0x01,0x19,0x19,0x19,0x19,0x99,0x98,0x98,
143+
0x98,0x98,0x98,0x9E,0x9E,0x9D,0x9E,0xB8,
144+
0xBA,0xBE,0x9D,0x9D,0x96,0xA7,0xA7,0xAE,
145+
0xAF,0x2F,0xA5,0x04,0x04,0x04,0x04,0x00,
146+
0x02,0x0A,0x0A,0x0A,0x0A,0x8B,0x8B,0x8B,
147+
0x8A,0x8B,0x8B,0x8A,0x8B,0x8A,0x8B,0x8F,
148+
0x8F,0x8F,0xAF,0xAF,0xAF,0xAD,0xAD,0xA7,
149+
0xA5,0xA5,0x27,0x07,0x05,0x07,0x07,0x01,
150+
0x10,0x08,0x08,0x08,0x08,0x08,0x0A,0x8E,
151+
0x8E,0x8E,0x8A,0x8A,0x8E,0xBE,0xBA,0x8E,
152+
0x8A,0xBE,0xBE,0x96,0xAE,0x86,0xBE,0xBE,
153+
0x36,0x84,0x0C,0x0C,0x04,0x04,0x04,0x00,
154+
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x88,
155+
0x88,0x88,0x8C,0x8E,0x8E,0x9D,0x9B,0xA8,
156+
0xAE,0xBD,0xBF,0x9E,0x95,0xB4,0xAD,0xAE,
157+
0xAE,0x8F,0x05,0x04,0x04,0x04,0x04,0x04,
158+
0x00,0x1A,0x1A,0x1A,0x1A,0x1B,0x9B,0x9A,
159+
0x9A,0x9B,0x9A,0x9B,0x9A,0x8B,0x8E,0x9E,
160+
0x9E,0x8E,0x8D,0xAD,0xAD,0xAF,0xA7,0xA5,
161+
0xA7,0x25,0x07,0x05,0x07,0x07,0x05,0x00,
162+
0x10,0x18,0x18,0x18,0x18,0x18,0x18,0x9E,
163+
0x9E,0x9E,0x9A,0x9A,0x9E,0xAA,0xAA,0xBE,
164+
0x9A,0x8E,0xA6,0x9E,0x86,0xA6,0x9E,0xB6,
165+
0xB6,0x0C,0x0C,0x04,0x04,0x04,0x04,0x00,
166+
0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
167+
0x88,0x88,0x8C,0x8E,0x8E,0x89,0x89,0x8A,
168+
0xAC,0xAF,0xAC,0x95,0x97,0x96,0xAF,0xAF,
169+
0x0E,0x05,0x05,0x04,0x04,0x04,0x04,0x00,
170+
0x0A,0x1A,0x1A,0x1A,0x1A,0x1B,0x1B,0x1A,
171+
0x9B,0x9B,0x9A,0x9B,0x9B,0x9E,0x9F,0x9F,
172+
0x9F,0x9F,0x9F,0xAF,0xAF,0xAD,0xA5,0xA7,
173+
0x05,0x07,0x05,0x07,0x07,0x07,0x05,0x05,
174+
0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x0C,
175+
0x0C,0x08,0x8A,0x8E,0x8E,0x8A,0xBE,0xBA,
176+
0x9E,0x9E,0xA6,0xBE,0x96,0xAE,0x24,0x14,
177+
0x1C,0x0C,0x0C,0x04,0x04,0x04,0x04,0x00,
178+
0x08,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
179+
0x18,0x9C,0x9C,0x9C,0x9E,0x9A,0x89,0x8F,
180+
0xAD,0xAE,0xAD,0xB7,0x94,0x9D,0x9E,0x0D,
181+
0x04,0x05,0x05,0x04,0x04,0x04,0x04,0x04,
182+
0x18,0x1A,0x1A,0x1A,0x1A,0x1B,0x1B,0x1A,
183+
0x1B,0x1A,0x9B,0x9A,0x9B,0x9F,0x9E,0x9E,
184+
0x9E,0x9D,0x9D,0x8D,0xAD,0xA7,0x07,0x05,
185+
0x07,0x05,0x05,0x07,0x07,0x05,0x05,0x04,
186+
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x1C,
187+
0x1C,0x18,0x18,0x1E,0x18,0x1E,0x1C,0xBA,
188+
0xAE,0x34,0x3E,0x24,0x1E,0x0C,0x04,0x1C,
189+
0x1C,0x0C,0x04,0x04,0x04,0x04,0x04,0x04,
190+
0x18,0x18,0x18,0x18,0x18,0x18,0x18,0x18,
191+
0x18,0x1C,0x1C,0x1C,0x98,0x1A,0x9A,0x9C,
192+
0x9F,0x8F,0x06,0x84,0x1E,0x1D,0x1C,0x05,
193+
0x04,0x05,0x05,0x05,0x04,0x04,0x04,0x04,
194+
0x1A,0x1A,0x1A,0x1A,0x1B,0x1B,0x1B,0x1A,
195+
0x1B,0x1A,0x1B,0x1A,0x1E,0x9E,0x9F,0x9F,
196+
0x9F,0x9D,0x9D,0x1F,0x07,0x05,0x05,0x07,
197+
0x05,0x05,0x07,0x07,0x05,0x05,0x05,0x05
198+
};

0 commit comments

Comments
 (0)