Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
d9ee4b6816 | |||
1d4f7e74de | |||
545acb7144 | |||
02e5ae137f |
193
Map.h
193
Map.h
@ -1,193 +0,0 @@
|
||||
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
346
Noise.h
@ -1,346 +0,0 @@
|
||||
/*
|
||||
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);
|
||||
}
|
48
README.md
48
README.md
@ -1,26 +1,46 @@
|
||||
Ultim8x8 RGB LED Panel + FastLED + ESP8266 Web Server
|
||||
FastLED + ESP8266 Web Server
|
||||
=========
|
||||
|
||||
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)
|
||||
Control an addressable LED strip with an ESP8266 via a web browser or infrared remote control.
|
||||
|
||||
Hardware
|
||||
--------
|
||||
|
||||
[ULTiM8x8 RGB LED Panel](https://www.crowdsupply.com/maniacal-labs-wyolum/ultim8x8)
|
||||
##### ESP8266 development board
|
||||
|
||||
[](https://www.crowdsupply.com/maniacal-labs-wyolum/ultim8x8)
|
||||
[](https://www.aliexpress.com/item/WEMOS-D1-mini-Pro-16M-bytes-external-antenna-connector-ESP8266-WIFI-Internet-of-Things-development-board/32724692514.html)
|
||||
|
||||
[Adafruit Feather HUZZAH with ESP8266 WiFi](https://www.adafruit.com/products/2821)
|
||||
[Wemos D1 Mini Pro & Headers](https://www.aliexpress.com/item/WEMOS-D1-mini-Pro-16M-bytes-external-antenna-connector-ESP8266-WIFI-Internet-of-Things-development-board/32724692514.html)
|
||||
|
||||
[](https://www.adafruit.com/products/2821)
|
||||
or
|
||||
|
||||
[](https://www.adafruit.com/products/2471)
|
||||
|
||||
[Adafruit HUZZAH ESP8266 Breakout](https://www.adafruit.com/products/2471)
|
||||
|
||||
##### Addressable LED strip
|
||||
|
||||
[](https://www.adafruit.com/product/1586)
|
||||
|
||||
[Adafruit NeoPixel Ring]
|
||||
|
||||
Other hardware:
|
||||
|
||||
* [3.3V to 5V Logic Level Shifter](http://www.digikey.com/product-detail/en/texas-instruments/SN74HCT245N/296-1612-5-ND/277258) (required if LEDs "glitch")
|
||||
|
||||
Recommended by [Adafruit NeoPixel "Best Practices"](https://learn.adafruit.com/adafruit-neopixel-uberguide/best-practices) to help protect LEDs from current onrush:
|
||||
* [1000µF Capacitor](http://www.digikey.com/product-detail/en/panasonic-electronic-components/ECA-1EM102/P5156-ND/245015)
|
||||
* [300 to 500 Ohm resistor](https://www.digikey.com/product-detail/en/stackpole-electronics-inc/CF14JT470R/CF14JT470RCT-ND/1830342)
|
||||
|
||||
Optional shield to make everything more tidy:
|
||||
|
||||
[](https://www.tindie.com/products/jasoncoon/wemos-d1-mini-esp8266-led-and-level-shifter-shield/)
|
||||
|
||||
[Wemos D1 Mini ESP8266 LED & Level Shifter Shield](https://www.tindie.com/products/jasoncoon/wemos-d1-mini-esp8266-led-and-level-shifter-shield)
|
||||
|
||||
Features
|
||||
--------
|
||||
* Turn the LEDs on and off
|
||||
* Turn the NeoPixel Ring on and off
|
||||
* Adjust the brightness
|
||||
* Change the display pattern
|
||||
* Adjust the color
|
||||
@ -45,12 +65,12 @@ The app is installed via the Arduino IDE which can be [downloaded here](https://
|
||||
The app depends on the following libraries. They must either be downloaded from GitHub and placed in the Arduino 'libraries' folder, or installed as [described here](https://www.arduino.cc/en/Guide/Libraries) by using the Arduino library manager.
|
||||
|
||||
* [FastLED](https://github.com/FastLED/FastLED)
|
||||
* [IRremoteESP8266](https://github.com/markszabo/IRremoteESP8266)
|
||||
* [IRremoteESP8266](https://github.com/sebastienwarin/IRremoteESP8266)
|
||||
* [Arduino WebSockets](https://github.com/Links2004/arduinoWebSockets)
|
||||
|
||||
Download the app code from GitHub using the green Clone or Download button from [the GitHub project main page](https://github.com/jasoncoon/esp8266-fastled-webserver) and click Download ZIP. Decompress the ZIP file in your Arduino sketch folder.
|
||||
|
||||
The web app needs to be uploaded to the ESP8266's SPIFFS. You can do this within the Arduino IDE after installing the [Arduino ESP8266FS tool](https://github.com/esp8266/Arduino/blob/master/doc/filesystem.md#uploading-files-to-file-system).
|
||||
The web app needs to be uploaded to the ESP8266's SPIFFS. You can do this within the Arduino IDE after installing the [Arduino ESP8266FS tool](http://esp8266.github.io/Arduino/versions/2.3.0/doc/filesystem.html#uploading-files-to-file-system).
|
||||
|
||||
With ESP8266FS installed upload the web app using `ESP8266 Sketch Data Upload` command in the Arduino Tools menu.
|
||||
|
||||
@ -75,7 +95,7 @@ The firmware implements basic [RESTful web services](https://en.wikipedia.org/wi
|
||||
Infrared Remote Control
|
||||
-----------------------
|
||||
|
||||
Control via infrared remote control is also supported, via the [ESP8266 port of the IRremote library](https://github.com/markszabo/IRremoteESP8266).
|
||||
Control via infrared remote control is also supported, via the [ESP8266 port of the IRremote library](https://github.com/sebastienwarin/IRremoteESP8266).
|
||||
|
||||
[Adafruit NeoPixel Ring]:https://www.adafruit.com/product/1586
|
||||
[Adafruit HUZZAH ESP8266 Breakout]:https://www.adafruit.com/products/2471
|
||||
|
@ -194,7 +194,7 @@ void drawTwinkles()
|
||||
|
||||
uint8_t backgroundBrightness = bg.getAverageLight();
|
||||
|
||||
for(uint16_t i = 0; i < NUM_LEDS; i++) {
|
||||
for(uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||
CRGB& pixel = leds[i];
|
||||
|
||||
PRNG16 = (uint16_t)(PRNG16 * 2053) + 1384; // next 'random' number
|
||||
|
186
WiFi.h
Normal file
186
WiFi.h
Normal file
@ -0,0 +1,186 @@
|
||||
//#include <DNSServer.h>
|
||||
|
||||
//DNSServer dnsServer;
|
||||
|
||||
//const byte DNS_PORT = 53;
|
||||
|
||||
// bool apMode = false;
|
||||
|
||||
// AP mode password
|
||||
const char WiFiAPPSK[] = "";
|
||||
|
||||
// Wi-Fi network to connect to (if not in AP mode)
|
||||
char* ssid = "";
|
||||
char* password = "";
|
||||
|
||||
#define HOSTNAME "ESP8266-" ///< Hostname. The initializeWiFi function adds the Chip ID at the end.
|
||||
|
||||
#define DEBUG_WIFI 1
|
||||
|
||||
unsigned long futureTimeout = 0;
|
||||
uint16_t connectionTimeout = 20000;
|
||||
|
||||
template <typename Generic>
|
||||
void debugPrintln(Generic text) {
|
||||
if (DEBUG_WIFI) {
|
||||
Serial.print("*WiFi: ");
|
||||
Serial.println(text);
|
||||
}
|
||||
}
|
||||
|
||||
void startAp() {
|
||||
// WiFi.disconnect();
|
||||
|
||||
// apMode = true;
|
||||
|
||||
// WiFi.mode(WIFI_AP_STA);
|
||||
// debugPrintln("SET AP STA");
|
||||
|
||||
String AP_NameString = "ESP8266-";
|
||||
AP_NameString += String(ESP.getChipId(), HEX);
|
||||
|
||||
char AP_NameChar[AP_NameString.length() + 1];
|
||||
memset(AP_NameChar, 0, AP_NameString.length() + 1);
|
||||
|
||||
for (int i = 0; i < AP_NameString.length(); i++)
|
||||
AP_NameChar[i] = AP_NameString.charAt(i);
|
||||
|
||||
debugPrintln("Starting soft AP");
|
||||
|
||||
if (WiFiAPPSK != NULL) {
|
||||
debugPrintln(WiFi.softAP(AP_NameChar, WiFiAPPSK) ? "ready" : "failed");
|
||||
} else {
|
||||
debugPrintln(WiFi.softAP(AP_NameChar) ? "ready" : "failed");
|
||||
}
|
||||
|
||||
debugPrintln("Connect to Wi-Fi access point: ");
|
||||
debugPrintln(AP_NameChar);
|
||||
|
||||
delay(500); // Without delay I've seen the IP address blank
|
||||
debugPrintln("AP IP address: ");
|
||||
debugPrintln(WiFi.softAPIP());
|
||||
|
||||
// dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
|
||||
// dnsServer.start(DNS_PORT, "*", WiFi.softAPIP());
|
||||
}
|
||||
|
||||
String getWiFiJson() {
|
||||
String hostname = String(HOSTNAME);
|
||||
hostname += String(ESP.getChipId(), HEX);
|
||||
|
||||
String json = "{";
|
||||
|
||||
json += "\"status\":\"" + String(WiFi.status()) + "\"";
|
||||
json += ",\"localIP\":\"" + WiFi.localIP().toString() + "\"";
|
||||
json += ",\"softAPIP\":\"" + WiFi.softAPIP().toString() + "\"";
|
||||
json += ",\"hostname\":\"" + hostname + "\"";
|
||||
json += ",\"ssid\":\"" + WiFi.SSID() + "\"";
|
||||
json += ",\"rssi\":\"" + String(WiFi.RSSI()) + "\"";
|
||||
|
||||
// json += ",\"networks\":[";
|
||||
// byte ssidCount = WiFi.scanNetworks();
|
||||
// for (byte i = 0; i < ssidCount; i++) {
|
||||
// if (i > 0)
|
||||
// json += ",";
|
||||
//
|
||||
// json += "{\"name\":\"" + WiFi.SSID(i) + "\",\"rssi\":\"" + String(WiFi.RSSI(i)) + "\"}";
|
||||
// }
|
||||
//
|
||||
// json += "]";
|
||||
|
||||
json += "}";
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
void initializeWiFi() {
|
||||
WiFi.mode(WIFI_AP_STA);
|
||||
|
||||
// Set Hostname.
|
||||
String hostname = String(HOSTNAME);
|
||||
hostname += String(ESP.getChipId(), HEX);
|
||||
WiFi.hostname(hostname);
|
||||
|
||||
// Print hostname.
|
||||
Serial.println("Hostname: " + hostname);
|
||||
|
||||
char hostnameChar[hostname.length() + 1];
|
||||
memset(hostnameChar, 0, hostname.length() + 1);
|
||||
|
||||
for (uint8_t i = 0; i < hostname.length(); i++)
|
||||
hostnameChar[i] = hostname.charAt(i);
|
||||
|
||||
// MDNS.begin(hostnameChar);
|
||||
|
||||
// Add service to MDNS-SD
|
||||
// MDNS.addService("http", "tcp", 80);
|
||||
|
||||
// attempt to connect; should it fail, fall back to AP mode
|
||||
// WiFi.mode(WIFI_STA);
|
||||
|
||||
String stored_ssid = WiFi.SSID();
|
||||
if (stored_ssid != NULL && stored_ssid != "") {
|
||||
debugPrintln("Connecting to stored SSID:");
|
||||
debugPrintln(stored_ssid);
|
||||
WiFi.begin();
|
||||
} else {
|
||||
debugPrintln("No stored SSID");
|
||||
}
|
||||
|
||||
startAp();
|
||||
|
||||
webServer.on("/wifi", HTTP_POST, []() {
|
||||
String ssid = webServer.arg("ssid");
|
||||
String password = webServer.arg("password");
|
||||
// String mode = webServer.arg("mode");
|
||||
|
||||
char ssidChars[50];
|
||||
ssid.toCharArray(ssidChars, 50);
|
||||
|
||||
char passwordChars[50];
|
||||
password.toCharArray(passwordChars, 50);
|
||||
|
||||
debugPrintln("Connecting to new SSID:");
|
||||
debugPrintln(ssid);
|
||||
|
||||
// dnsServer.stop();
|
||||
// WiFi.softAPdisconnect(true);
|
||||
|
||||
// apMode = false;
|
||||
// WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssidChars, passwordChars);
|
||||
// futureTimeout = millis() + connectionTimeout;
|
||||
|
||||
webServer.sendHeader("Location", "/wifi.htm");
|
||||
webServer.send(303);
|
||||
});
|
||||
|
||||
webServer.on("/wifi", HTTP_GET, []() {
|
||||
String json = getWiFiJson();
|
||||
webServer.send(200, "application/json", json);
|
||||
});
|
||||
}
|
||||
|
||||
void checkWiFi() {
|
||||
// if (WiFi.status() == WL_CONNECTED) {
|
||||
// debugPrintln("connected");
|
||||
// futureTimeout = millis() + connectionTimeout;
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// if (apMode) {
|
||||
// debugPrintln("Already running in AP mode.");
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // time to give up on the stored network and switch to ap mode?
|
||||
// if (futureTimeout != 0 && millis() < futureTimeout) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// debugPrintln("Switching to AP mode, timeout elapsed: ");
|
||||
// debugPrintln(connectionTimeout);
|
||||
//
|
||||
// startApMode();
|
||||
}
|
||||
|
BIN
data/images/github.ico
Normal file
BIN
data/images/github.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.4 KiB |
@ -8,12 +8,12 @@
|
||||
<title>ESP8266 + FastLED by Evil Genius Labs</title>
|
||||
|
||||
<!-- request CSS from internet CDN -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-minicolors/2.2.4/jquery.minicolors.min.css" integrity="sha256-4wnSkPYU5B4yngAlx/rEb8LdfMah4teUth4AfhGEuaY=" crossorigin="anonymous" />
|
||||
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> -->
|
||||
<!-- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-minicolors/2.2.4/jquery.minicolors.min.css" integrity="sha256-4wnSkPYU5B4yngAlx/rEb8LdfMah4teUth4AfhGEuaY=" crossorigin="anonymous" /> -->
|
||||
|
||||
<!-- request CSS from the ESP8266 web server -->
|
||||
<!-- <link rel="stylesheet" href="css/bootstrap.min.css"> -->
|
||||
<!-- <link rel="stylesheet" href="css/jquery.minicolors.min.css"> -->
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="css/minicolors.min.css">
|
||||
|
||||
<link rel="stylesheet" href="css/styles.css">
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://www.evilgeniuslabs.org" target="_blank"><img src="https://evilgeniuslabs.org/images/atom.svg" style="width: 24px; height: 24px;" /></a>
|
||||
<a class="navbar-brand" href="https://www.evilgeniuslabs.org" target="_blank"><img src="/images/atom196.png" style="width: 24px; height: 24px;" /></a>
|
||||
<a class="navbar-brand" href="https://www.evilgeniuslabs.org" target="_blank">Evil Genius Labs</a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
||||
@ -40,11 +40,12 @@
|
||||
<li><a href="/simple.htm" target="_blank" title="Simple Mode">Simple</a></li>
|
||||
<li><a href="/edit.htm" target="_blank" title="Edit Files">Files</a></li>
|
||||
<li><a href="/update" target="_blank" title="Update Firmware">Firmware</a></li>
|
||||
<li><a href="/wifi.htm" target="_blank" title="Wi-Fi Settings">Wi-Fi</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/jasoncoon/esp8266-fastled-webserver">
|
||||
<img style="height: 16px;" src="https://assets-cdn.github.com/favicon.ico" />
|
||||
<img style="height: 16px;" src="/images/github.ico" />
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@ -215,16 +216,16 @@
|
||||
</nav>
|
||||
|
||||
<!-- request js from internet CDN -->
|
||||
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-minicolors/2.2.4/jquery.minicolors.min.js" integrity="sha256-XAFQ9dZ6hy8p/GRhU8h/8pMvM1etymiJLZW1CiHV3bQ=" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js" integrity="sha256-A4JwlcDvqO4JXpvEtvWY1RH8JAEMu5W21wP8GUXLUNs=" crossorigin="anonymous"></script>
|
||||
<!-- <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script> -->
|
||||
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> -->
|
||||
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-minicolors/2.2.4/jquery.minicolors.min.js" integrity="sha256-XAFQ9dZ6hy8p/GRhU8h/8pMvM1etymiJLZW1CiHV3bQ=" crossorigin="anonymous"></script> -->
|
||||
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js" integrity="sha256-A4JwlcDvqO4JXpvEtvWY1RH8JAEMu5W21wP8GUXLUNs=" crossorigin="anonymous"></script> -->
|
||||
|
||||
<!-- request js from the ESP8266 web server -->
|
||||
<!-- <script src="js/jquery-3.1.1.min.js"></script> -->
|
||||
<!-- <script src="js/bootstrap.min.js"></script> -->
|
||||
<!-- <script src="js/jquery.minicolors.min.js"></script> -->
|
||||
<!-- <script src="js/r-websocket.min.js"></script> -->
|
||||
<script src="js/jquery-3.1.1.min.js"></script>
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
<script src="js/minicolors.min.js"></script>
|
||||
<script src="js/r-websocket.min.js"></script>
|
||||
|
||||
<script src="js/app.js"></script>
|
||||
|
||||
|
@ -8,10 +8,10 @@
|
||||
<title>ESP8266 + FastLED by Evil Genius Labs</title>
|
||||
|
||||
<!-- request CSS from internet CDN -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
|
||||
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> -->
|
||||
|
||||
<!-- request CSS from the ESP8266 web server -->
|
||||
<!-- <link rel="stylesheet" href="css/bootstrap.min.css"> -->
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
|
||||
<link rel="stylesheet" href="css/simple.css">
|
||||
|
||||
@ -42,14 +42,14 @@
|
||||
</div>
|
||||
|
||||
<!-- request js from internet CDN -->
|
||||
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
|
||||
<script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js" integrity="sha256-A4JwlcDvqO4JXpvEtvWY1RH8JAEMu5W21wP8GUXLUNs=" crossorigin="anonymous"></script>
|
||||
<!-- <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script> -->
|
||||
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> -->
|
||||
<!-- <script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script> -->
|
||||
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js" integrity="sha256-A4JwlcDvqO4JXpvEtvWY1RH8JAEMu5W21wP8GUXLUNs=" crossorigin="anonymous"></script> -->
|
||||
|
||||
<!-- request js from the ESP8266 web server -->
|
||||
<!-- <script src="js/jquery-3.1.1.min.js"></script> -->
|
||||
<!-- <script src="js/bootstrap.min.js"></script> -->
|
||||
<script src="js/jquery-3.1.1.min.js"></script>
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
|
||||
<script src="js/simple.js"></script>
|
||||
|
||||
|
95
data/wifi.htm
Normal file
95
data/wifi.htm
Normal file
@ -0,0 +1,95 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>ESP8266 + FastLED by Evil Genius Labs</title>
|
||||
|
||||
<!-- request CSS from internet CDN -->
|
||||
<!-- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> -->
|
||||
|
||||
<!-- request CSS from the ESP8266 web server -->
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
|
||||
<link rel="stylesheet" href="css/styles.css">
|
||||
|
||||
<link rel="icon" href="images/atom196.png">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-default navbar-static-top" id="top" role="banner">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse-1" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="https://www.evilgeniuslabs.org" target="_blank"><img src="/images/atom196.png" style="width: 24px; height: 24px;" /></a>
|
||||
<a class="navbar-brand" href="https://www.evilgeniuslabs.org" target="_blank">Evil Genius Labs</a>
|
||||
</div>
|
||||
<div class="collapse navbar-collapse" id="navbar-collapse-1">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="/">ESP8266 + FastLED <span class="sr-only">(current)</span></a></li>
|
||||
<li><a href="/simple.htm" target="_blank" title="Simple Mode">Simple</a></li>
|
||||
<li><a href="/edit.htm" target="_blank" title="Edit Files">Files</a></li>
|
||||
<li><a href="/update" target="_blank" title="Update Firmware">Firmware</a></li>
|
||||
<li class="active"><a href="/wifi.htm" target="_blank" title="Wi-Fi Settings">Wi-Fi</a></li>
|
||||
</ul>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li>
|
||||
<a href="https://github.com/jasoncoon/esp8266-fastled-webserver">
|
||||
<img style="height: 16px;" src="/images/github.ico" />
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div id="container" class="container">
|
||||
|
||||
<form class="form-horizontal" id="form" action="/wifi" method="post">
|
||||
|
||||
<div class="form-group">
|
||||
<label for="inputSSID" class="col-sm-2 control-label">SSID</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" autocorrect="off" autocapitalize="none"
|
||||
class="form-control" id="inputSSID" name="ssid" placeholder="SSID (Wi-Fi network name)">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="inputPassword" class="col-sm-2 control-label">Password</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="password" class="form-control" id="inputPassword" name="password" placeholder="Password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-2 col-sm-10">
|
||||
<button type="submit" class="btn btn-default">Connect</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- request js from internet CDN -->
|
||||
<!-- <script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script> -->
|
||||
<!-- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> -->
|
||||
<!-- <script src="https://unpkg.com/isotope-layout@3/dist/isotope.pkgd.min.js"></script> -->
|
||||
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js" integrity="sha256-A4JwlcDvqO4JXpvEtvWY1RH8JAEMu5W21wP8GUXLUNs=" crossorigin="anonymous"></script> -->
|
||||
|
||||
<!-- request js from the ESP8266 web server -->
|
||||
<script src="js/jquery-3.1.1.min.js"></script>
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,19 +1,19 @@
|
||||
/*
|
||||
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/>.
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include <FastLED.h>
|
||||
@ -37,37 +37,23 @@ extern "C" {
|
||||
|
||||
#include "Field.h"
|
||||
|
||||
#define HOSTNAME "ESP8266-Feather-" ///< Hostname. The setup function adds the Chip ID at the end.
|
||||
|
||||
//#define RECV_PIN D4
|
||||
//IRrecv irReceiver(RECV_PIN);
|
||||
|
||||
//#include "Commands.h"
|
||||
|
||||
const bool apMode = false;
|
||||
|
||||
// AP mode password
|
||||
const char WiFiAPPSK[] = "";
|
||||
|
||||
// Wi-Fi network to connect to (if not in AP mode)
|
||||
const char* ssid = "";
|
||||
const char* password = "";
|
||||
|
||||
ESP8266WebServer webServer(80);
|
||||
WebSocketsServer webSocketsServer = WebSocketsServer(81);
|
||||
ESP8266HTTPUpdateServer httpUpdateServer;
|
||||
|
||||
#include "WiFi.h"
|
||||
|
||||
#include "FSBrowser.h"
|
||||
|
||||
#define DATA_PIN 13
|
||||
#define CLK_PIN 14
|
||||
#define LED_TYPE APA102
|
||||
#define COLOR_ORDER BGR
|
||||
#define MatrixWidth 24
|
||||
#define MatrixHeight 8
|
||||
#define NUM_LEDS MatrixWidth * MatrixHeight
|
||||
|
||||
const bool MatrixSerpentineLayout = true;
|
||||
#define DATA_PIN D8
|
||||
#define LED_TYPE WS2811
|
||||
#define COLOR_ORDER GRB
|
||||
#define NUM_LEDS 24
|
||||
|
||||
#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.
|
||||
@ -120,28 +106,6 @@ uint8_t gHue = 0; // rotating "base color" used by many of the patterns
|
||||
|
||||
CRGB solidColor = CRGB::Blue;
|
||||
|
||||
uint16_t XY( uint8_t x, uint8_t y)
|
||||
{
|
||||
uint16_t i;
|
||||
|
||||
if ( MatrixSerpentineLayout == false) {
|
||||
i = (y * MatrixWidth) + x;
|
||||
}
|
||||
|
||||
if ( MatrixSerpentineLayout == true) {
|
||||
if ( x & 0x01) {
|
||||
// Odd columns run backwards
|
||||
uint8_t reverseY = (MatrixHeight - 1) - y;
|
||||
i = (x * MatrixHeight) + reverseY;
|
||||
} else {
|
||||
// Even rows run forwards
|
||||
i = (x * MatrixHeight) + y;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
// scale the brightness of all pixels down
|
||||
void dimAll(byte value)
|
||||
{
|
||||
@ -150,36 +114,6 @@ void dimAll(byte 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 Pattern PatternList[];
|
||||
typedef struct {
|
||||
@ -190,72 +124,12 @@ typedef PatternAndName PatternAndNameList[];
|
||||
|
||||
#include "Twinkles.h"
|
||||
#include "TwinkleFOX.h"
|
||||
#include "Map.h"
|
||||
#include "Noise.h"
|
||||
|
||||
// List of patterns to cycle through. Each is defined as a separate function below.
|
||||
|
||||
PatternAndNameList patterns = {
|
||||
{ pride, "Pride" },
|
||||
{ pride2, "Pride 2" },
|
||||
{ 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
|
||||
{ rainbowTwinkles, "Rainbow Twinkles" },
|
||||
@ -294,6 +168,36 @@ PatternAndNameList 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"
|
||||
|
||||
void setup() {
|
||||
@ -301,9 +205,9 @@ void setup() {
|
||||
delay(100);
|
||||
Serial.setDebugOutput(true);
|
||||
|
||||
//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.setDither(true);
|
||||
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.setDither(false);
|
||||
FastLED.setCorrection(TypicalLEDStrip);
|
||||
FastLED.setBrightness(brightness);
|
||||
FastLED.setMaxPowerInVoltsAndMilliamps(5, MILLI_AMPS);
|
||||
@ -339,57 +243,9 @@ void setup() {
|
||||
Serial.printf("\n");
|
||||
}
|
||||
|
||||
// Set Hostname.
|
||||
String hostname(HOSTNAME);
|
||||
hostname += String(ESP.getChipId(), HEX);
|
||||
WiFi.hostname(hostname);
|
||||
initializeWiFi();
|
||||
|
||||
char hostnameChar[hostname.length() + 1];
|
||||
memset(hostnameChar, 0, hostname.length() + 1);
|
||||
|
||||
for (uint8_t i = 0; i < hostname.length(); i++)
|
||||
hostnameChar[i] = hostname.charAt(i);
|
||||
|
||||
// MDNS.begin(hostnameChar);
|
||||
|
||||
// Add service to MDNS-SD
|
||||
// MDNS.addService("http", "tcp", 80);
|
||||
|
||||
// Print hostname.
|
||||
Serial.println("Hostname: " + hostname);
|
||||
|
||||
if (apMode)
|
||||
{
|
||||
WiFi.mode(WIFI_AP);
|
||||
|
||||
// Do a little work to get a unique-ish name. Append the
|
||||
// last two bytes of the MAC (HEX'd) to "Thing-":
|
||||
uint8_t mac[WL_MAC_ADDR_LENGTH];
|
||||
WiFi.softAPmacAddress(mac);
|
||||
String macID = String(mac[WL_MAC_ADDR_LENGTH - 2], HEX) +
|
||||
String(mac[WL_MAC_ADDR_LENGTH - 1], HEX);
|
||||
macID.toUpperCase();
|
||||
String AP_NameString = "ESP8266-" + macID;
|
||||
|
||||
char AP_NameChar[AP_NameString.length() + 1];
|
||||
memset(AP_NameChar, 0, AP_NameString.length() + 1);
|
||||
|
||||
for (int i = 0; i < AP_NameString.length(); i++)
|
||||
AP_NameChar[i] = AP_NameString.charAt(i);
|
||||
|
||||
WiFi.softAP(AP_NameChar, WiFiAPPSK);
|
||||
|
||||
Serial.printf("Connect to Wi-Fi access point: %s\n", AP_NameChar);
|
||||
Serial.println("and open http://192.168.4.1 in your browser");
|
||||
}
|
||||
else
|
||||
{
|
||||
WiFi.mode(WIFI_STA);
|
||||
Serial.printf("Connecting to %s\n", ssid);
|
||||
if (String(WiFi.SSID()) != String(ssid)) {
|
||||
WiFi.begin(ssid, password);
|
||||
}
|
||||
}
|
||||
checkWiFi();
|
||||
|
||||
httpUpdateServer.setup(&webServer);
|
||||
|
||||
@ -433,7 +289,7 @@ void setup() {
|
||||
|
||||
webServer.on("/speed", HTTP_POST, []() {
|
||||
String value = webServer.arg("value");
|
||||
setSpeed(value.toInt());
|
||||
speed = value.toInt();
|
||||
broadcastInt("speed", speed);
|
||||
sendInt(speed);
|
||||
});
|
||||
@ -560,6 +416,11 @@ void loop() {
|
||||
// Add entropy to random number generator; we use a lot of it.
|
||||
random16_add_entropy(random(65535));
|
||||
|
||||
EVERY_N_SECONDS(10) {
|
||||
checkWiFi();
|
||||
}
|
||||
|
||||
// dnsServer.processNextRequest();
|
||||
webSocketsServer.loop();
|
||||
webServer.handleClient();
|
||||
|
||||
@ -599,7 +460,7 @@ void loop() {
|
||||
FastLED.show();
|
||||
|
||||
// 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) {
|
||||
@ -878,8 +739,6 @@ void loadSettings()
|
||||
currentPaletteIndex = 0;
|
||||
else if (currentPaletteIndex >= paletteCount)
|
||||
currentPaletteIndex = paletteCount - 1;
|
||||
|
||||
speed = EEPROM.read(9);
|
||||
}
|
||||
|
||||
void setPower(uint8_t value)
|
||||
@ -1003,16 +862,6 @@ void setPaletteName(String name)
|
||||
}
|
||||
}
|
||||
|
||||
void setSpeed(uint8_t value)
|
||||
{
|
||||
speed = value;
|
||||
|
||||
EEPROM.write(9, value);
|
||||
EEPROM.commit();
|
||||
|
||||
broadcastInt("speed", speed);
|
||||
}
|
||||
|
||||
void adjustBrightness(bool up)
|
||||
{
|
||||
if (up && brightnessIndex < brightnessCount - 1)
|
||||
@ -1075,97 +924,6 @@ void rainbow()
|
||||
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()
|
||||
{
|
||||
// built-in FastLED rainbow, plus some random sparkly glitter
|
||||
@ -1300,46 +1058,6 @@ 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()
|
||||
{
|
||||
for (uint8_t i = 0; i < NUM_LEDS; i++) {
|
||||
@ -1479,56 +1197,6 @@ 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
|
||||
// across the defined LED strip.
|
||||
void palettetest( CRGB* ledarray, uint16_t numleds, const CRGBPalette16& gCurrentPalette)
|
||||
|
Reference in New Issue
Block a user