Added Pacifica effect (closes #790)

This commit is contained in:
cschwinne 2020-03-25 11:17:45 +01:00
parent ed729c32d2
commit 07d6bfa989
6 changed files with 132 additions and 6 deletions

View File

@ -2,6 +2,12 @@
### Development versions after 0.9.1 release ### Development versions after 0.9.1 release
#### Build 2003251
- Added Pacifica effect (tentative, doesn't yet support other colors)
- Added Atlantica palette
- Fixed ESP32 build of Espalexa
#### Build 2003222 #### Build 2003222
- Fixed Alexa Whites on non-RGBW lights (bump Espalexa to 2.4.5) - Fixed Alexa Whites on non-RGBW lights (bump Espalexa to 2.4.5)

View File

@ -3094,6 +3094,7 @@ uint16_t WS2812FX::mode_plasma(void) {
return FRAMETIME; return FRAMETIME;
} }
/* /*
* Percentage display * Percentage display
* Intesity values from 0-100 turn on the leds. * Intesity values from 0-100 turn on the leds.
@ -3167,3 +3168,108 @@ uint16_t WS2812FX::mode_heartbeat(void) {
return FRAMETIME; return FRAMETIME;
} }
// "Pacifica"
// Gentle, blue-green ocean waves.
// December 2019, Mark Kriegsman and Mary Corey March.
// For Dan.
//
//
// In this animation, there are four "layers" of waves of light.
//
// Each layer moves independently, and each is scaled separately.
//
// All four wave layers are added together on top of each other, and then
// another filter is applied that adds "whitecaps" of brightness where the
// waves line up with each other more. Finally, another pass is taken
// over the led array to 'deepen' (dim) the blues and greens.
//
// The speed and scale and motion each layer varies slowly within independent
// hand-chosen ranges, which is why the code has a lot of low-speed 'beatsin8' functions
// with a lot of oddly specific numeric ranges.
//
// These three custom blue-green color palettes were inspired by the colors found in
// the waters off the southern coast of California, https://goo.gl/maps/QQgd97jjHesHZVxQ7
//
// Modified for WLED, based on https://github.com/FastLED/FastLED/blob/master/examples/Pacifica/Pacifica.ino
//
uint16_t WS2812FX::mode_pacifica()
{
CRGBPalette16 pacifica_palette_1 =
{ 0x000507, 0x000409, 0x00030B, 0x00030D, 0x000210, 0x000212, 0x000114, 0x000117,
0x000019, 0x00001C, 0x000026, 0x000031, 0x00003B, 0x000046, 0x14554B, 0x28AA50 };
CRGBPalette16 pacifica_palette_2 =
{ 0x000507, 0x000409, 0x00030B, 0x00030D, 0x000210, 0x000212, 0x000114, 0x000117,
0x000019, 0x00001C, 0x000026, 0x000031, 0x00003B, 0x000046, 0x0C5F52, 0x19BE5F };
CRGBPalette16 pacifica_palette_3 =
{ 0x000208, 0x00030E, 0x000514, 0x00061A, 0x000820, 0x000927, 0x000B2D, 0x000C33,
0x000E39, 0x001040, 0x001450, 0x001860, 0x001C70, 0x002080, 0x1040BF, 0x2060FF };
// Increment the four "color index start" counters, one for each wave layer.
// Each is incremented at a different speed, and the speeds vary over time.
uint16_t sCIStart1 = SEGENV.aux0, sCIStart2 = SEGENV.aux1, sCIStart3 = SEGENV.step, sCIStart4 = SEGENV.step >> 16;
//static uint16_t sCIStart1, sCIStart2, sCIStart3, sCIStart4;
uint32_t deltams = 26 + (SEGMENT.speed >> 3);
uint16_t speedfactor1 = beatsin16(3, 179, 269);
uint16_t speedfactor2 = beatsin16(4, 179, 269);
uint32_t deltams1 = (deltams * speedfactor1) / 256;
uint32_t deltams2 = (deltams * speedfactor2) / 256;
uint32_t deltams21 = (deltams1 + deltams2) / 2;
sCIStart1 += (deltams1 * beatsin88(1011,10,13));
sCIStart2 -= (deltams21 * beatsin88(777,8,11));
sCIStart3 -= (deltams1 * beatsin88(501,5,7));
sCIStart4 -= (deltams2 * beatsin88(257,4,6));
SEGENV.aux0 = sCIStart1; SEGENV.aux1 = sCIStart2;
SEGENV.step = sCIStart4; SEGENV.step = (SEGENV.step << 16) + sCIStart3;
// Clear out the LED array to a dim background blue-green
//fill(132618);
uint8_t basethreshold = beatsin8( 9, 55, 65);
uint8_t wave = beat8( 7 );
for( uint16_t i = 0; i < SEGLEN; i++) {
CRGB c = CRGB(2, 6, 10);
// Render each of four layers, with different scales and speeds, that vary over time
c += pacifica_one_layer(i, pacifica_palette_1, sCIStart1, beatsin16(3, 11 * 256, 14 * 256), beatsin8(10, 70, 130), 0-beat16(301));
c += pacifica_one_layer(i, pacifica_palette_2, sCIStart2, beatsin16(4, 6 * 256, 9 * 256), beatsin8(17, 40, 80), beat16(401));
c += pacifica_one_layer(i, pacifica_palette_3, sCIStart3, 6 * 256 , beatsin8(9, 10,38) , 0-beat16(503));
c += pacifica_one_layer(i, pacifica_palette_3, sCIStart4, 5 * 256 , beatsin8(8, 10,28) , beat16(601));
// Add extra 'white' to areas where the four layers of light have lined up brightly
uint8_t threshold = scale8( sin8( wave), 20) + basethreshold;
wave += 7;
uint8_t l = c.getAverageLight();
if (l > threshold) {
uint8_t overage = l - threshold;
uint8_t overage2 = qadd8(overage, overage);
c += CRGB(overage, overage2, qadd8(overage2, overage2));
}
//deepen the blues and greens
c.blue = scale8(c.blue, 145);
c.green = scale8(c.green, 200);
c |= CRGB( 2, 5, 7);
setPixelColor(i, c.red, c.green, c.blue);
}
return FRAMETIME;
}
// Add one layer of waves into the led array
CRGB WS2812FX::pacifica_one_layer(uint16_t i, CRGBPalette16& p, uint16_t cistart, uint16_t wavescale, uint8_t bri, uint16_t ioff)
{
uint16_t ci = cistart;
uint16_t waveangle = ioff;
uint16_t wavescale_half = (wavescale >> 1) + 20;
waveangle += ((120 + SEGMENT.intensity) * i); //original 250 * i
uint16_t s16 = sin16(waveangle) + 32768;
uint16_t cs = scale16(s16, wavescale_half) + wavescale_half;
ci += (cs * i);
uint16_t sindex16 = sin16(ci) + 32768;
uint8_t sindex8 = scale16(sindex16, 240);
return ColorFromPalette(p, sindex8, bri, LINEARBLEND);
}

View File

@ -95,7 +95,7 @@
#define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE ) #define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE )
#define IS_SELECTED ((SEGMENT.options & SELECTED) == SELECTED ) #define IS_SELECTED ((SEGMENT.options & SELECTED) == SELECTED )
#define MODE_COUNT 101 #define MODE_COUNT 102
#define FX_MODE_STATIC 0 #define FX_MODE_STATIC 0
#define FX_MODE_BLINK 1 #define FX_MODE_BLINK 1
@ -198,6 +198,7 @@
#define FX_MODE_PERCENT 98 #define FX_MODE_PERCENT 98
#define FX_MODE_RIPPLE_RAINBOW 99 #define FX_MODE_RIPPLE_RAINBOW 99
#define FX_MODE_HEARTBEAT 100 #define FX_MODE_HEARTBEAT 100
#define FX_MODE_PACIFICA 101
class WS2812FX { class WS2812FX {
typedef uint16_t (WS2812FX::*mode_ptr)(void); typedef uint16_t (WS2812FX::*mode_ptr)(void);
@ -387,6 +388,7 @@ class WS2812FX {
_mode[FX_MODE_PERCENT] = &WS2812FX::mode_percent; _mode[FX_MODE_PERCENT] = &WS2812FX::mode_percent;
_mode[FX_MODE_RIPPLE_RAINBOW] = &WS2812FX::mode_ripple_rainbow; _mode[FX_MODE_RIPPLE_RAINBOW] = &WS2812FX::mode_ripple_rainbow;
_mode[FX_MODE_HEARTBEAT] = &WS2812FX::mode_heartbeat; _mode[FX_MODE_HEARTBEAT] = &WS2812FX::mode_heartbeat;
_mode[FX_MODE_PACIFICA] = &WS2812FX::mode_pacifica;
_brightness = DEFAULT_BRIGHTNESS; _brightness = DEFAULT_BRIGHTNESS;
currentPalette = CRGBPalette16(CRGB::Black); currentPalette = CRGBPalette16(CRGB::Black);
@ -571,7 +573,8 @@ class WS2812FX {
mode_plasma(void), mode_plasma(void),
mode_percent(void), mode_percent(void),
mode_ripple_rainbow(void), mode_ripple_rainbow(void),
mode_heartbeat(void); mode_heartbeat(void),
mode_pacifica(void);
private: private:
@ -621,6 +624,7 @@ class WS2812FX {
spots_base(uint16_t); spots_base(uint16_t);
CRGB twinklefox_one_twinkle(uint32_t ms, uint8_t salt, bool cat); CRGB twinklefox_one_twinkle(uint32_t ms, uint8_t salt, bool cat);
CRGB pacifica_one_layer(uint16_t i, CRGBPalette16& p, uint16_t cistart, uint16_t wavescale, uint8_t bri, uint16_t ioff);
uint32_t _lastPaletteChange = 0; uint32_t _lastPaletteChange = 0;
uint32_t _lastShow = 0; uint32_t _lastShow = 0;
@ -656,7 +660,7 @@ const char JSON_mode_names[] PROGMEM = R"=====([
"Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Meteor Smooth","Railway","Ripple", "Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Meteor Smooth","Railway","Ripple",
"Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern","Solid Pattern Tri","Spots","Spots Fade","Glitter","Candle","Fireworks Starburst", "Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern","Solid Pattern Tri","Spots","Spots Fade","Glitter","Candle","Fireworks Starburst",
"Fireworks 1D","Bouncing Balls","Sinelon","Sinelon Dual","Sinelon Rainbow","Popcorn","Drip","Plasma","Percent","Ripple Rainbow", "Fireworks 1D","Bouncing Balls","Sinelon","Sinelon Dual","Sinelon Rainbow","Popcorn","Drip","Plasma","Percent","Ripple Rainbow",
"Heartbeat" "Heartbeat","Pacifica"
])====="; ])=====";
@ -666,7 +670,7 @@ const char JSON_palette_names[] PROGMEM = R"=====([
"Pastel","Sunset 2","Beech","Vintage","Departure","Landscape","Beach","Sherbet","Hult","Hult 64", "Pastel","Sunset 2","Beech","Vintage","Departure","Landscape","Beach","Sherbet","Hult","Hult 64",
"Drywet","Jul","Grintage","Rewhi","Tertiary","Fire","Icefire","Cyane","Light Pink","Autumn", "Drywet","Jul","Grintage","Rewhi","Tertiary","Fire","Icefire","Cyane","Light Pink","Autumn",
"Magenta","Magred","Yelmag","Yelblu","Orange & Teal","Tiamat","April Night","Orangery","C9","Sakura", "Magenta","Magred","Yelmag","Yelblu","Orange & Teal","Tiamat","April Night","Orangery","C9","Sakura",
"Aurora" "Aurora","Atlantica"
])====="; ])=====";
#endif #endif

View File

@ -13,7 +13,7 @@
#ifndef PalettesWLED_h #ifndef PalettesWLED_h
#define PalettesWLED_h #define PalettesWLED_h
#define GRADIENT_PALETTE_COUNT 38 #define GRADIENT_PALETTE_COUNT 39
const byte ib_jul01_gp[] PROGMEM = { const byte ib_jul01_gp[] PROGMEM = {
0, 194, 1, 1, 0, 194, 1, 1,
@ -574,6 +574,14 @@ const byte Aurora_gp[] PROGMEM = {
170, 0,243, 45, 170, 0,243, 45,
200, 0,135, 7, 200, 0,135, 7,
255, 1, 5, 45};//deep blue 255, 1, 5, 45};//deep blue
const byte Atlantica_gp[] PROGMEM = {
0, 0, 28,112, //#001C70
50, 32, 96,255, //#2060FF
100, 0,243, 45,
150, 12, 95, 82, //#0C5F52
200, 25,190, 95, //#19BE5F
255, 40,170, 80};//#28AA50
// Single array of defined cpt-city color palettes. // Single array of defined cpt-city color palettes.
@ -619,6 +627,7 @@ const byte* const gGradientPalettes[] PROGMEM = {
C9_gp, //48-35 C9 C9_gp, //48-35 C9
Sakura_gp, //49-36 Sakura Sakura_gp, //49-36 Sakura
Aurora_gp, //50-37 Aurora Aurora_gp, //50-37 Aurora
Atlantica_gp, //51-38 Atlantica
}; };
#endif #endif

View File

@ -2,6 +2,7 @@
#define EspalexaDevice_h #define EspalexaDevice_h
#include "Arduino.h" #include "Arduino.h"
#include <functional>
typedef class EspalexaDevice; typedef class EspalexaDevice;

View File

@ -118,7 +118,7 @@
#endif #endif
//version code in format yymmddb (b = daily build) //version code in format yymmddb (b = daily build)
#define VERSION 2003222 #define VERSION 2003251
char versionString[] = "0.9.1"; char versionString[] = "0.9.1";