Skip to content

Commit e2103ea

Browse files
committed
Added polar noise patterns.
Added ring arrays.
1 parent 060c096 commit e2103ea

File tree

3 files changed

+246
-13
lines changed

3 files changed

+246
-13
lines changed

Map.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,42 @@ uint8_t radii[NUM_LEDS] = { 13, 13, 13, 13, 26, 26, 26, 26, 26, 26, 26, 26, 26
1919
217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 217, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 230, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242,
2020
242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 242, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255 };
2121

22+
23+
// Polar coordinate mapping code for FastLED by Adam Haile, Maniacal Labs:
24+
// http://maniacallabs.com/2015/05/04/review-code-adafruit-dotstar-disk/
25+
// https://gist.github.com/adammhaile/a769f3ff87ff61f22ace
26+
27+
#define ringCount 20 //Total Number of Rings. AdaFruit Disk has 10
28+
29+
//Map rings on disk to indicies.
30+
//This is where all the magic happens.
31+
//Each represents one of the concentric rings.
32+
uint16_t rings[ringCount][2] = {
33+
{ 0, 3 }, // 0 Center Ring
34+
{ 4, 15 }, // 1
35+
{ 16, 36 }, // 2
36+
{ 37, 65 }, // 3
37+
{ 66, 102 }, // 4
38+
{ 103, 147 }, // 5
39+
{ 148, 200 }, // 6
40+
{ 201, 262 }, // 7
41+
{ 263, 332 }, // 8
42+
{ 333, 410 }, // 9
43+
{ 411, 496 }, // 10
44+
{ 497, 590 }, // 11
45+
{ 591, 692 }, // 12
46+
{ 693, 803 }, // 13
47+
{ 804, 920 }, // 14
48+
{ 921, 1045 }, // 15
49+
{ 1046, 1180 }, // 16
50+
{ 1181, 1322 }, // 17
51+
{ 1323, 1467 }, // 18
52+
{ 1468, 1627 }, // 19 Outer Ring
53+
};
54+
55+
//For convenience, last ring index
56+
uint8_t lastRing = ringCount - 1;
57+
2258
void radarSweepPalette() {
2359
fadeToBlackBy(leds, NUM_LEDS, 64);
2460

PolarNoise.h

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
/*
2+
Sol: https://github.com/evilgeniuslabs/sol
3+
Copyright (C) 2016 Jason Coon, Evil Genius Labs
4+
5+
This program is free software: you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation, either version 3 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License
16+
along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
void drawPolarNoise(CRGBPalette16 palette, uint8_t hueReduce = 0)
20+
{
21+
for (uint8_t ringIndex = 0; ringIndex < ringCount; ringIndex++) { // y
22+
uint16_t ringStart = rings[ringIndex][0];
23+
uint16_t ringEnd = rings[ringIndex][1];
24+
25+
for (uint16_t i = ringStart; i <= ringEnd; i++) { // x
26+
uint8_t x = (i - ringStart) * (256 / (ringEnd - ringStart));
27+
uint8_t y = ringIndex * (128 / ringCount);
28+
29+
int xoffset = noisescale * x;
30+
int yoffset = noisescale * y;
31+
32+
uint8_t data = inoise8(x + xoffset + noisex, y + yoffset + noisey, noisez);
33+
34+
// The range of the inoise8 function is roughly 16-238.
35+
// These two operations expand those values out to roughly 0..255
36+
// You can comment them out if you want the raw noise data.
37+
data = qsub8(data, 16);
38+
data = qadd8(data, scale8(data, 39));
39+
40+
leds[i] = ColorFromPalette(palette, data, 255, LINEARBLEND);
41+
}
42+
43+
// if(ringIndex != 0) {
44+
// // blend the first pixel in the ring into the last
45+
// nblend(leds[ringStart], leds[ringEnd], 192);
46+
// nblend(leds[ringStart + 1], leds[ringEnd - 1], 128);
47+
// nblend(leds[ringStart + 2], leds[ringEnd - 2], 64);
48+
// }
49+
}
50+
51+
noisex += noisespeedx;
52+
noisey += noisespeedy;
53+
noisez += noisespeedz;
54+
}
55+
56+
void gradientPalettePolarNoise() {
57+
noisespeedx = 4;
58+
noisespeedy = 0;
59+
noisespeedz = 0;
60+
noisescale = 1;
61+
colorLoop = 0;
62+
drawPolarNoise(gCurrentPalette);
63+
}
64+
65+
void palettePolarNoise() {
66+
noisespeedx = 9;
67+
noisespeedy = 0;
68+
noisespeedz = 0;
69+
noisescale = 1;
70+
colorLoop = 0;
71+
drawPolarNoise(palettes[currentPaletteIndex]);
72+
}
73+
74+
void rainbowPolarNoise() {
75+
noisespeedx = 0;
76+
noisespeedy = 2;
77+
noisespeedz = 0;
78+
noisescale = 0;
79+
colorLoop = 0;
80+
drawPolarNoise(RainbowColors_p);
81+
}
82+
83+
void rainbowStripePolarNoise() {
84+
noisespeedx = 0;
85+
noisespeedy = 2;
86+
noisespeedz = 0;
87+
noisescale = 0;
88+
colorLoop = 0;
89+
drawPolarNoise(RainbowStripeColors_p);
90+
}
91+
92+
void partyPolarNoise() {
93+
noisespeedx = 9;
94+
noisespeedy = 0;
95+
noisespeedz = 0;
96+
noisescale = 1;
97+
colorLoop = 0;
98+
drawPolarNoise(PartyColors_p);
99+
}
100+
101+
void forestPolarNoise() {
102+
noisespeedx = 9;
103+
noisespeedy = 0;
104+
noisespeedz = 0;
105+
noisescale = 1;
106+
colorLoop = 0;
107+
drawPolarNoise(ForestColors_p);
108+
}
109+
110+
void cloudPolarNoise() {
111+
noisespeedx = 2;
112+
noisespeedy = 0;
113+
noisespeedz = 0;
114+
noisescale = 0;
115+
colorLoop = 0;
116+
drawPolarNoise(CloudColors_p);
117+
}
118+
119+
void firePolarNoise() {
120+
// noisespeedx = 0; // 24;
121+
// noisespeedy = -24;
122+
// noisespeedz = 0;
123+
// noisescale = 4;
124+
// colorLoop = 0;
125+
noisespeedx = 0; // 24;
126+
noisespeedy = -32;
127+
noisespeedz = 0;
128+
noisescale = 4;
129+
colorLoop = 0;
130+
drawPolarNoise(HeatColors_p, 60);
131+
}
132+
133+
void firePolarNoise2() {
134+
// noisespeedx = 0;
135+
// noisespeedy = -8;
136+
// noisespeedz = 4;
137+
// noisescale = 1;
138+
// colorLoop = 0;
139+
noisespeedx = 0;
140+
noisespeedy = -4;
141+
noisespeedz = 4;
142+
noisescale = 1;
143+
colorLoop = 0;
144+
drawPolarNoise(HeatColors_p);
145+
}
146+
147+
void lavaPolarNoise() {
148+
noisespeedx = 0;
149+
noisespeedy = -1;
150+
noisespeedz = 1;
151+
noisescale = 1;
152+
colorLoop = 0;
153+
drawPolarNoise(LavaColors_p);
154+
}
155+
156+
void oceanPolarNoise() {
157+
noisespeedx = -1; // beatsin8(6, 0, 2) - 1;
158+
noisespeedy = 0;
159+
noisespeedz = 1;
160+
noisescale = 0;
161+
colorLoop = 0;
162+
drawPolarNoise(OceanColors_p);
163+
}
164+
165+
void blackAndWhitePolarNoise() {
166+
SetupBlackAndWhiteStripedPalette();
167+
noisespeedx = -4; // beatsin8(8, 0, 9) - 4;
168+
noisespeedy = 0;
169+
noisespeedz = 0;
170+
noisescale = 0;
171+
colorLoop = 0;
172+
drawPolarNoise(blackAndWhiteStripedPalette);
173+
}
174+
175+
void blackAndBluePolarNoise() {
176+
SetupBlackAndBlueStripedPalette();
177+
noisespeedx = 0;
178+
noisespeedy = -8; // beatsin8(8, 0, 16) - 8;
179+
noisespeedz = 0;
180+
noisescale = 1;
181+
colorLoop = 0;
182+
drawPolarNoise(blackAndBlueStripedPalette);
183+
}

esp8266-fastled-webserver.ino

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ typedef PatternAndName PatternAndNameList[];
178178
#include "TwinkleFOX.h"
179179
#include "Map.h"
180180
#include "Noise.h"
181+
#include "PolarNoise.h"
181182
#include "Pacifica.h"
182183
#include "PridePlayground.h"
183184
#include "ColorWavesPlayground.h"
@@ -210,19 +211,32 @@ PatternAndNameList patterns = {
210211
{ yGradientPalette, "Y Axis Gradient Palette" },
211212
{ xyGradientPalette, "XY Axis Gradient Palette" },
212213

213-
// noise patterns
214-
{ fireNoise, "Fire Noise" },
215-
{ fireNoise2, "Fire Noise 2" },
216-
{ lavaNoise, "Lava Noise" },
217-
{ rainbowNoise, "Rainbow Noise" },
218-
{ rainbowStripeNoise, "Rainbow Stripe Noise" },
219-
{ partyNoise, "Party Noise" },
220-
{ forestNoise, "Forest Noise" },
221-
{ cloudNoise, "Cloud Noise" },
222-
{ oceanNoise, "Ocean Noise" },
223-
{ blackAndWhiteNoise, "Black & White Noise" },
224-
{ blackAndBlueNoise, "Black & Blue Noise" },
225-
214+
// noise patterns (XY and Polar variations)
215+
{ gradientPalettePolarNoise, "Gradient Palette Polar Noise" },
216+
{ palettePolarNoise, "Palette Polar Noise" },
217+
{ fireNoise, "Fire Noise" },
218+
{ firePolarNoise, "Fire Polar Noise" },
219+
{ fireNoise2, "Fire Noise 2" },
220+
{ firePolarNoise2, "Fire Polar Noise 2" },
221+
{ lavaNoise, "Lava Noise" },
222+
{ lavaPolarNoise, "Lava Polar Noise" },
223+
{ rainbowNoise, "Rainbow Noise" },
224+
{ rainbowPolarNoise, "Rainbow Polar Noise" },
225+
{ rainbowStripeNoise, "Rainbow Stripe Noise" },
226+
{ rainbowStripePolarNoise, "Rainbow Stripe Polar Noise" },
227+
{ partyNoise, "Party Noise" },
228+
{ partyPolarNoise, "Party Polar Noise" },
229+
{ forestNoise, "Forest Noise" },
230+
{ forestPolarNoise, "Forest Polar Noise" },
231+
{ cloudNoise, "Cloud Noise" },
232+
{ cloudPolarNoise, "Cloud Polar Noise" },
233+
{ oceanNoise, "Ocean Noise" },
234+
{ oceanPolarNoise, "Ocean Polar Noise" },
235+
{ blackAndWhiteNoise, "Black & White Noise" },
236+
{ blackAndWhitePolarNoise, "Black & White Polar Noise" },
237+
{ blackAndBlueNoise, "Black & Blue Noise" },
238+
{ blackAndBluePolarNoise, "Black & Blue Polar Noise" },
239+
226240
{ drawAnalogClock, "Analog Clock" },
227241

228242
{ pridePlayground, "Pride Playground" },

0 commit comments

Comments
 (0)