Compare commits
7 Commits
sunrise-cl
...
ultim8x8
Author | SHA1 | Date | |
---|---|---|---|
41146d118e | |||
c0c7879c0b | |||
d335cc22cf | |||
e5c988727e | |||
93340c3016 | |||
20c528871f | |||
55e70750c9 |
193
Map.h
Normal file
193
Map.h
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
uint8_t cubeWidth = 8;
|
||||||
|
uint8_t cubeDepth = 8;
|
||||||
|
uint8_t cubeHeight = 8;
|
||||||
|
|
||||||
|
uint8_t coordsX[NUM_LEDS] = { 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7 };
|
||||||
|
uint8_t coordsY[NUM_LEDS] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
|
uint8_t coordsZ[NUM_LEDS] = { 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 6, 5, 4, 3, 2, 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
|
|
||||||
|
void cubeTest() {
|
||||||
|
static uint8_t x = 0;
|
||||||
|
static uint8_t y = 0;
|
||||||
|
static uint8_t z = 0;
|
||||||
|
|
||||||
|
EVERY_N_MILLIS(255 - speed) {
|
||||||
|
x++;
|
||||||
|
if(x >= cubeWidth) {
|
||||||
|
x = 0;
|
||||||
|
y++;
|
||||||
|
if(y >= cubeDepth) {
|
||||||
|
y = 0;
|
||||||
|
z++;
|
||||||
|
if(z >= cubeHeight) {
|
||||||
|
z = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FastLED.clear();
|
||||||
|
|
||||||
|
CHSV color = CHSV(gHue, 255, 255);
|
||||||
|
|
||||||
|
for(uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t cx = coordsX[i];
|
||||||
|
uint8_t cy = coordsY[i];
|
||||||
|
uint8_t cz = coordsZ[i];
|
||||||
|
|
||||||
|
if((cx == x && cy == y) || (cx == x && cz == z) || (cy == y && cz == z)) {
|
||||||
|
leds[i] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeXPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t x = coordsX[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(palettes[currentPaletteIndex], beat8(speed) - (x * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeYPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t y = coordsY[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(palettes[currentPaletteIndex], beat8(speed) - (y * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeZPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t z = coordsZ[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(palettes[currentPaletteIndex], beat8(speed) - (z * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeXYPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t x = coordsX[i];
|
||||||
|
uint8_t y = coordsY[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(palettes[currentPaletteIndex], beat8(speed) - ((x + y) * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeXZPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t x = coordsX[i];
|
||||||
|
uint8_t z = coordsZ[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(palettes[currentPaletteIndex], beat8(speed) - ((x + z) * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeYZPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t y = coordsY[i];
|
||||||
|
uint8_t z = coordsZ[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(palettes[currentPaletteIndex], beat8(speed) - ((y + z) * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeXYZPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t x = coordsX[i];
|
||||||
|
uint8_t y = coordsY[i];
|
||||||
|
uint8_t z = coordsZ[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(palettes[currentPaletteIndex], beat8(speed) - ((x + y + z) * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeXGradientPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t x = coordsX[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(gCurrentPalette, beat8(speed) - (x * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeYGradientPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t y = coordsY[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(gCurrentPalette, beat8(speed) - (y * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeZGradientPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t z = coordsZ[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(gCurrentPalette, beat8(speed) - (z * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeXYGradientPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t x = coordsX[i];
|
||||||
|
uint8_t y = coordsY[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(gCurrentPalette, beat8(speed) - ((x + y) * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeXZGradientPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t x = coordsX[i];
|
||||||
|
uint8_t z = coordsZ[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(gCurrentPalette, beat8(speed) - ((x + z) * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeYZGradientPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t y = coordsY[i];
|
||||||
|
uint8_t z = coordsZ[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(gCurrentPalette, beat8(speed) - ((y + z) * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void cubeXYZGradientPalette() {
|
||||||
|
uint8_t hues = 8;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t x = coordsX[i];
|
||||||
|
uint8_t y = coordsY[i];
|
||||||
|
uint8_t z = coordsZ[i];
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(gCurrentPalette, beat8(speed) - ((x + y + z) * hues));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
346
Noise.h
Normal file
346
Noise.h
Normal file
@ -0,0 +1,346 @@
|
|||||||
|
/*
|
||||||
|
ESP8266 + FastLED + IR Remote: https://github.com/jasoncoon/esp8266-fastled-webserver
|
||||||
|
Copyright (C) 2015-2016 Jason Coon
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define MAX_DIMENSION ((MatrixWidth > MatrixHeight) ? MatrixWidth : MatrixHeight)
|
||||||
|
|
||||||
|
// The 16 bit version of our coordinates
|
||||||
|
uint16_t noisex;
|
||||||
|
uint16_t noisey;
|
||||||
|
uint16_t noisez;
|
||||||
|
|
||||||
|
// We're using the x/y dimensions to map to the x/y pixels on the matrix. We'll
|
||||||
|
// use the z-axis for "time". speed determines how fast time moves forward. Try
|
||||||
|
// 1 for a very slow moving effect, or 60 for something that ends up looking like
|
||||||
|
// water.
|
||||||
|
int noisespeedx = 0;
|
||||||
|
int noisespeedy = 1;
|
||||||
|
int noisespeedz = 0;
|
||||||
|
|
||||||
|
// Scale determines how far apart the pixels in our noise matrix are. Try
|
||||||
|
// changing these values around to see how it affects the motion of the display. The
|
||||||
|
// higher the value of scale, the more "zoomed out" the noise will be. A value
|
||||||
|
// of 1 will be so zoomed in, you'll mostly see solid colors.
|
||||||
|
uint16_t noisescale = 1; // scale is set dynamically once we've started up
|
||||||
|
|
||||||
|
// This is the array that we keep our computed noise values in
|
||||||
|
uint8_t noise[MAX_DIMENSION][MAX_DIMENSION];
|
||||||
|
|
||||||
|
uint8_t colorLoop = 0;
|
||||||
|
|
||||||
|
CRGBPalette16 blackAndWhiteStripedPalette;
|
||||||
|
|
||||||
|
// This function sets up a palette of black and white stripes,
|
||||||
|
// using code. Since the palette is effectively an array of
|
||||||
|
// sixteen CRGB colors, the various fill_* functions can be used
|
||||||
|
// to set them up.
|
||||||
|
void SetupBlackAndWhiteStripedPalette()
|
||||||
|
{
|
||||||
|
// 'black out' all 16 palette entries...
|
||||||
|
fill_solid( blackAndWhiteStripedPalette, 16, CRGB::Black);
|
||||||
|
// and set every fourth one to white.
|
||||||
|
blackAndWhiteStripedPalette[0] = CRGB::White;
|
||||||
|
blackAndWhiteStripedPalette[4] = CRGB::White;
|
||||||
|
blackAndWhiteStripedPalette[8] = CRGB::White;
|
||||||
|
blackAndWhiteStripedPalette[12] = CRGB::White;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CRGBPalette16 blackAndBlueStripedPalette;
|
||||||
|
|
||||||
|
// This function sets up a palette of black and blue stripes,
|
||||||
|
// using code. Since the palette is effectively an array of
|
||||||
|
// sixteen CRGB colors, the various fill_* functions can be used
|
||||||
|
// to set them up.
|
||||||
|
void SetupBlackAndBlueStripedPalette()
|
||||||
|
{
|
||||||
|
// 'black out' all 16 palette entries...
|
||||||
|
fill_solid( blackAndBlueStripedPalette, 16, CRGB::Black);
|
||||||
|
|
||||||
|
for(uint8_t i = 0; i < 6; i++) {
|
||||||
|
blackAndBlueStripedPalette[i] = CRGB::Blue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// There are several different palettes of colors demonstrated here.
|
||||||
|
//
|
||||||
|
// FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
|
||||||
|
// OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.
|
||||||
|
//
|
||||||
|
// Additionally, you can manually define your own color palettes, or you can write
|
||||||
|
// code that creates color palettes on the fly.
|
||||||
|
|
||||||
|
void drawNoise(CRGBPalette16 palette, uint8_t hueReduce = 0)
|
||||||
|
{
|
||||||
|
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
||||||
|
for(uint8_t y = 0; y < MatrixHeight; y++) {
|
||||||
|
uint16_t i = XY(x, y);
|
||||||
|
|
||||||
|
int xoffset = noisescale * x;
|
||||||
|
int yoffset = noisescale * y;
|
||||||
|
|
||||||
|
uint8_t data = inoise8(x + xoffset + noisex, y + yoffset + noisey, noisez);
|
||||||
|
|
||||||
|
// The range of the inoise8 function is roughly 16-238.
|
||||||
|
// These two operations expand those values out to roughly 0..255
|
||||||
|
// You can comment them out if you want the raw noise data.
|
||||||
|
data = qsub8(data, 16);
|
||||||
|
data = qadd8(data, scale8(data, 39));
|
||||||
|
|
||||||
|
if(hueReduce > 0 && data >= hueReduce)
|
||||||
|
data -= hueReduce;
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(palette, data, 255, LINEARBLEND);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
noisex += noisespeedx;
|
||||||
|
noisey += noisespeedy;
|
||||||
|
noisez += noisespeedz;
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawNoise3d(CRGBPalette16 palette, uint8_t hueReduce = 0)
|
||||||
|
{
|
||||||
|
for(uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
|
uint8_t x = coordsX[i];
|
||||||
|
uint8_t y = coordsY[i];
|
||||||
|
uint8_t z = coordsZ[i];
|
||||||
|
|
||||||
|
int xoffset = noisescale * x;
|
||||||
|
int yoffset = noisescale * y;
|
||||||
|
int zoffset = noisescale * z;
|
||||||
|
|
||||||
|
uint8_t data = inoise8(x + xoffset + noisex, y + yoffset + noisey, z + zoffset + noisez);
|
||||||
|
|
||||||
|
// The range of the inoise8 function is roughly 16-238.
|
||||||
|
// These two operations expand those values out to roughly 0..255
|
||||||
|
// You can comment them out if you want the raw noise data.
|
||||||
|
data = qsub8(data, 16);
|
||||||
|
data = qadd8(data, scale8(data, 39));
|
||||||
|
|
||||||
|
if(hueReduce > 0 && data >= hueReduce)
|
||||||
|
data -= hueReduce;
|
||||||
|
|
||||||
|
leds[i] = ColorFromPalette(palette, data, 255, LINEARBLEND);
|
||||||
|
}
|
||||||
|
|
||||||
|
noisex += noisespeedx;
|
||||||
|
noisey += noisespeedy;
|
||||||
|
noisez += noisespeedz;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rainbowNoise() {
|
||||||
|
noisespeedx = 0;
|
||||||
|
noisespeedy = -1;
|
||||||
|
noisespeedz = 0;
|
||||||
|
noisescale = 24;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise(RainbowColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rainbowNoise3d() {
|
||||||
|
noisespeedx = 0;
|
||||||
|
noisespeedy = 0;
|
||||||
|
noisespeedz = -1;
|
||||||
|
noisescale = 24;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise3d(RainbowColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rainbowStripeNoise() {
|
||||||
|
noisespeedx = 0;
|
||||||
|
noisespeedy = -2;
|
||||||
|
noisespeedz = 0;
|
||||||
|
noisescale = 24;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise(RainbowStripeColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rainbowStripeNoise3d() {
|
||||||
|
noisespeedx = 0;
|
||||||
|
noisespeedy = 0;
|
||||||
|
noisespeedz = -2;
|
||||||
|
noisescale = 24;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise3d(RainbowStripeColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void partyNoise() {
|
||||||
|
noisespeedx = -9;
|
||||||
|
noisespeedy = 0;
|
||||||
|
noisespeedz = 0;
|
||||||
|
noisescale = 32;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise(PartyColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void partyNoise3d() {
|
||||||
|
noisespeedx = -9;
|
||||||
|
noisespeedy = 0;
|
||||||
|
noisespeedz = 0;
|
||||||
|
noisescale = 32;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise3d(PartyColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void forestNoise() {
|
||||||
|
noisespeedx = -9;
|
||||||
|
noisespeedy = 0;
|
||||||
|
noisespeedz = 0;
|
||||||
|
noisescale = 32;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise(ForestColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void forestNoise3d() {
|
||||||
|
noisespeedx = -9;
|
||||||
|
noisespeedy = 0;
|
||||||
|
noisespeedz = 0;
|
||||||
|
noisescale = 32;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise3d(ForestColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cloudNoise() {
|
||||||
|
noisespeedx = -2;
|
||||||
|
noisespeedy = 0;
|
||||||
|
noisespeedz = 0;
|
||||||
|
noisescale = 24;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise(CloudColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void cloudNoise3d() {
|
||||||
|
noisespeedx = -2;
|
||||||
|
noisespeedy = 0;
|
||||||
|
noisespeedz = 0;
|
||||||
|
noisescale = 24;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise3d(CloudColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fireNoise() {
|
||||||
|
noisespeedx = 0; // 24;
|
||||||
|
noisespeedy = -32;
|
||||||
|
noisespeedz = 0;
|
||||||
|
noisescale = 64;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise(HeatColors_p, 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fireNoise3d() {
|
||||||
|
noisespeedx = 0;
|
||||||
|
noisespeedy = 0;
|
||||||
|
noisespeedz = 32;
|
||||||
|
noisescale = 64;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise3d(HeatColors_p, 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fireNoise2() {
|
||||||
|
noisespeedx = 0;
|
||||||
|
noisespeedy = -8;
|
||||||
|
noisespeedz = 3;
|
||||||
|
noisescale = 32;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise(HeatColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fireNoise23d() {
|
||||||
|
noisespeedx = 1;
|
||||||
|
noisespeedy = 3;
|
||||||
|
noisespeedz = 8;
|
||||||
|
noisescale = 32;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise3d(HeatColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lavaNoise() {
|
||||||
|
noisespeedx = 0;
|
||||||
|
noisespeedy = -1;
|
||||||
|
noisespeedz = 1;
|
||||||
|
noisescale = 24;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise(LavaColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lavaNoise3d() {
|
||||||
|
noisespeedx = 1;
|
||||||
|
noisespeedy = 3;
|
||||||
|
noisespeedz = -8;
|
||||||
|
noisescale = 32;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise3d(LavaColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void oceanNoise() {
|
||||||
|
noisespeedx = -2;
|
||||||
|
noisespeedy = 0;
|
||||||
|
noisespeedz = 4;
|
||||||
|
noisescale = 24;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise(OceanColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void oceanNoise3d() {
|
||||||
|
noisespeedx = -2;
|
||||||
|
noisespeedy = 0;
|
||||||
|
noisespeedz = 4;
|
||||||
|
noisescale = 24;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise3d(OceanColors_p);
|
||||||
|
}
|
||||||
|
|
||||||
|
void blackAndWhiteNoise() {
|
||||||
|
SetupBlackAndWhiteStripedPalette();
|
||||||
|
noisespeedx = -12;
|
||||||
|
noisespeedy = 0;
|
||||||
|
noisespeedz = 0;
|
||||||
|
noisescale = 24;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise(blackAndWhiteStripedPalette);
|
||||||
|
}
|
||||||
|
|
||||||
|
void blackAndWhiteNoise3d() {
|
||||||
|
SetupBlackAndWhiteStripedPalette();
|
||||||
|
noisespeedx = -12;
|
||||||
|
noisespeedy = 0;
|
||||||
|
noisespeedz = 0;
|
||||||
|
noisescale = 24;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise3d(blackAndWhiteStripedPalette);
|
||||||
|
}
|
||||||
|
|
||||||
|
void blackAndBlueNoise() {
|
||||||
|
SetupBlackAndBlueStripedPalette();
|
||||||
|
noisespeedx = 0;
|
||||||
|
noisespeedy = 8;
|
||||||
|
noisespeedz = 0;
|
||||||
|
noisescale = 32;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise(blackAndBlueStripedPalette);
|
||||||
|
}
|
||||||
|
|
||||||
|
void blackAndBlueNoise3d() {
|
||||||
|
SetupBlackAndBlueStripedPalette();
|
||||||
|
noisespeedx = -4;
|
||||||
|
noisespeedy = -4;
|
||||||
|
noisespeedz = -4;
|
||||||
|
noisescale = 32;
|
||||||
|
colorLoop = 0;
|
||||||
|
drawNoise3d(blackAndBlueStripedPalette);
|
||||||
|
}
|
18
README.md
18
README.md
@ -1,22 +1,26 @@
|
|||||||
FastLED + ESP8266 Web Server
|
Ultim8x8 RGB LED Panel + FastLED + ESP8266 Web Server
|
||||||
=========
|
=========
|
||||||
|
|
||||||
Control an addressable LED strip with an ESP8266 via a web browser or infrared remote control.
|
Control an [ULTiM8x8 RGB LED Panel] with an ESP8266 via a web browser.
|
||||||
|
|
||||||
|
[Demo Video](https://www.youtube.com/watch?v=xigy7J_K7Aw):
|
||||||
|
|
||||||
|
[](http://www.youtube.com/watch?v=xigy7J_K7Aw)
|
||||||
|
|
||||||
Hardware
|
Hardware
|
||||||
--------
|
--------
|
||||||
|
|
||||||
An ESP8266 development board, such as the [Adafruit HUZZAH ESP8266 Breakout]:
|
[ULTiM8x8 RGB LED Panel](https://www.crowdsupply.com/maniacal-labs-wyolum/ultim8x8)
|
||||||
|
|
||||||
[](https://www.adafruit.com/products/2471)
|
[](https://www.crowdsupply.com/maniacal-labs-wyolum/ultim8x8)
|
||||||
|
|
||||||
Addressable LED strip, such as the [Adafruit NeoPixel Ring]:
|
[Adafruit Feather HUZZAH with ESP8266 WiFi](https://www.adafruit.com/products/2821)
|
||||||
|
|
||||||
[](https://www.adafruit.com/product/1586)
|
[](https://www.adafruit.com/products/2821)
|
||||||
|
|
||||||
Features
|
Features
|
||||||
--------
|
--------
|
||||||
* Turn the NeoPixel Ring on and off
|
* Turn the LEDs on and off
|
||||||
* Adjust the brightness
|
* Adjust the brightness
|
||||||
* Change the display pattern
|
* Change the display pattern
|
||||||
* Adjust the color
|
* Adjust the color
|
||||||
|
65
Text.h
65
Text.h
@ -1,65 +0,0 @@
|
|||||||
bool mask[NUM_LEDS];
|
|
||||||
|
|
||||||
const byte digits4x8[8 * 10] = {
|
|
||||||
0x06, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x06, // 0
|
|
||||||
0x04, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x0e, // 1
|
|
||||||
0x06, 0x09, 0x08, 0x08, 0x04, 0x02, 0x01, 0x0f, // 2
|
|
||||||
0x06, 0x09, 0x08, 0x04, 0x08, 0x08, 0x09, 0x06, // 3
|
|
||||||
0x04, 0x05, 0x05, 0x05, 0x0f, 0x04, 0x04, 0x04, // 4
|
|
||||||
0x0f, 0x01, 0x01, 0x07, 0x08, 0x08, 0x09, 0x06, // 5
|
|
||||||
0x06, 0x09, 0x01, 0x07, 0x09, 0x09, 0x09, 0x06, // 6
|
|
||||||
0x0f, 0x08, 0x08, 0x04, 0x02, 0x01, 0x01, 0x01, // 7
|
|
||||||
0x06, 0x09, 0x09, 0x06, 0x09, 0x09, 0x09, 0x06, // 8
|
|
||||||
0x06, 0x09, 0x09, 0x09, 0x0e, 0x08, 0x09, 0x06, // 9
|
|
||||||
};
|
|
||||||
|
|
||||||
// preceed with a call to fillMask(false);
|
|
||||||
// set mask to true where digit should light
|
|
||||||
void digit(byte start, byte d) {
|
|
||||||
byte row, col;
|
|
||||||
for (col = 0; col < 4; col++) {
|
|
||||||
for (row = 0; row < 8; row++) {
|
|
||||||
if ((digits4x8[d * 8 + row] >> col) & 1) {
|
|
||||||
togglePixelMask(row, col + start, true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void displayNum(uint32_t n) {
|
|
||||||
digit( 0, (n / 10000) % 10);
|
|
||||||
digit( 5, (n / 1000) % 10);
|
|
||||||
digit(10, (n / 100) % 10);
|
|
||||||
digit(15, (n / 10) % 10);
|
|
||||||
digit(20, (n / 1) % 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
void displayTime(uint32_t tm) {
|
|
||||||
uint8_t hh = (tm / 3600) % 12;
|
|
||||||
uint8_t mm = (tm / 60) % 60;
|
|
||||||
uint8_t ss = (tm) % 60;
|
|
||||||
if (hh > 9) {
|
|
||||||
digit( 1, hh / 10);
|
|
||||||
}
|
|
||||||
digit( 6, hh % 10);
|
|
||||||
setPixelMask(2, 11, true);
|
|
||||||
setPixelMask(3, 11, true);
|
|
||||||
setPixelMask(5, 11, true);
|
|
||||||
setPixelMask(6, 11, true);
|
|
||||||
digit(13, mm / 10);
|
|
||||||
digit(18, mm % 10);
|
|
||||||
|
|
||||||
if (hh > 9) {
|
|
||||||
digit( 1 + 24, hh / 10);
|
|
||||||
}
|
|
||||||
digit( 6 + 24, hh % 10);
|
|
||||||
setPixelMask(2, 11 + 24, true);
|
|
||||||
setPixelMask(3, 11 + 24, true);
|
|
||||||
setPixelMask(5, 11 + 24, true);
|
|
||||||
setPixelMask(6, 11 + 24, true);
|
|
||||||
digit(13 + 24, mm / 10);
|
|
||||||
digit(18 + 24, mm % 10);
|
|
||||||
}
|
|
||||||
|
|
@ -194,7 +194,7 @@ void drawTwinkles()
|
|||||||
|
|
||||||
uint8_t backgroundBrightness = bg.getAverageLight();
|
uint8_t backgroundBrightness = bg.getAverageLight();
|
||||||
|
|
||||||
for(uint8_t i = 0; i < NUM_LEDS; i++) {
|
for(uint16_t i = 0; i < NUM_LEDS; i++) {
|
||||||
CRGB& pixel = leds[i];
|
CRGB& pixel = leds[i];
|
||||||
|
|
||||||
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
|
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
|
||||||
|
@ -24,25 +24,25 @@ extern "C" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#include <ESP8266mDNS.h>
|
//#include <ESP8266mDNS.h>
|
||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266WebServer.h>
|
||||||
#include <ESP8266HTTPUpdateServer.h>
|
#include <ESP8266HTTPUpdateServer.h>
|
||||||
#include <WebSocketsServer.h>
|
#include <WebSocketsServer.h>
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include <IRremoteESP8266.h>
|
//#include <IRremoteESP8266.h>
|
||||||
#include "GradientPalettes.h"
|
#include "GradientPalettes.h"
|
||||||
|
|
||||||
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
|
#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
|
||||||
|
|
||||||
#include "Field.h"
|
#include "Field.h"
|
||||||
|
|
||||||
#define HOSTNAME "ESP8266-" ///< Hostname. The setup function adds the Chip ID at the end.
|
#define HOSTNAME "ESP8266-Feather-" ///< Hostname. The setup function adds the Chip ID at the end.
|
||||||
|
|
||||||
#define RECV_PIN 1
|
//#define RECV_PIN D4
|
||||||
IRrecv irReceiver(RECV_PIN);
|
//IRrecv irReceiver(RECV_PIN);
|
||||||
|
|
||||||
#include "Commands.h"
|
//#include "Commands.h"
|
||||||
|
|
||||||
const bool apMode = false;
|
const bool apMode = false;
|
||||||
|
|
||||||
@ -59,15 +59,17 @@ ESP8266HTTPUpdateServer httpUpdateServer;
|
|||||||
|
|
||||||
#include "FSBrowser.h"
|
#include "FSBrowser.h"
|
||||||
|
|
||||||
#define DATA_PIN MOSI
|
#define DATA_PIN 13
|
||||||
#define CLK_PIN SCK
|
#define CLK_PIN 14
|
||||||
#define LED_TYPE APA102
|
#define LED_TYPE APA102
|
||||||
#define COLOR_ORDER BGR
|
#define COLOR_ORDER BGR
|
||||||
#define MatrixWidth 8 * 3
|
#define MatrixWidth 24
|
||||||
#define MatrixHeight 8
|
#define MatrixHeight 8
|
||||||
#define NUM_LEDS MatrixWidth * MatrixHeight
|
#define NUM_LEDS MatrixWidth * MatrixHeight
|
||||||
|
|
||||||
#define MILLI_AMPS 500 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA)
|
const bool MatrixSerpentineLayout = true;
|
||||||
|
|
||||||
|
#define MILLI_AMPS 2000 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA)
|
||||||
#define FRAMES_PER_SECOND 120 // here you can control the speed. With the Access Point / Web Server the animations run a bit slower.
|
#define FRAMES_PER_SECOND 120 // here you can control the speed. With the Access Point / Web Server the animations run a bit slower.
|
||||||
|
|
||||||
CRGB leds[NUM_LEDS];
|
CRGB leds[NUM_LEDS];
|
||||||
@ -109,8 +111,6 @@ CRGBPalette16 IceColors_p = CRGBPalette16(CRGB::Black, CRGB::Blue, CRGB::Aqua, C
|
|||||||
uint8_t currentPatternIndex = 0; // Index number of which pattern is current
|
uint8_t currentPatternIndex = 0; // Index number of which pattern is current
|
||||||
uint8_t autoplay = 0;
|
uint8_t autoplay = 0;
|
||||||
|
|
||||||
bool resetPattern = true;
|
|
||||||
|
|
||||||
uint8_t autoplayDuration = 10;
|
uint8_t autoplayDuration = 10;
|
||||||
unsigned long autoPlayTimeout = 0;
|
unsigned long autoPlayTimeout = 0;
|
||||||
|
|
||||||
@ -120,17 +120,7 @@ uint8_t gHue = 0; // rotating "base color" used by many of the patterns
|
|||||||
|
|
||||||
CRGB solidColor = CRGB::Blue;
|
CRGB solidColor = CRGB::Blue;
|
||||||
|
|
||||||
// scale the brightness of all pixels down
|
uint16_t XY( uint8_t x, uint8_t y)
|
||||||
void dimAll(byte value)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < NUM_LEDS; i++) {
|
|
||||||
leds[i].nscale8(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool MatrixSerpentineLayout = true;
|
|
||||||
|
|
||||||
uint16_t XY(uint8_t x, uint8_t y)
|
|
||||||
{
|
{
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
|
|
||||||
@ -152,6 +142,44 @@ uint16_t XY(uint8_t x, uint8_t y)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// scale the brightness of all pixels down
|
||||||
|
void dimAll(byte value)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < NUM_LEDS; i++) {
|
||||||
|
leds[i].nscale8(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
CRGBPalette16 palette;
|
||||||
|
String name;
|
||||||
|
} PaletteAndName;
|
||||||
|
typedef PaletteAndName PaletteAndNameList[];
|
||||||
|
|
||||||
|
const CRGBPalette16 palettes[] = {
|
||||||
|
RainbowColors_p,
|
||||||
|
RainbowStripeColors_p,
|
||||||
|
CloudColors_p,
|
||||||
|
LavaColors_p,
|
||||||
|
OceanColors_p,
|
||||||
|
ForestColors_p,
|
||||||
|
PartyColors_p,
|
||||||
|
HeatColors_p
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint8_t paletteCount = ARRAY_SIZE(palettes);
|
||||||
|
|
||||||
|
const String paletteNames[paletteCount] = {
|
||||||
|
"Rainbow",
|
||||||
|
"Rainbow Stripe",
|
||||||
|
"Cloud",
|
||||||
|
"Lava",
|
||||||
|
"Ocean",
|
||||||
|
"Forest",
|
||||||
|
"Party",
|
||||||
|
"Heat",
|
||||||
|
};
|
||||||
|
|
||||||
typedef void (*Pattern)();
|
typedef void (*Pattern)();
|
||||||
typedef Pattern PatternList[];
|
typedef Pattern PatternList[];
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -162,19 +190,72 @@ typedef PatternAndName PatternAndNameList[];
|
|||||||
|
|
||||||
#include "Twinkles.h"
|
#include "Twinkles.h"
|
||||||
#include "TwinkleFOX.h"
|
#include "TwinkleFOX.h"
|
||||||
#include "Sunrise.h"
|
#include "Map.h"
|
||||||
|
#include "Noise.h"
|
||||||
|
|
||||||
// List of patterns to cycle through. Each is defined as a separate function below.
|
// List of patterns to cycle through. Each is defined as a separate function below.
|
||||||
|
|
||||||
PatternAndNameList patterns = {
|
PatternAndNameList patterns = {
|
||||||
{ sunriseStatic, "Sunrise Static" },
|
|
||||||
{ sunriseFlicker, "Sunrise Flicker" },
|
|
||||||
{ sunriseWavesVertical, "Sunrise Waves Vertical" },
|
|
||||||
{ sunriseWavesHorizontal, "Sunrise Waves Horizontal" },
|
|
||||||
{ sunriseWavesDiagonal, "Sunrise Waves Diagonal" },
|
|
||||||
{ sunriseWavesRotating, "Sunrise Waves Rotating" },
|
|
||||||
{ pride, "Pride" },
|
{ pride, "Pride" },
|
||||||
|
{ pride2, "Pride 2" },
|
||||||
{ colorWaves, "Color Waves" },
|
{ colorWaves, "Color Waves" },
|
||||||
|
{ colorWaves2, "Color Waves 2" },
|
||||||
|
|
||||||
|
{ cubeTest, "Cube XYZ Test" },
|
||||||
|
|
||||||
|
{ cubeXPalette, "Cube X Palette" },
|
||||||
|
{ cubeYPalette, "Cube Y Palette" },
|
||||||
|
{ cubeZPalette, "Cube Z Palette" },
|
||||||
|
|
||||||
|
{ cubeXYPalette, "Cube XY Palette" },
|
||||||
|
{ cubeXZPalette, "Cube XZ Palette" },
|
||||||
|
{ cubeYZPalette, "Cube YZ Palette" },
|
||||||
|
{ cubeXYZPalette, "Cube XYZ Palette" },
|
||||||
|
|
||||||
|
{ cubeXGradientPalette, "Cube X Gradient Palette" },
|
||||||
|
{ cubeYGradientPalette, "Cube Y Gradient Palette" },
|
||||||
|
{ cubeZGradientPalette, "Cube Z Gradient Palette" },
|
||||||
|
|
||||||
|
{ cubeXYGradientPalette, "Cube XY Gradient Palette" },
|
||||||
|
{ cubeXZGradientPalette, "Cube XZ Gradient Palette" },
|
||||||
|
{ cubeYZGradientPalette, "Cube YZ Gradient Palette" },
|
||||||
|
{ cubeXYZGradientPalette, "Cube XYZ Gradient Palette" },
|
||||||
|
|
||||||
|
// 3d noise patterns
|
||||||
|
{ fireNoise3d, "Fire Noise 3D" },
|
||||||
|
{ fireNoise23d, "Fire Noise 2 3D" },
|
||||||
|
{ lavaNoise3d, "Lava Noise 3D" },
|
||||||
|
{ rainbowNoise3d, "Rainbow Noise 3D" },
|
||||||
|
{ rainbowStripeNoise3d, "Rainbow Stripe Noise 3D" },
|
||||||
|
{ partyNoise3d, "Party Noise 3D" },
|
||||||
|
{ forestNoise3d, "Forest Noise 3D" },
|
||||||
|
{ cloudNoise3d, "Cloud Noise 3D" },
|
||||||
|
{ oceanNoise3d, "Ocean Noise 3D" },
|
||||||
|
{ blackAndWhiteNoise3d, "Black & White Noise 3D" },
|
||||||
|
{ blackAndBlueNoise3d, "Black & Blue Noise 3D" },
|
||||||
|
|
||||||
|
{ xyMatrixTest, "Matrix Test" },
|
||||||
|
|
||||||
|
{ verticalPalette, "Vertical Palette" },
|
||||||
|
{ diagonalPalette, "Diagonal Palette" },
|
||||||
|
{ horizontalPalette, "Horizontal Palette" },
|
||||||
|
|
||||||
|
{ verticalGradientPalette, "Vertical Gradient Palette" },
|
||||||
|
{ diagonalGradientPalette, "Diagonal Gradient Palette" },
|
||||||
|
{ horizontalGradientPalette, "Horizontal Gradient Palette" },
|
||||||
|
|
||||||
|
// noise patterns
|
||||||
|
{ fireNoise, "Fire Noise" },
|
||||||
|
{ fireNoise2, "Fire Noise 2" },
|
||||||
|
{ lavaNoise, "Lava Noise" },
|
||||||
|
{ rainbowNoise, "Rainbow Noise" },
|
||||||
|
{ rainbowStripeNoise, "Rainbow Stripe Noise" },
|
||||||
|
{ partyNoise, "Party Noise" },
|
||||||
|
{ forestNoise, "Forest Noise" },
|
||||||
|
{ cloudNoise, "Cloud Noise" },
|
||||||
|
{ oceanNoise, "Ocean Noise" },
|
||||||
|
{ blackAndWhiteNoise, "Black & White Noise" },
|
||||||
|
{ blackAndBlueNoise, "Black & Blue Noise" },
|
||||||
|
|
||||||
// twinkle patterns
|
// twinkle patterns
|
||||||
{ rainbowTwinkles, "Rainbow Twinkles" },
|
{ rainbowTwinkles, "Rainbow Twinkles" },
|
||||||
@ -213,36 +294,6 @@ PatternAndNameList patterns = {
|
|||||||
|
|
||||||
const uint8_t patternCount = ARRAY_SIZE(patterns);
|
const uint8_t patternCount = ARRAY_SIZE(patterns);
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
CRGBPalette16 palette;
|
|
||||||
String name;
|
|
||||||
} PaletteAndName;
|
|
||||||
typedef PaletteAndName PaletteAndNameList[];
|
|
||||||
|
|
||||||
const CRGBPalette16 palettes[] = {
|
|
||||||
RainbowColors_p,
|
|
||||||
RainbowStripeColors_p,
|
|
||||||
CloudColors_p,
|
|
||||||
LavaColors_p,
|
|
||||||
OceanColors_p,
|
|
||||||
ForestColors_p,
|
|
||||||
PartyColors_p,
|
|
||||||
HeatColors_p
|
|
||||||
};
|
|
||||||
|
|
||||||
const uint8_t paletteCount = ARRAY_SIZE(palettes);
|
|
||||||
|
|
||||||
const String paletteNames[paletteCount] = {
|
|
||||||
"Rainbow",
|
|
||||||
"Rainbow Stripe",
|
|
||||||
"Cloud",
|
|
||||||
"Lava",
|
|
||||||
"Ocean",
|
|
||||||
"Forest",
|
|
||||||
"Party",
|
|
||||||
"Heat",
|
|
||||||
};
|
|
||||||
|
|
||||||
#include "Fields.h"
|
#include "Fields.h"
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
@ -250,9 +301,9 @@ void setup() {
|
|||||||
delay(100);
|
delay(100);
|
||||||
Serial.setDebugOutput(true);
|
Serial.setDebugOutput(true);
|
||||||
|
|
||||||
// FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS); // for WS2812 (Neopixel)
|
//FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS); // for WS2812 (Neopixel)
|
||||||
FastLED.addLeds<LED_TYPE, DATA_PIN, CLK_PIN, COLOR_ORDER>(leds, NUM_LEDS); // for APA102 (Dotstar)
|
FastLED.addLeds<LED_TYPE, DATA_PIN, CLK_PIN, COLOR_ORDER>(leds, NUM_LEDS); // for APA102 (Dotstar)
|
||||||
FastLED.setDither(false);
|
FastLED.setDither(true);
|
||||||
FastLED.setCorrection(TypicalLEDStrip);
|
FastLED.setCorrection(TypicalLEDStrip);
|
||||||
FastLED.setBrightness(brightness);
|
FastLED.setBrightness(brightness);
|
||||||
FastLED.setMaxPowerInVoltsAndMilliamps(5, MILLI_AMPS);
|
FastLED.setMaxPowerInVoltsAndMilliamps(5, MILLI_AMPS);
|
||||||
@ -264,7 +315,7 @@ void setup() {
|
|||||||
|
|
||||||
FastLED.setBrightness(brightness);
|
FastLED.setBrightness(brightness);
|
||||||
|
|
||||||
irReceiver.enableIRIn(); // Start the receiver
|
// irReceiver.enableIRIn(); // Start the receiver
|
||||||
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size());
|
Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size());
|
||||||
@ -299,10 +350,10 @@ void setup() {
|
|||||||
for (uint8_t i = 0; i < hostname.length(); i++)
|
for (uint8_t i = 0; i < hostname.length(); i++)
|
||||||
hostnameChar[i] = hostname.charAt(i);
|
hostnameChar[i] = hostname.charAt(i);
|
||||||
|
|
||||||
MDNS.begin(hostnameChar);
|
// MDNS.begin(hostnameChar);
|
||||||
|
|
||||||
// Add service to MDNS-SD
|
// Add service to MDNS-SD
|
||||||
MDNS.addService("http", "tcp", 80);
|
// MDNS.addService("http", "tcp", 80);
|
||||||
|
|
||||||
// Print hostname.
|
// Print hostname.
|
||||||
Serial.println("Hostname: " + hostname);
|
Serial.println("Hostname: " + hostname);
|
||||||
@ -382,7 +433,7 @@ void setup() {
|
|||||||
|
|
||||||
webServer.on("/speed", HTTP_POST, []() {
|
webServer.on("/speed", HTTP_POST, []() {
|
||||||
String value = webServer.arg("value");
|
String value = webServer.arg("value");
|
||||||
speed = value.toInt();
|
setSpeed(value.toInt());
|
||||||
broadcastInt("speed", speed);
|
broadcastInt("speed", speed);
|
||||||
sendInt(speed);
|
sendInt(speed);
|
||||||
});
|
});
|
||||||
@ -512,7 +563,7 @@ void loop() {
|
|||||||
webSocketsServer.loop();
|
webSocketsServer.loop();
|
||||||
webServer.handleClient();
|
webServer.handleClient();
|
||||||
|
|
||||||
handleIrInput();
|
// handleIrInput();
|
||||||
|
|
||||||
if (power == 0) {
|
if (power == 0) {
|
||||||
fill_solid(leds, NUM_LEDS, CRGB::Black);
|
fill_solid(leds, NUM_LEDS, CRGB::Black);
|
||||||
@ -547,10 +598,8 @@ void loop() {
|
|||||||
|
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
|
|
||||||
resetPattern = false;
|
|
||||||
|
|
||||||
// insert a delay to keep the framerate modest
|
// insert a delay to keep the framerate modest
|
||||||
// FastLED.delay(1000 / FRAMES_PER_SECOND);
|
FastLED.delay(1000 / FRAMES_PER_SECOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {
|
void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length) {
|
||||||
@ -590,212 +639,212 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t length
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleIrInput()
|
//void handleIrInput()
|
||||||
{
|
//{
|
||||||
InputCommand command = readCommand();
|
// InputCommand command = readCommand();
|
||||||
|
//
|
||||||
if (command != InputCommand::None) {
|
// if (command != InputCommand::None) {
|
||||||
Serial.print("command: ");
|
// Serial.print("command: ");
|
||||||
Serial.println((int) command);
|
// Serial.println((int) command);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
switch (command) {
|
// switch (command) {
|
||||||
case InputCommand::Up: {
|
// case InputCommand::Up: {
|
||||||
adjustPattern(true);
|
// adjustPattern(true);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Down: {
|
// case InputCommand::Down: {
|
||||||
adjustPattern(false);
|
// adjustPattern(false);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Power: {
|
// case InputCommand::Power: {
|
||||||
setPower(power == 0 ? 1 : 0);
|
// setPower(power == 0 ? 1 : 0);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::BrightnessUp: {
|
// case InputCommand::BrightnessUp: {
|
||||||
adjustBrightness(true);
|
// adjustBrightness(true);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::BrightnessDown: {
|
// case InputCommand::BrightnessDown: {
|
||||||
adjustBrightness(false);
|
// adjustBrightness(false);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::PlayMode: { // toggle pause/play
|
// case InputCommand::PlayMode: { // toggle pause/play
|
||||||
setAutoplay(!autoplay);
|
// setAutoplay(!autoplay);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// pattern buttons
|
// // pattern buttons
|
||||||
|
//
|
||||||
case InputCommand::Pattern1: {
|
// case InputCommand::Pattern1: {
|
||||||
setPattern(0);
|
// setPattern(0);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Pattern2: {
|
// case InputCommand::Pattern2: {
|
||||||
setPattern(1);
|
// setPattern(1);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Pattern3: {
|
// case InputCommand::Pattern3: {
|
||||||
setPattern(2);
|
// setPattern(2);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Pattern4: {
|
// case InputCommand::Pattern4: {
|
||||||
setPattern(3);
|
// setPattern(3);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Pattern5: {
|
// case InputCommand::Pattern5: {
|
||||||
setPattern(4);
|
// setPattern(4);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Pattern6: {
|
// case InputCommand::Pattern6: {
|
||||||
setPattern(5);
|
// setPattern(5);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Pattern7: {
|
// case InputCommand::Pattern7: {
|
||||||
setPattern(6);
|
// setPattern(6);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Pattern8: {
|
// case InputCommand::Pattern8: {
|
||||||
setPattern(7);
|
// setPattern(7);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Pattern9: {
|
// case InputCommand::Pattern9: {
|
||||||
setPattern(8);
|
// setPattern(8);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Pattern10: {
|
// case InputCommand::Pattern10: {
|
||||||
setPattern(9);
|
// setPattern(9);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Pattern11: {
|
// case InputCommand::Pattern11: {
|
||||||
setPattern(10);
|
// setPattern(10);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Pattern12: {
|
// case InputCommand::Pattern12: {
|
||||||
setPattern(11);
|
// setPattern(11);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// custom color adjustment buttons
|
// // custom color adjustment buttons
|
||||||
|
//
|
||||||
case InputCommand::RedUp: {
|
// case InputCommand::RedUp: {
|
||||||
solidColor.red += 8;
|
// solidColor.red += 8;
|
||||||
setSolidColor(solidColor);
|
// setSolidColor(solidColor);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::RedDown: {
|
// case InputCommand::RedDown: {
|
||||||
solidColor.red -= 8;
|
// solidColor.red -= 8;
|
||||||
setSolidColor(solidColor);
|
// setSolidColor(solidColor);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::GreenUp: {
|
// case InputCommand::GreenUp: {
|
||||||
solidColor.green += 8;
|
// solidColor.green += 8;
|
||||||
setSolidColor(solidColor);
|
// setSolidColor(solidColor);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::GreenDown: {
|
// case InputCommand::GreenDown: {
|
||||||
solidColor.green -= 8;
|
// solidColor.green -= 8;
|
||||||
setSolidColor(solidColor);
|
// setSolidColor(solidColor);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::BlueUp: {
|
// case InputCommand::BlueUp: {
|
||||||
solidColor.blue += 8;
|
// solidColor.blue += 8;
|
||||||
setSolidColor(solidColor);
|
// setSolidColor(solidColor);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::BlueDown: {
|
// case InputCommand::BlueDown: {
|
||||||
solidColor.blue -= 8;
|
// solidColor.blue -= 8;
|
||||||
setSolidColor(solidColor);
|
// setSolidColor(solidColor);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// color buttons
|
// // color buttons
|
||||||
|
//
|
||||||
case InputCommand::Red: {
|
// case InputCommand::Red: {
|
||||||
setSolidColor(CRGB::Red);
|
// setSolidColor(CRGB::Red);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::RedOrange: {
|
// case InputCommand::RedOrange: {
|
||||||
setSolidColor(CRGB::OrangeRed);
|
// setSolidColor(CRGB::OrangeRed);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Orange: {
|
// case InputCommand::Orange: {
|
||||||
setSolidColor(CRGB::Orange);
|
// setSolidColor(CRGB::Orange);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::YellowOrange: {
|
// case InputCommand::YellowOrange: {
|
||||||
setSolidColor(CRGB::Goldenrod);
|
// setSolidColor(CRGB::Goldenrod);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Yellow: {
|
// case InputCommand::Yellow: {
|
||||||
setSolidColor(CRGB::Yellow);
|
// setSolidColor(CRGB::Yellow);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
case InputCommand::Green: {
|
// case InputCommand::Green: {
|
||||||
setSolidColor(CRGB::Green);
|
// setSolidColor(CRGB::Green);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Lime: {
|
// case InputCommand::Lime: {
|
||||||
setSolidColor(CRGB::Lime);
|
// setSolidColor(CRGB::Lime);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Aqua: {
|
// case InputCommand::Aqua: {
|
||||||
setSolidColor(CRGB::Aqua);
|
// setSolidColor(CRGB::Aqua);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Teal: {
|
// case InputCommand::Teal: {
|
||||||
setSolidColor(CRGB::Teal);
|
// setSolidColor(CRGB::Teal);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Navy: {
|
// case InputCommand::Navy: {
|
||||||
setSolidColor(CRGB::Navy);
|
// setSolidColor(CRGB::Navy);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
case InputCommand::Blue: {
|
// case InputCommand::Blue: {
|
||||||
setSolidColor(CRGB::Blue);
|
// setSolidColor(CRGB::Blue);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::RoyalBlue: {
|
// case InputCommand::RoyalBlue: {
|
||||||
setSolidColor(CRGB::RoyalBlue);
|
// setSolidColor(CRGB::RoyalBlue);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Purple: {
|
// case InputCommand::Purple: {
|
||||||
setSolidColor(CRGB::Purple);
|
// setSolidColor(CRGB::Purple);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Indigo: {
|
// case InputCommand::Indigo: {
|
||||||
setSolidColor(CRGB::Indigo);
|
// setSolidColor(CRGB::Indigo);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Magenta: {
|
// case InputCommand::Magenta: {
|
||||||
setSolidColor(CRGB::Magenta);
|
// setSolidColor(CRGB::Magenta);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
case InputCommand::White: {
|
// case InputCommand::White: {
|
||||||
setSolidColor(CRGB::White);
|
// setSolidColor(CRGB::White);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::Pink: {
|
// case InputCommand::Pink: {
|
||||||
setSolidColor(CRGB::Pink);
|
// setSolidColor(CRGB::Pink);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::LightPink: {
|
// case InputCommand::LightPink: {
|
||||||
setSolidColor(CRGB::LightPink);
|
// setSolidColor(CRGB::LightPink);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::BabyBlue: {
|
// case InputCommand::BabyBlue: {
|
||||||
setSolidColor(CRGB::CornflowerBlue);
|
// setSolidColor(CRGB::CornflowerBlue);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
case InputCommand::LightBlue: {
|
// case InputCommand::LightBlue: {
|
||||||
setSolidColor(CRGB::LightBlue);
|
// setSolidColor(CRGB::LightBlue);
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
||||||
void loadSettings()
|
void loadSettings()
|
||||||
{
|
{
|
||||||
@ -829,6 +878,8 @@ void loadSettings()
|
|||||||
currentPaletteIndex = 0;
|
currentPaletteIndex = 0;
|
||||||
else if (currentPaletteIndex >= paletteCount)
|
else if (currentPaletteIndex >= paletteCount)
|
||||||
currentPaletteIndex = paletteCount - 1;
|
currentPaletteIndex = paletteCount - 1;
|
||||||
|
|
||||||
|
speed = EEPROM.read(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPower(uint8_t value)
|
void setPower(uint8_t value)
|
||||||
@ -917,8 +968,6 @@ void setPattern(uint8_t value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
broadcastInt("pattern", currentPatternIndex);
|
broadcastInt("pattern", currentPatternIndex);
|
||||||
|
|
||||||
resetPattern = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPatternName(String name)
|
void setPatternName(String name)
|
||||||
@ -954,6 +1003,16 @@ void setPaletteName(String name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setSpeed(uint8_t value)
|
||||||
|
{
|
||||||
|
speed = value;
|
||||||
|
|
||||||
|
EEPROM.write(9, value);
|
||||||
|
EEPROM.commit();
|
||||||
|
|
||||||
|
broadcastInt("speed", speed);
|
||||||
|
}
|
||||||
|
|
||||||
void adjustBrightness(bool up)
|
void adjustBrightness(bool up)
|
||||||
{
|
{
|
||||||
if (up && brightnessIndex < brightnessCount - 1)
|
if (up && brightnessIndex < brightnessCount - 1)
|
||||||
@ -1016,6 +1075,97 @@ void rainbow()
|
|||||||
fill_rainbow( leds, NUM_LEDS, gHue, 255 / NUM_LEDS);
|
fill_rainbow( leds, NUM_LEDS, gHue, 255 / NUM_LEDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void xyMatrixTest()
|
||||||
|
{
|
||||||
|
FastLED.clear();
|
||||||
|
|
||||||
|
static uint8_t x = 0;
|
||||||
|
static uint8_t y = 0;
|
||||||
|
|
||||||
|
leds[XY(x, y)] = CHSV(gHue, 255, 255);
|
||||||
|
|
||||||
|
EVERY_N_MILLIS(30) {
|
||||||
|
x++;
|
||||||
|
if (x >= MatrixWidth) {
|
||||||
|
x = 0;
|
||||||
|
y++;
|
||||||
|
if (y >= MatrixHeight) {
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void verticalPalette() {
|
||||||
|
uint8_t verticalHues = 256 / MatrixHeight;
|
||||||
|
|
||||||
|
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
||||||
|
CRGB color = ColorFromPalette(palettes[currentPaletteIndex], beat8(speed) + (y * verticalHues));
|
||||||
|
|
||||||
|
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
||||||
|
leds[XY(x, y)] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void diagonalPalette() {
|
||||||
|
uint8_t verticalHues = 256 / MatrixHeight;
|
||||||
|
|
||||||
|
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
||||||
|
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
||||||
|
CRGB color = ColorFromPalette(palettes[currentPaletteIndex], beat8(speed) - ((x - y) * verticalHues));
|
||||||
|
leds[XY(x, y)] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void horizontalPalette() {
|
||||||
|
uint8_t horizontalHues = 256 / MatrixWidth;
|
||||||
|
|
||||||
|
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
||||||
|
CRGB color = ColorFromPalette(palettes[currentPaletteIndex], beat8(speed) - (x * horizontalHues));
|
||||||
|
|
||||||
|
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
||||||
|
leds[XY(x, y)] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void verticalGradientPalette() {
|
||||||
|
uint8_t verticalHues = 256 / MatrixHeight;
|
||||||
|
|
||||||
|
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
||||||
|
CRGB color = ColorFromPalette(gCurrentPalette, beat8(speed) + (y * verticalHues));
|
||||||
|
|
||||||
|
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
||||||
|
leds[XY(x, y)] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void diagonalGradientPalette() {
|
||||||
|
uint8_t verticalHues = 256 / MatrixHeight;
|
||||||
|
|
||||||
|
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
||||||
|
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
||||||
|
CRGB color = ColorFromPalette(gCurrentPalette, beat8(speed) - ((x - y) * verticalHues));
|
||||||
|
leds[XY(x, y)] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void horizontalGradientPalette() {
|
||||||
|
uint8_t horizontalHues = 256 / MatrixWidth;
|
||||||
|
|
||||||
|
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
||||||
|
CRGB color = ColorFromPalette(gCurrentPalette, beat8(speed) - (x * horizontalHues));
|
||||||
|
|
||||||
|
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
||||||
|
leds[XY(x, y)] = color;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void rainbowWithGlitter()
|
void rainbowWithGlitter()
|
||||||
{
|
{
|
||||||
// built-in FastLED rainbow, plus some random sparkly glitter
|
// built-in FastLED rainbow, plus some random sparkly glitter
|
||||||
@ -1150,6 +1300,46 @@ void pride()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void pride2()
|
||||||
|
{
|
||||||
|
static uint16_t sPseudotime = 0;
|
||||||
|
static uint16_t sLastMillis = 0;
|
||||||
|
static uint16_t sHue16 = 0;
|
||||||
|
|
||||||
|
uint8_t sat8 = beatsin88( 87, 220, 250);
|
||||||
|
uint8_t brightdepth = beatsin88( 341, 96, 224);
|
||||||
|
uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
|
||||||
|
uint8_t msmultiplier = beatsin88(147, 23, 60);
|
||||||
|
|
||||||
|
uint16_t hue16 = sHue16;//gHue * 256;
|
||||||
|
uint16_t hueinc16 = beatsin88(113, 1, 3000);
|
||||||
|
|
||||||
|
uint16_t ms = millis();
|
||||||
|
uint16_t deltams = ms - sLastMillis ;
|
||||||
|
sLastMillis = ms;
|
||||||
|
sPseudotime += deltams * msmultiplier;
|
||||||
|
sHue16 += deltams * beatsin88( 400, 5, 9);
|
||||||
|
uint16_t brightnesstheta16 = sPseudotime;
|
||||||
|
|
||||||
|
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
||||||
|
hue16 += hueinc16;
|
||||||
|
uint8_t hue8 = hue16 / 256;
|
||||||
|
|
||||||
|
brightnesstheta16 += brightnessthetainc16;
|
||||||
|
uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
|
||||||
|
|
||||||
|
uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
|
||||||
|
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
|
||||||
|
bri8 += (255 - brightdepth);
|
||||||
|
|
||||||
|
CRGB newcolor = CHSV( hue8, sat8, bri8);
|
||||||
|
|
||||||
|
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
||||||
|
nblend(leds[XY(x, y)], newcolor, 64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void radialPaletteShift()
|
void radialPaletteShift()
|
||||||
{
|
{
|
||||||
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||||
@ -1289,6 +1479,56 @@ void colorwaves( CRGB* ledarray, uint16_t numleds, CRGBPalette16& palette)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void colorWaves2()
|
||||||
|
{
|
||||||
|
static uint16_t sPseudotime = 0;
|
||||||
|
static uint16_t sLastMillis = 0;
|
||||||
|
static uint16_t sHue16 = 0;
|
||||||
|
|
||||||
|
// uint8_t sat8 = beatsin88( 87, 220, 250);
|
||||||
|
uint8_t brightdepth = beatsin88( 341, 96, 224);
|
||||||
|
uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
|
||||||
|
uint8_t msmultiplier = beatsin88(147, 23, 60);
|
||||||
|
|
||||||
|
uint16_t hue16 = sHue16;//gHue * 256;
|
||||||
|
uint16_t hueinc16 = beatsin88(113, 300, 1500);
|
||||||
|
|
||||||
|
uint16_t ms = millis();
|
||||||
|
uint16_t deltams = ms - sLastMillis ;
|
||||||
|
sLastMillis = ms;
|
||||||
|
sPseudotime += deltams * msmultiplier;
|
||||||
|
sHue16 += deltams * beatsin88( 400, 5, 9);
|
||||||
|
uint16_t brightnesstheta16 = sPseudotime;
|
||||||
|
|
||||||
|
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
||||||
|
hue16 += hueinc16;
|
||||||
|
uint8_t hue8 = hue16 / 256;
|
||||||
|
uint16_t h16_128 = hue16 >> 7;
|
||||||
|
if ( h16_128 & 0x100) {
|
||||||
|
hue8 = 255 - (h16_128 >> 1);
|
||||||
|
} else {
|
||||||
|
hue8 = h16_128 >> 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
brightnesstheta16 += brightnessthetainc16;
|
||||||
|
uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
|
||||||
|
|
||||||
|
uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
|
||||||
|
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
|
||||||
|
bri8 += (255 - brightdepth);
|
||||||
|
|
||||||
|
uint8_t index = hue8;
|
||||||
|
//index = triwave8( index);
|
||||||
|
index = scale8( index, 240);
|
||||||
|
|
||||||
|
CRGB newcolor = ColorFromPalette(gCurrentPalette, index, bri8);
|
||||||
|
|
||||||
|
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
||||||
|
nblend(leds[XY(x, y)], newcolor, 128);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Alternate rendering function just scrolls the current palette
|
// Alternate rendering function just scrolls the current palette
|
||||||
// across the defined LED strip.
|
// across the defined LED strip.
|
||||||
void palettetest( CRGB* ledarray, uint16_t numleds, const CRGBPalette16& gCurrentPalette)
|
void palettetest( CRGB* ledarray, uint16_t numleds, const CRGBPalette16& gCurrentPalette)
|
||||||
|
193
sunrise.h
193
sunrise.h
@ -1,193 +0,0 @@
|
|||||||
const uint16_t sunriseSeconds = 60; // how long should the "sun" take to rise from completely dark to completely lit
|
|
||||||
const uint16_t sunriseMillis = (sunriseSeconds * 1000);
|
|
||||||
const uint16_t sunriseInterval = sunriseMillis / 240; // when using palettes, the usable range is 0-240 before it starts wrapping from the last color to the first
|
|
||||||
|
|
||||||
uint8_t sunriseIncrement = 4; // how much to change brightness for each level of the matrix
|
|
||||||
|
|
||||||
uint8_t sunriseLevel;
|
|
||||||
|
|
||||||
const CRGBPalette16 sunrisePalette = HeatColors_p;
|
|
||||||
const uint8_t centerX = MatrixWidth / 2;
|
|
||||||
|
|
||||||
void updateSunrise() {
|
|
||||||
EVERY_N_MILLIS(sunriseInterval) {
|
|
||||||
if (sunriseLevel < 240) {
|
|
||||||
sunriseLevel++;
|
|
||||||
Serial.print("Current level: "); Serial.println(sunriseLevel);
|
|
||||||
}
|
|
||||||
else if (sunriseIncrement > 0) {
|
|
||||||
sunriseIncrement--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (resetPattern) {
|
|
||||||
sunriseLevel = 0;
|
|
||||||
sunriseIncrement = 4;
|
|
||||||
FastLED.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sunriseStatic() {
|
|
||||||
updateSunrise();
|
|
||||||
|
|
||||||
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
|
||||||
int16_t d = sunriseLevel - sunriseIncrement;
|
|
||||||
|
|
||||||
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
|
||||||
if (d >= 0) {
|
|
||||||
CRGB newcolor = ColorFromPalette(sunrisePalette, random(0, d), random8(d, 255));
|
|
||||||
uint16_t pixelnumber = XY(x, y);
|
|
||||||
nblend(leds[pixelnumber], newcolor, 64);
|
|
||||||
}
|
|
||||||
d -= sunriseIncrement;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sunriseFlicker() {
|
|
||||||
dimAll(240);
|
|
||||||
|
|
||||||
updateSunrise();
|
|
||||||
|
|
||||||
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
|
||||||
int16_t d = sunriseLevel - sunriseIncrement;
|
|
||||||
|
|
||||||
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
|
||||||
if (d >= 0) {
|
|
||||||
CRGB newcolor = ColorFromPalette(sunrisePalette, random(0, d), random8(d, 255));
|
|
||||||
uint16_t pixelnumber = XY(x, y);
|
|
||||||
nblend(leds[pixelnumber], newcolor, 64);
|
|
||||||
}
|
|
||||||
d -= sunriseIncrement;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sunriseWavesDiagonal() {
|
|
||||||
dimAll(240);
|
|
||||||
|
|
||||||
updateSunrise();
|
|
||||||
|
|
||||||
uint8_t t = beat8(60);
|
|
||||||
|
|
||||||
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
|
||||||
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
|
||||||
uint8_t cx = sin8(x);
|
|
||||||
uint8_t cy = cos8(y);
|
|
||||||
uint8_t bri8 = sin8(8 * (cx + cy) + t);
|
|
||||||
|
|
||||||
CRGB newcolor = ColorFromPalette(sunrisePalette, sunriseLevel, bri8);
|
|
||||||
|
|
||||||
uint16_t pixelnumber = XY(x, y);
|
|
||||||
pixelnumber = (NUM_LEDS - 1) - pixelnumber;
|
|
||||||
|
|
||||||
nblend(leds[pixelnumber], newcolor, 64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sunriseWavesVertical() {
|
|
||||||
updateSunrise();
|
|
||||||
|
|
||||||
static uint16_t sPseudotime = 0;
|
|
||||||
static uint16_t sLastMillis = 0;
|
|
||||||
|
|
||||||
uint8_t brightdepth = beatsin88( 341, 96, 224);
|
|
||||||
uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
|
|
||||||
uint8_t msmultiplier = beatsin88(147, 23, 60);
|
|
||||||
|
|
||||||
uint16_t ms = millis();
|
|
||||||
uint16_t deltams = ms - sLastMillis ;
|
|
||||||
sLastMillis = ms;
|
|
||||||
sPseudotime += deltams * msmultiplier;
|
|
||||||
uint16_t brightnesstheta16 = sPseudotime;
|
|
||||||
|
|
||||||
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
|
||||||
brightnesstheta16 += brightnessthetainc16;
|
|
||||||
uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
|
|
||||||
|
|
||||||
uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
|
|
||||||
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
|
|
||||||
bri8 += (255 - brightdepth);
|
|
||||||
|
|
||||||
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
|
||||||
CRGB newcolor = ColorFromPalette(sunrisePalette, sunriseLevel, bri8);
|
|
||||||
|
|
||||||
uint16_t pixelnumber = XY(x, (MatrixHeight - 1) - y);
|
|
||||||
pixelnumber = (NUM_LEDS - 1) - pixelnumber;
|
|
||||||
|
|
||||||
nblend(leds[pixelnumber], newcolor, 64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sunriseWavesHorizontal() {
|
|
||||||
updateSunrise();
|
|
||||||
|
|
||||||
static uint16_t sPseudotime = 0;
|
|
||||||
static uint16_t sLastMillis = 0;
|
|
||||||
|
|
||||||
uint8_t brightdepth = beatsin88( 341, 96, 224);
|
|
||||||
uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
|
|
||||||
uint8_t msmultiplier = beatsin88(147, 23, 60);
|
|
||||||
|
|
||||||
uint16_t ms = millis();
|
|
||||||
uint16_t deltams = ms - sLastMillis ;
|
|
||||||
sLastMillis = ms;
|
|
||||||
sPseudotime += deltams * msmultiplier;
|
|
||||||
uint16_t brightnesstheta16 = sPseudotime;
|
|
||||||
|
|
||||||
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
|
||||||
brightnesstheta16 += brightnessthetainc16;
|
|
||||||
uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
|
|
||||||
|
|
||||||
uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
|
|
||||||
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
|
|
||||||
bri8 += (255 - brightdepth);
|
|
||||||
|
|
||||||
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
|
||||||
CRGB newcolor = ColorFromPalette(sunrisePalette, sunriseLevel, bri8);
|
|
||||||
|
|
||||||
uint16_t pixelnumber = XY(x, y);
|
|
||||||
pixelnumber = (NUM_LEDS - 1) - pixelnumber;
|
|
||||||
|
|
||||||
nblend(leds[pixelnumber], newcolor, 64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sunriseWavesRotating() {
|
|
||||||
updateSunrise();
|
|
||||||
|
|
||||||
static uint16_t sPseudotime = 0;
|
|
||||||
static uint16_t sLastMillis = 0;
|
|
||||||
|
|
||||||
uint8_t brightdepth = beatsin88( 341, 96, 224);
|
|
||||||
uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
|
|
||||||
uint8_t msmultiplier = beatsin88(147, 23, 60);
|
|
||||||
|
|
||||||
uint16_t ms = millis();
|
|
||||||
uint16_t deltams = ms - sLastMillis ;
|
|
||||||
sLastMillis = ms;
|
|
||||||
sPseudotime += deltams * msmultiplier;
|
|
||||||
uint16_t brightnesstheta16 = sPseudotime;
|
|
||||||
|
|
||||||
for (uint8_t x = 0; x < MatrixWidth; x++) {
|
|
||||||
for (uint8_t y = 0; y < MatrixHeight; y++) {
|
|
||||||
brightnesstheta16 += brightnessthetainc16;
|
|
||||||
uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
|
|
||||||
|
|
||||||
uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
|
|
||||||
uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
|
|
||||||
bri8 += (255 - brightdepth);
|
|
||||||
|
|
||||||
CRGB newcolor = ColorFromPalette(sunrisePalette, sunriseLevel, bri8);
|
|
||||||
|
|
||||||
uint16_t pixelnumber = XY(x, y);
|
|
||||||
pixelnumber = (NUM_LEDS - 1) - pixelnumber;
|
|
||||||
|
|
||||||
nblend(leds[pixelnumber], newcolor, 64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Reference in New Issue
Block a user