3 Commits

Author SHA1 Message Date
9025d0ed10 Updated for 8x8x8 tinytim cube. 2017-09-05 07:59:24 -05:00
3a3bb2043c Added support for 6 panel tinytim cube. 2017-06-11 11:04:59 -05:00
02e5ae137f Improved instructions. 2017-05-06 11:33:25 -05:00
9 changed files with 218 additions and 662 deletions

134
Map.h
View File

@ -1,125 +1,11 @@
uint8_t cubeWidth = 8; uint8_t coordsX[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, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 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, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 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, 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() { void cubeXGradientPalette() {
uint8_t hues = 8; uint8_t hues = 8;
for (uint8_t i = 0; i < NUM_LEDS; i++) { for (uint16_t i = 0; i < NUM_LEDS; i++) {
uint8_t x = coordsX[i]; uint8_t x = coordsX[i];
leds[i] = ColorFromPalette(gCurrentPalette, beat8(speed) - (x * hues)); leds[i] = ColorFromPalette(gCurrentPalette, beat8(speed) - (x * hues));
@ -129,7 +15,7 @@ void cubeXGradientPalette() {
void cubeYGradientPalette() { void cubeYGradientPalette() {
uint8_t hues = 8; uint8_t hues = 8;
for (uint8_t i = 0; i < NUM_LEDS; i++) { for (uint16_t i = 0; i < NUM_LEDS; i++) {
uint8_t y = coordsY[i]; uint8_t y = coordsY[i];
leds[i] = ColorFromPalette(gCurrentPalette, beat8(speed) - (y * hues)); leds[i] = ColorFromPalette(gCurrentPalette, beat8(speed) - (y * hues));
@ -139,7 +25,7 @@ void cubeYGradientPalette() {
void cubeZGradientPalette() { void cubeZGradientPalette() {
uint8_t hues = 8; uint8_t hues = 8;
for (uint8_t i = 0; i < NUM_LEDS; i++) { for (uint16_t i = 0; i < NUM_LEDS; i++) {
uint8_t z = coordsZ[i]; uint8_t z = coordsZ[i];
leds[i] = ColorFromPalette(gCurrentPalette, beat8(speed) - (z * hues)); leds[i] = ColorFromPalette(gCurrentPalette, beat8(speed) - (z * hues));
@ -149,7 +35,7 @@ void cubeZGradientPalette() {
void cubeXYGradientPalette() { void cubeXYGradientPalette() {
uint8_t hues = 8; uint8_t hues = 8;
for (uint8_t i = 0; i < NUM_LEDS; i++) { for (uint16_t i = 0; i < NUM_LEDS; i++) {
uint8_t x = coordsX[i]; uint8_t x = coordsX[i];
uint8_t y = coordsY[i]; uint8_t y = coordsY[i];
@ -160,7 +46,7 @@ void cubeXYGradientPalette() {
void cubeXZGradientPalette() { void cubeXZGradientPalette() {
uint8_t hues = 8; uint8_t hues = 8;
for (uint8_t i = 0; i < NUM_LEDS; i++) { for (uint16_t i = 0; i < NUM_LEDS; i++) {
uint8_t x = coordsX[i]; uint8_t x = coordsX[i];
uint8_t z = coordsZ[i]; uint8_t z = coordsZ[i];
@ -171,7 +57,7 @@ void cubeXZGradientPalette() {
void cubeYZGradientPalette() { void cubeYZGradientPalette() {
uint8_t hues = 8; uint8_t hues = 8;
for (uint8_t i = 0; i < NUM_LEDS; i++) { for (uint16_t i = 0; i < NUM_LEDS; i++) {
uint8_t y = coordsY[i]; uint8_t y = coordsY[i];
uint8_t z = coordsZ[i]; uint8_t z = coordsZ[i];
@ -182,7 +68,7 @@ void cubeYZGradientPalette() {
void cubeXYZGradientPalette() { void cubeXYZGradientPalette() {
uint8_t hues = 8; uint8_t hues = 8;
for (uint8_t i = 0; i < NUM_LEDS; i++) { for (uint16_t i = 0; i < NUM_LEDS; i++) {
uint8_t x = coordsX[i]; uint8_t x = coordsX[i];
uint8_t y = coordsY[i]; uint8_t y = coordsY[i];
uint8_t z = coordsZ[i]; uint8_t z = coordsZ[i];

160
Noise.h
View File

@ -16,8 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. 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 // The 16 bit version of our coordinates
uint16_t noisex; uint16_t noisex;
uint16_t noisey; uint16_t noisey;
@ -27,9 +25,9 @@ uint16_t noisez;
// use the z-axis for "time". speed determines how fast time moves forward. Try // 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 // 1 for a very slow moving effect, or 60 for something that ends up looking like
// water. // water.
int noisespeedx = 0; int8_t noisespeedx = 0;
int noisespeedy = 1; int8_t noisespeedy = 1;
int noisespeedz = 0; int8_t noisespeedz = 0;
// Scale determines how far apart the pixels in our noise matrix are. Try // 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 // changing these values around to see how it affects the motion of the display. The
@ -37,9 +35,6 @@ int noisespeedz = 0;
// of 1 will be so zoomed in, you'll mostly see solid colors. // 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 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; uint8_t colorLoop = 0;
CRGBPalette16 blackAndWhiteStripedPalette; CRGBPalette16 blackAndWhiteStripedPalette;
@ -84,38 +79,9 @@ void SetupBlackAndBlueStripedPalette()
// Additionally, you can manually define your own color palettes, or you can write // Additionally, you can manually define your own color palettes, or you can write
// code that creates color palettes on the fly. // 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) void drawNoise3d(CRGBPalette16 palette, uint8_t hueReduce = 0)
{ {
for(uint8_t i = 0; i < NUM_LEDS; i++) { for(uint16_t i = 0; i < NUM_LEDS; i++) {
uint8_t x = coordsX[i]; uint8_t x = coordsX[i];
uint8_t y = coordsY[i]; uint8_t y = coordsY[i];
uint8_t z = coordsZ[i]; uint8_t z = coordsZ[i];
@ -143,15 +109,6 @@ void drawNoise3d(CRGBPalette16 palette, uint8_t hueReduce = 0)
noisez += noisespeedz; noisez += noisespeedz;
} }
void rainbowNoise() {
noisespeedx = 0;
noisespeedy = -1;
noisespeedz = 0;
noisescale = 24;
colorLoop = 0;
drawNoise(RainbowColors_p);
}
void rainbowNoise3d() { void rainbowNoise3d() {
noisespeedx = 0; noisespeedx = 0;
noisespeedy = 0; noisespeedy = 0;
@ -161,15 +118,6 @@ void rainbowNoise3d() {
drawNoise3d(RainbowColors_p); drawNoise3d(RainbowColors_p);
} }
void rainbowStripeNoise() {
noisespeedx = 0;
noisespeedy = -2;
noisespeedz = 0;
noisescale = 24;
colorLoop = 0;
drawNoise(RainbowStripeColors_p);
}
void rainbowStripeNoise3d() { void rainbowStripeNoise3d() {
noisespeedx = 0; noisespeedx = 0;
noisespeedy = 0; noisespeedy = 0;
@ -179,15 +127,6 @@ void rainbowStripeNoise3d() {
drawNoise3d(RainbowStripeColors_p); drawNoise3d(RainbowStripeColors_p);
} }
void partyNoise() {
noisespeedx = -9;
noisespeedy = 0;
noisespeedz = 0;
noisescale = 32;
colorLoop = 0;
drawNoise(PartyColors_p);
}
void partyNoise3d() { void partyNoise3d() {
noisespeedx = -9; noisespeedx = -9;
noisespeedy = 0; noisespeedy = 0;
@ -197,15 +136,6 @@ void partyNoise3d() {
drawNoise3d(PartyColors_p); drawNoise3d(PartyColors_p);
} }
void forestNoise() {
noisespeedx = -9;
noisespeedy = 0;
noisespeedz = 0;
noisescale = 32;
colorLoop = 0;
drawNoise(ForestColors_p);
}
void forestNoise3d() { void forestNoise3d() {
noisespeedx = -9; noisespeedx = -9;
noisespeedy = 0; noisespeedy = 0;
@ -215,15 +145,6 @@ void forestNoise3d() {
drawNoise3d(ForestColors_p); drawNoise3d(ForestColors_p);
} }
void cloudNoise() {
noisespeedx = -2;
noisespeedy = 0;
noisespeedz = 0;
noisescale = 24;
colorLoop = 0;
drawNoise(CloudColors_p);
}
void cloudNoise3d() { void cloudNoise3d() {
noisespeedx = -2; noisespeedx = -2;
noisespeedy = 0; noisespeedy = 0;
@ -233,69 +154,33 @@ void cloudNoise3d() {
drawNoise3d(CloudColors_p); drawNoise3d(CloudColors_p);
} }
void fireNoise() {
noisespeedx = 0; // 24;
noisespeedy = -32;
noisespeedz = 0;
noisescale = 64;
colorLoop = 0;
drawNoise(HeatColors_p, 60);
}
void fireNoise3d() { void fireNoise3d() {
noisespeedx = 0; noisespeedx = 16;
noisespeedy = 0; noisespeedy = 16;
noisespeedz = 32; noisespeedz = 16;
noisescale = 64; noisescale = 64;
colorLoop = 0; colorLoop = 0;
drawNoise3d(HeatColors_p, 60); drawNoise3d(HeatColors_p, 60);
} }
void fireNoise2() {
noisespeedx = 0;
noisespeedy = -8;
noisespeedz = 3;
noisescale = 32;
colorLoop = 0;
drawNoise(HeatColors_p);
}
void fireNoise23d() { void fireNoise23d() {
noisespeedx = 1; noisespeedx = 3;
noisespeedy = 3; noisespeedy = 3;
noisespeedz = 8; noisespeedz = 3;
noisescale = 32; noisescale = 32;
colorLoop = 0; colorLoop = 0;
drawNoise3d(HeatColors_p); drawNoise3d(HeatColors_p);
} }
void lavaNoise() {
noisespeedx = 0;
noisespeedy = -1;
noisespeedz = 1;
noisescale = 24;
colorLoop = 0;
drawNoise(LavaColors_p);
}
void lavaNoise3d() { void lavaNoise3d() {
noisespeedx = 1; noisespeedx = -4;
noisespeedy = 3; noisespeedy = -4;
noisespeedz = -8; noisespeedz = -4;
noisescale = 32; noisescale = 32;
colorLoop = 0; colorLoop = 0;
drawNoise3d(LavaColors_p); drawNoise3d(LavaColors_p);
} }
void oceanNoise() {
noisespeedx = -2;
noisespeedy = 0;
noisespeedz = 4;
noisescale = 24;
colorLoop = 0;
drawNoise(OceanColors_p);
}
void oceanNoise3d() { void oceanNoise3d() {
noisespeedx = -2; noisespeedx = -2;
noisespeedy = 0; noisespeedy = 0;
@ -305,16 +190,6 @@ void oceanNoise3d() {
drawNoise3d(OceanColors_p); drawNoise3d(OceanColors_p);
} }
void blackAndWhiteNoise() {
SetupBlackAndWhiteStripedPalette();
noisespeedx = -12;
noisespeedy = 0;
noisespeedz = 0;
noisescale = 24;
colorLoop = 0;
drawNoise(blackAndWhiteStripedPalette);
}
void blackAndWhiteNoise3d() { void blackAndWhiteNoise3d() {
SetupBlackAndWhiteStripedPalette(); SetupBlackAndWhiteStripedPalette();
noisespeedx = -12; noisespeedx = -12;
@ -325,16 +200,6 @@ void blackAndWhiteNoise3d() {
drawNoise3d(blackAndWhiteStripedPalette); drawNoise3d(blackAndWhiteStripedPalette);
} }
void blackAndBlueNoise() {
SetupBlackAndBlueStripedPalette();
noisespeedx = 0;
noisespeedy = 8;
noisespeedz = 0;
noisescale = 32;
colorLoop = 0;
drawNoise(blackAndBlueStripedPalette);
}
void blackAndBlueNoise3d() { void blackAndBlueNoise3d() {
SetupBlackAndBlueStripedPalette(); SetupBlackAndBlueStripedPalette();
noisespeedx = -4; noisespeedx = -4;
@ -344,3 +209,4 @@ void blackAndBlueNoise3d() {
colorLoop = 0; colorLoop = 0;
drawNoise3d(blackAndBlueStripedPalette); drawNoise3d(blackAndBlueStripedPalette);
} }

View File

@ -1,26 +1,22 @@
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. Control an addressable LED strip with an ESP8266 via a web browser or infrared remote control.
[Demo Video](https://www.youtube.com/watch?v=xigy7J_K7Aw):
[![Demo Video](http://img.youtube.com/vi/xigy7J_K7Aw/0.jpg)](http://www.youtube.com/watch?v=xigy7J_K7Aw)
Hardware Hardware
-------- --------
[ULTiM8x8 RGB LED Panel](https://www.crowdsupply.com/maniacal-labs-wyolum/ultim8x8) An ESP8266 development board, such as the [Adafruit HUZZAH ESP8266 Breakout]:
[![ULTiM8x8 RGB LED Panel](https://www.crowdsupply.com/img/7d3e/ultim8x8-bothboards_jpg_project-body.jpg)](https://www.crowdsupply.com/maniacal-labs-wyolum/ultim8x8) [![Adafruit HUZZAH ESP8266 Breakout](https://cdn-shop.adafruit.com/310x233/2471-10.jpg)](https://www.adafruit.com/products/2471)
[Adafruit Feather HUZZAH with ESP8266 WiFi](https://www.adafruit.com/products/2821) Addressable LED strip, such as the [Adafruit NeoPixel Ring]:
[![Adafruit Feather HUZZAH with ESP8266 WiFi](https://cdn-shop.adafruit.com/310x233/2821-01.jpg)](https://www.adafruit.com/products/2821) [![Adafruit NeoPixel Ring](https://www.adafruit.com/images/145x109/1586-00.jpg)](https://www.adafruit.com/product/1586)
Features Features
-------- --------
* Turn the LEDs on and off * Turn the NeoPixel Ring on and off
* Adjust the brightness * Adjust the brightness
* Change the display pattern * Change the display pattern
* Adjust the color * Adjust the color

View File

@ -2,10 +2,20 @@
padding-bottom: 70px; padding-bottom: 70px;
}*/ }*/
.grid-item-color-button {
border: 0px;
width: 7.69%;
height: 64px;
margin: 0px;
padding: 0px;
}
.grid-item-color { .grid-item-color {
width: 4%; border: none;
width: 3.33%;
height: 32px; height: 32px;
cursor: pointer; margin: 0px;
padding: 0px;
} }
.grid-item-pattern { .grid-item-pattern {

View File

@ -5,7 +5,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>ESP8266 + FastLED by Evil Genius Labs</title> <title>Cube by Evil Genius Labs</title>
<!-- request CSS from internet CDN --> <!-- 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">
@ -36,7 +36,7 @@
</div> </div>
<div class="collapse navbar-collapse" id="navbar-collapse-1"> <div class="collapse navbar-collapse" id="navbar-collapse-1">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li class="active"><a href="/">ESP8266 + FastLED <span class="sr-only">(current)</span></a></li> <li class="active"><a href="/">Cube <span class="sr-only">(current)</span></a></li>
<li><a href="/simple.htm" target="_blank" title="Simple Mode">Simple</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="/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="/update" target="_blank" title="Update Firmware">Firmware</a></li>

View File

@ -3,7 +3,7 @@ var address = location.hostname;
var urlBase = ""; var urlBase = "";
// used when hosting the site somewhere other than the ESP8266 (handy for testing without waiting forever to upload to SPIFFS) // used when hosting the site somewhere other than the ESP8266 (handy for testing without waiting forever to upload to SPIFFS)
// var address = "esp8266-1920f7.local"; // var address = "192.168.86.55";
// var urlBase = "http://" + address + "/"; // var urlBase = "http://" + address + "/";
var postColorTimer = {}; var postColorTimer = {};

View File

@ -3,7 +3,7 @@ var address = location.hostname;
var urlBase = ""; var urlBase = "";
// used when hosting the site somewhere other than the ESP8266 (handy for testing without waiting forever to upload to SPIFFS) // used when hosting the site somewhere other than the ESP8266 (handy for testing without waiting forever to upload to SPIFFS)
// var address = "192.168.1.13"; // var address = "192.168.86.55";
// var urlBase = "http://" + address + "/"; // var urlBase = "http://" + address + "/";
var postColorTimer = {}; var postColorTimer = {};
@ -15,6 +15,27 @@ var patterns = [
"Pride", "Pride",
"Color Waves", "Color Waves",
"X Gradient Palette",
"Y Gradient Palette",
"Z Gradient Palette",
"XY Gradient Palette",
"XZ Gradient Palette",
"YZ Gradient Palette",
"XYZ Gradient Palette",
"Fire Noise",
"Fire Noise 2",
"Lava Noise",
"Rainbow Noise",
"Rainbow Stripe Noise",
"Party Noise",
"Forest Noise",
"Cloud Noise",
"Ocean Noise",
"Black & White Noise",
"Black & Blue Noise",
"Rainbow Twinkles", "Rainbow Twinkles",
"Snow Twinkles", "Snow Twinkles",
"Cloud Twinkles", "Cloud Twinkles",
@ -35,15 +56,11 @@ var patterns = [
"Cloud 2 Twinkles", "Cloud 2 Twinkles",
"Ocean Twinkles", "Ocean Twinkles",
"Rainbow",
"Rainbow With Glitter",
"Solid Rainbow", "Solid Rainbow",
"Confetti", "Confetti",
"Sinelon", "Sinelon",
"Beat", "Beat",
"Juggle", "Juggle",
"Fire",
"Water"
]; ];
var ws = new ReconnectingWebSocket('ws://' + address + ':81/', ['arduino']); var ws = new ReconnectingWebSocket('ws://' + address + ':81/', ['arduino']);
@ -114,13 +131,13 @@ $(document).ready(function() {
}); });
function addColorButtons() { function addColorButtons() {
var hues = 25; var hues = 30;
var hueStep = 360 / hues; var hueStep = 360 / hues;
var levels = 10; var levels = 25;
var levelStep = 60 / levels; var levelStep = 50 / levels;
for(var l = 20; l < 80; l += levelStep) { for(var l = 50; l < 95; l += levelStep) {
for(var h = 0; h < hues; h++) { for(var h = 0; h < hues; h++) {
addColorButton(h * hueStep, 100, l); addColorButton(h * hueStep, 100, l);
} }
@ -131,24 +148,35 @@ function addColorButtons() {
layoutMode: 'fitRows' layoutMode: 'fitRows'
}); });
$('.grid-color-buttons').isotope({
itemSelector: '.grid-item-color-button',
layoutMode: 'fitRows'
});
$('.grid-item-color-button').click(colorButtonClick);
} }
var colorButtonIndex = 0; var colorButtonIndex = 0;
function addColorButton(h, s, l) { function colorButtonClick() {
var color = "hsla(" + h + ", " + s + "%, " + l + "%, 1)"
var template = $("#colorButtonTemplate").clone();
template.attr("id", "color-button-" + colorButtonIndex++);
template.css("background-color", color);
template.click(function() {
var rgb = $(this).css('backgroundColor'); var rgb = $(this).css('backgroundColor');
var components = rgbToComponents(rgb); var components = rgbToComponents(rgb);
$(".grid-item-color").css("border", "none"); $(".grid-item-color").css("border", "none");
if($(this).attr("class") === "grid-item-color") {
$(this).css("border", "1px solid"); $(this).css("border", "1px solid");
}
postColor("solidColor", components); postColor("solidColor", components);
}); }
function addColorButton(h, s, l) {
var color = "hsl(" + h + ", " + s + "%, " + l + "%)"
var template = $("#colorButtonTemplate").clone();
template.css("background-color", color);
template.attr("title", template.css("background-color") + "\r\n" + color);
template.click(colorButtonClick);
$("#colorButtonsRow").append(template); $("#colorButtonsRow").append(template);
} }

View File

@ -5,7 +5,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>ESP8266 + FastLED by Evil Genius Labs</title> <title>Cube by Evil Genius Labs</title>
<!-- request CSS from internet CDN --> <!-- 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">
@ -20,22 +20,44 @@
<body> <body>
<div id="container" class="container"> <div id="container" class="container-fluid">
<div style="margin: 5px;"> <div style="margin: 5px;">
<button type="button" class="btn btn-default" id="btnOn">On</button> <button type="button" class="btn btn-default" id="btnOn">On</button>
<button type="button" class="btn btn-default" id="btnOff">Off</button> <button type="button" class="btn btn-default" id="btnOff">Off</button>
</div> </div>
<h4>Patterns</h4>
<div id="patternGrid" class="grid-pattern"></div> <div id="patternGrid" class="grid-pattern"></div>
<h4>Basic Colors</h4>
<div class="grid-color-buttons">
<button type="button" class="grid-item-color-button" style="background: #FF0000;" title="Red">&nbsp;</button>
<button type="button" class="grid-item-color-button" style="background: #FF8000;" title="Orange">&nbsp;</button>
<button type="button" class="grid-item-color-button" style="background: #FFFF00;" title="Yellow">&nbsp;</button>
<button type="button" class="grid-item-color-button" style="background: #80FF00;" title="Chartreuse">&nbsp;</button>
<button type="button" class="grid-item-color-button" style="background: #00FF00;" title="Green">&nbsp;</button>
<button type="button" class="grid-item-color-button" style="background: #00FF80;" title="Spring Green">&nbsp;</button>
<button type="button" class="grid-item-color-button" style="background: #00FFFF;" title="Cyan">&nbsp;</button>
<button type="button" class="grid-item-color-button" style="background: #0080FF;" title="Azure">&nbsp;</button>
<button type="button" class="grid-item-color-button" style="background: #0000FF;" title="Blue">&nbsp;</button>
<button type="button" class="grid-item-color-button" style="background: #8000FF;" title="Violet">&nbsp;</button>
<button type="button" class="grid-item-color-button" style="background: #FF00FF;" title="Magenta">&nbsp;</button>
<button type="button" class="grid-item-color-button" style="background: #FF0080;" title="Rose">&nbsp;</button>
<button type="button" class="grid-item-color-button" style="background: #FFFFFF; border: 1px solid;" title="White">&nbsp;</button>
</div>
<h4>Color Palette</h4>
<div id="colorButtonsRow" class="grid-color"></div> <div id="colorButtonsRow" class="grid-color"></div>
</div> </div>
<div id="templates" style="display: none"> <div id="templates" style="display: none">
<div id="colorButtonTemplate" class="grid-item-color"></div> <button id="colorButtonTemplate" class="grid-item-color"></button>
<button id="patternButtonTemplate" class="grid-item-pattern btn btn-default"></button> <button id="patternButtonTemplate" class="grid-item-pattern btn btn-default"></button>

View File

@ -16,6 +16,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
//#define FASTLED_ALLOW_INTERRUPTS 0
#define FASTLED_INTERRUPT_RETRY_COUNT 0
#include <FastLED.h> #include <FastLED.h>
FASTLED_USING_NAMESPACE FASTLED_USING_NAMESPACE
@ -24,7 +26,7 @@ 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>
@ -37,7 +39,7 @@ extern "C" {
#include "Field.h" #include "Field.h"
#define HOSTNAME "ESP8266-Feather-" ///< Hostname. The setup function adds the Chip ID at the end. #define HOSTNAME "Cube-ESP8266-" ///< Hostname. The setup function adds the Chip ID at the end.
//#define RECV_PIN D4 //#define RECV_PIN D4
//IRrecv irReceiver(RECV_PIN); //IRrecv irReceiver(RECV_PIN);
@ -59,15 +61,10 @@ ESP8266HTTPUpdateServer httpUpdateServer;
#include "FSBrowser.h" #include "FSBrowser.h"
#define DATA_PIN 13 #define DATA_PIN D5
#define CLK_PIN 14 #define LED_TYPE WS2812B
#define LED_TYPE APA102 #define COLOR_ORDER GRB
#define COLOR_ORDER BGR #define NUM_LEDS 8 * 8 * 6
#define MatrixWidth 24
#define MatrixHeight 8
#define NUM_LEDS MatrixWidth * MatrixHeight
const bool MatrixSerpentineLayout = true;
#define MILLI_AMPS 2000 // IMPORTANT: set the max milli-Amps of your power supply (4A = 4000mA) #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.
@ -120,28 +117,6 @@ uint8_t gHue = 0; // rotating "base color" used by many of the patterns
CRGB solidColor = CRGB::Blue; 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 // scale the brightness of all pixels down
void dimAll(byte value) void dimAll(byte value)
{ {
@ -150,6 +125,84 @@ void dimAll(byte value)
} }
} }
typedef void (*Pattern)();
typedef Pattern PatternList[];
typedef struct {
Pattern pattern;
String name;
} PatternAndName;
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" },
{ colorWaves, "Color Waves" },
{ cubeXGradientPalette, "X Gradient Palette" },
{ cubeYGradientPalette, "Y Gradient Palette" },
{ cubeZGradientPalette, "Z Gradient Palette" },
{ cubeXYGradientPalette, "XY Gradient Palette" },
{ cubeXZGradientPalette, "XZ Gradient Palette" },
{ cubeYZGradientPalette, "YZ Gradient Palette" },
{ cubeXYZGradientPalette, "XYZ Gradient Palette" },
// 3d noise patterns
{ fireNoise3d, "Fire Noise" },
{ fireNoise23d, "Fire Noise 2" },
{ lavaNoise3d, "Lava Noise" },
{ rainbowNoise3d, "Rainbow Noise" },
{ rainbowStripeNoise3d, "Rainbow Stripe Noise" },
{ partyNoise3d, "Party Noise" },
{ forestNoise3d, "Forest Noise" },
{ cloudNoise3d, "Cloud Noise" },
{ oceanNoise3d, "Ocean Noise" },
{ blackAndWhiteNoise3d, "Black & White Noise" },
{ blackAndBlueNoise3d, "Black & Blue Noise" },
// twinkle patterns
{ rainbowTwinkles, "Rainbow Twinkles" },
{ snowTwinkles, "Snow Twinkles" },
{ cloudTwinkles, "Cloud Twinkles" },
{ incandescentTwinkles, "Incandescent Twinkles" },
// TwinkleFOX patterns
{ retroC9Twinkles, "Retro C9 Twinkles" },
{ redWhiteTwinkles, "Red & White Twinkles" },
{ blueWhiteTwinkles, "Blue & White Twinkles" },
{ redGreenWhiteTwinkles, "Red, Green & White Twinkles" },
{ fairyLightTwinkles, "Fairy Light Twinkles" },
{ snow2Twinkles, "Snow 2 Twinkles" },
{ hollyTwinkles, "Holly Twinkles" },
{ iceTwinkles, "Ice Twinkles" },
{ partyTwinkles, "Party Twinkles" },
{ forestTwinkles, "Forest Twinkles" },
{ lavaTwinkles, "Lava Twinkles" },
{ fireTwinkles, "Fire Twinkles" },
{ cloud2Twinkles, "Cloud 2 Twinkles" },
{ oceanTwinkles, "Ocean Twinkles" },
// { rainbow, "Rainbow" },
// { rainbowWithGlitter, "Rainbow With Glitter" },
{ rainbowSolid, "Solid Rainbow" },
{ confetti, "Confetti" },
{ sinelon, "Sinelon" },
{ bpm, "Beat" },
{ juggle, "Juggle" },
// { fire, "Fire" },
// { water, "Water" },
{ showSolidColor, "Solid Color" }
};
const uint8_t patternCount = ARRAY_SIZE(patterns);
typedef struct { typedef struct {
CRGBPalette16 palette; CRGBPalette16 palette;
String name; String name;
@ -180,130 +233,18 @@ const String paletteNames[paletteCount] = {
"Heat", "Heat",
}; };
typedef void (*Pattern)();
typedef Pattern PatternList[];
typedef struct {
Pattern pattern;
String name;
} PatternAndName;
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" },
{ snowTwinkles, "Snow Twinkles" },
{ cloudTwinkles, "Cloud Twinkles" },
{ incandescentTwinkles, "Incandescent Twinkles" },
// TwinkleFOX patterns
{ retroC9Twinkles, "Retro C9 Twinkles" },
{ redWhiteTwinkles, "Red & White Twinkles" },
{ blueWhiteTwinkles, "Blue & White Twinkles" },
{ redGreenWhiteTwinkles, "Red, Green & White Twinkles" },
{ fairyLightTwinkles, "Fairy Light Twinkles" },
{ snow2Twinkles, "Snow 2 Twinkles" },
{ hollyTwinkles, "Holly Twinkles" },
{ iceTwinkles, "Ice Twinkles" },
{ partyTwinkles, "Party Twinkles" },
{ forestTwinkles, "Forest Twinkles" },
{ lavaTwinkles, "Lava Twinkles" },
{ fireTwinkles, "Fire Twinkles" },
{ cloud2Twinkles, "Cloud 2 Twinkles" },
{ oceanTwinkles, "Ocean Twinkles" },
{ rainbow, "Rainbow" },
{ rainbowWithGlitter, "Rainbow With Glitter" },
{ rainbowSolid, "Solid Rainbow" },
{ confetti, "Confetti" },
{ sinelon, "Sinelon" },
{ bpm, "Beat" },
{ juggle, "Juggle" },
{ fire, "Fire" },
{ water, "Water" },
{ showSolidColor, "Solid Color" }
};
const uint8_t patternCount = ARRAY_SIZE(patterns);
#include "Fields.h" #include "Fields.h"
void setup() { void setup() {
WiFi.setSleepMode(WIFI_NONE_SLEEP);
Serial.begin(115200); Serial.begin(115200);
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(true); FastLED.setDither(false);
FastLED.setCorrection(TypicalLEDStrip); FastLED.setCorrection(TypicalLEDStrip);
FastLED.setBrightness(brightness); FastLED.setBrightness(brightness);
FastLED.setMaxPowerInVoltsAndMilliamps(5, MILLI_AMPS); FastLED.setMaxPowerInVoltsAndMilliamps(5, MILLI_AMPS);
@ -350,10 +291,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);
@ -433,7 +374,7 @@ void setup() {
webServer.on("/speed", HTTP_POST, []() { webServer.on("/speed", HTTP_POST, []() {
String value = webServer.arg("value"); String value = webServer.arg("value");
setSpeed(value.toInt()); speed = value.toInt();
broadcastInt("speed", speed); broadcastInt("speed", speed);
sendInt(speed); sendInt(speed);
}); });
@ -599,7 +540,7 @@ void loop() {
FastLED.show(); FastLED.show();
// 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) {
@ -878,8 +819,6 @@ 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)
@ -1003,16 +942,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) void adjustBrightness(bool up)
{ {
if (up && brightnessIndex < brightnessCount - 1) if (up && brightnessIndex < brightnessCount - 1)
@ -1075,97 +1004,6 @@ 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
@ -1300,46 +1138,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() void radialPaletteShift()
{ {
for (uint8_t i = 0; i < NUM_LEDS; i++) { for (uint8_t i = 0; i < NUM_LEDS; i++) {
@ -1357,7 +1155,7 @@ void heatMap(CRGBPalette16 palette, bool up)
random16_add_entropy(random(256)); random16_add_entropy(random(256));
// Array of temperature readings at each simulation cell // Array of temperature readings at each simulation cell
static byte heat[256]; static byte heat[NUM_LEDS];
byte colorindex; byte colorindex;
@ -1479,56 +1277,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 // 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)