Added Pride2012 and Colorwaves effects

Adjusted Noise16 effects
Added palette fade transition option
This commit is contained in:
cschwinne 2018-09-08 16:21:44 +02:00
parent 6d4339b034
commit ce5fec4d5f
12 changed files with 520 additions and 213 deletions

View File

@ -1667,6 +1667,11 @@ uint16_t WS2812FX::mode_circus_combustus(void) {
*/
uint16_t WS2812FX::mode_icu(void) {
uint16_t dest = SEGMENT_RUNTIME.counter_mode_step & 0xFFFF;
for (uint16_t i = SEGMENT.start; i <= SEGMENT.stop; i++)
{
setPixelColor(i, SEGMENT.colors[1]);
}
setPixelColor(SEGMENT.start + dest, SEGMENT.colors[0]);
setPixelColor(SEGMENT.start + dest + SEGMENT_LENGTH/2, SEGMENT.colors[0]);
@ -1973,12 +1978,62 @@ uint16_t WS2812FX::mode_fire_2012(void)
}
// Pride2015
// Animated, ever-changing rainbows.
// by Mark Kriegsman: https://gist.github.com/kriegsman/964de772d64c502760e5
uint16_t WS2812FX::mode_pride_2015(void)
{
uint16_t duration = 10 + SEGMENT.speed;
uint16_t sPseudotime = SEGMENT_RUNTIME.counter_mode_step;
uint16_t sHue16 = SEGMENT_RUNTIME.aux_param;
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);
sPseudotime += duration * msmultiplier;
sHue16 += duration * beatsin88( 400, 5,9);
uint16_t brightnesstheta16 = sPseudotime;
CRGB fastled_col;
for( uint16_t i = SEGMENT.start ; i <= SEGMENT.stop; i++) {
hue16 += hueinc16;
uint8_t hue8 = hue16 >> 8;
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);
uint32_t color = getPixelColor(i);
fastled_col.red = (color >> 16 & 0xFF);
fastled_col.green = (color >> 8 & 0xFF);
fastled_col.blue = (color & 0xFF);
nblend( fastled_col, newcolor, 64);
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
}
SEGMENT_RUNTIME.counter_mode_step = sPseudotime;
SEGMENT_RUNTIME.aux_param = sHue16;
return 20;
}
// eight colored dots, weaving in and out of sync with each other
uint16_t WS2812FX::mode_juggle(void){
fade_out((255-SEGMENT.intensity) / 32);
CRGB fastled_col;
byte dothue = 0;
for ( byte i = 0; i < 8; i++) {
uint16_t index = SEGMENT.start + beatsin16(i + 7, 0, SEGMENT_LENGTH);
uint16_t index = SEGMENT.start + beatsin16(i + 7, 0, SEGMENT_LENGTH -1);
uint32_t color = getPixelColor(index);
fastled_col.red = (color >> 16 & 0xFF);
fastled_col.green = (color >> 8 & 0xFF);
@ -1990,6 +2045,7 @@ uint16_t WS2812FX::mode_juggle(void){
return 10 + (uint16_t)(255 - SEGMENT.speed)/4;
}
/*
* FastLED palette modes helper function. Limitation: Due to memory reasons, multiple active segments with FastLED will disable the Palette transitions
*/
@ -2081,7 +2137,7 @@ void WS2812FX::handle_palette(void)
targetPalette = PartyColors_p; break;
}
if (singleSegmentMode) //only blend if just one segment uses FastLED mode
if (singleSegmentMode && paletteFade) //only blend if just one segment uses FastLED mode
{
nblendPaletteTowardPalette(currentPalette, targetPalette, 42);
} else
@ -2107,6 +2163,66 @@ uint16_t WS2812FX::mode_palette(void)
}
// ColorWavesWithPalettes by Mark Kriegsman: https://gist.github.com/kriegsman/8281905786e8b2632aeb
// This function draws color waves with an ever-changing,
// widely-varying set of parameters, using a color palette.
uint16_t WS2812FX::mode_colorwaves(void)
{
handle_palette();
uint16_t duration = 10 + SEGMENT.speed;
uint16_t sPseudotime = SEGMENT_RUNTIME.counter_mode_step;
uint16_t sHue16 = SEGMENT_RUNTIME.aux_param;
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);
sPseudotime += duration * msmultiplier;
sHue16 += duration * beatsin88( 400, 5, 9);
uint16_t brightnesstheta16 = sPseudotime;
CRGB fastled_col;
for ( uint16_t i = SEGMENT.start ; i <= SEGMENT.stop; i++) {
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(currentPalette, index, bri8);
uint32_t color = getPixelColor(i);
fastled_col.red = (color >> 16 & 0xFF);
fastled_col.green = (color >> 8 & 0xFF);
fastled_col.blue = (color & 0xFF);
nblend(fastled_col, newcolor, 128);
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
}
SEGMENT_RUNTIME.counter_mode_step = sPseudotime;
SEGMENT_RUNTIME.aux_param = sHue16;
return 20;
}
// colored stripes pulsing at a defined Beats-Per-Minute (BPM)
uint16_t WS2812FX::mode_bpm(void)
{
handle_palette();
@ -2137,23 +2253,22 @@ uint16_t WS2812FX::mode_fillnoise8(void)
return 20;
}
uint16_t WS2812FX::mode_noise16_1(void)
{
uint16_t scale = 750; // the "zoom factor" for the noise
uint16_t scale = 320; // the "zoom factor" for the noise
handle_palette();
CRGB fastled_col;
SEGMENT_RUNTIME.counter_mode_step += (1 + SEGMENT.speed/16);
for (int i = SEGMENT.start; i <= SEGMENT.stop; i++) {
uint16_t shift_x = beatsin8(5); // the x position of the noise field swings @ 17 bpm
uint16_t shift_y = SEGMENT_RUNTIME.counter_mode_step/50; // the y position becomes slowly incremented
uint16_t shift_x = beatsin8(11); // the x position of the noise field swings @ 17 bpm
uint16_t shift_y = SEGMENT_RUNTIME.counter_mode_step/42; // the y position becomes slowly incremented
uint16_t real_x = (i + shift_x) * scale; // the x position of the noise field swings @ 17 bpm
uint16_t real_y = (i + shift_y) * scale; // the y position becomes slowly incremented
uint32_t real_z = SEGMENT_RUNTIME.counter_mode_step*2; // the z position becomes quickly incremented
uint32_t real_z = SEGMENT_RUNTIME.counter_mode_step; // the z position becomes quickly incremented
uint8_t noise = inoise16(real_x, real_y, real_z) >> 8; // get the noise data and scale it down
@ -2169,21 +2284,21 @@ uint16_t WS2812FX::mode_noise16_1(void)
uint16_t WS2812FX::mode_noise16_2(void)
{
uint8_t scale = 750; // the "zoom factor" for the noise
uint16_t scale = 1000; // the "zoom factor" for the noise
handle_palette();
CRGB fastled_col;
SEGMENT_RUNTIME.counter_mode_step += (1 + SEGMENT.speed);
for (int i = SEGMENT.start; i <= SEGMENT.stop; i++) {
uint16_t shift_x = SEGMENT_RUNTIME.counter_mode_step/64; // x as a function of time
uint16_t shift_y = 0;
uint16_t shift_x = SEGMENT_RUNTIME.counter_mode_step >> 6; // x as a function of time
uint16_t shift_y = SEGMENT_RUNTIME.counter_mode_step/42;
uint32_t real_x = (i + shift_x) * scale; // calculate the coordinates within the noise field
uint32_t real_y = (i + shift_y) * scale; // based on the precalculated positions
uint32_t real_z = 4223;
uint8_t noise = inoise16(real_x, real_y, real_z) >> 8; // get the noise data and scale it down
uint8_t noise = inoise16(real_x, 0, 4223) >> 8; // get the noise data and scale it down
uint8_t index = sin8(noise * 3); // map led color based on noise data
@ -2197,7 +2312,7 @@ uint16_t WS2812FX::mode_noise16_2(void)
uint16_t WS2812FX::mode_noise16_3(void)
{
uint8_t scale = 750; // the "zoom factor" for the noise
uint16_t scale = 800; // the "zoom factor" for the noise
handle_palette();
CRGB fastled_col;
SEGMENT_RUNTIME.counter_mode_step += (1 + SEGMENT.speed);
@ -2209,9 +2324,9 @@ uint16_t WS2812FX::mode_noise16_3(void)
uint32_t real_x = (i + shift_x) * scale; // calculate the coordinates within the noise field
uint32_t real_y = (i + shift_y) * scale; // based on the precalculated positions
uint32_t real_z = SEGMENT_RUNTIME.counter_mode_step/16;
uint32_t real_z = SEGMENT_RUNTIME.counter_mode_step*8;
uint8_t noise = inoise16(real_x, real_y, real_z) >> 7; // get the noise data and scale it down
uint8_t noise = inoise16(real_x, real_y, real_z) >> 8; // get the noise data and scale it down
uint8_t index = sin8(noise * 3); // map led color based on noise data

View File

@ -82,7 +82,7 @@
#define REVERSE (uint8_t)0x80
#define IS_REVERSE ((SEGMENT.options & REVERSE) == REVERSE)
#define MODE_COUNT 72
#define MODE_COUNT 74
#define FX_MODE_STATIC 0
#define FX_MODE_BLINK 1
@ -147,15 +147,18 @@
#define FX_MODE_DUAL_LARSON_SCANNER 60
#define FX_MODE_RANDOM_CHASE 61
#define FX_MODE_OSCILLATE 62
//Modes that use FastLED -->
#define FX_MODE_FIRE_2012 63
#define FX_MODE_JUGGLE 64
#define FX_MODE_PALETTE 65
#define FX_MODE_BPM 66
#define FX_MODE_FILLNOISE8 67
#define FX_MODE_NOISE16_1 68
#define FX_MODE_NOISE16_2 69
#define FX_MODE_NOISE16_3 70
#define FX_MODE_NOISE16_4 71
#define FX_MODE_PRIDE_2015 64
#define FX_MODE_JUGGLE 65
#define FX_MODE_PALETTE 66
#define FX_MODE_COLORWAVES 67
#define FX_MODE_BPM 68
#define FX_MODE_FILLNOISE8 69
#define FX_MODE_NOISE16_1 70
#define FX_MODE_NOISE16_2 71
#define FX_MODE_NOISE16_3 72
#define FX_MODE_NOISE16_4 73
class WS2812FX {
typedef uint16_t (WS2812FX::*mode_ptr)(void);
@ -248,9 +251,11 @@ class WS2812FX {
_mode[FX_MODE_RANDOM_CHASE] = &WS2812FX::mode_random_chase;
_mode[FX_MODE_OSCILLATE] = &WS2812FX::mode_oscillate;
_mode[FX_MODE_FIRE_2012] = &WS2812FX::mode_fire_2012;
_mode[FX_MODE_PRIDE_2015] = &WS2812FX::mode_pride_2015;
_mode[FX_MODE_BPM] = &WS2812FX::mode_bpm;
_mode[FX_MODE_JUGGLE] = &WS2812FX::mode_juggle;
_mode[FX_MODE_PALETTE] = &WS2812FX::mode_palette;
_mode[FX_MODE_COLORWAVES] = &WS2812FX::mode_colorwaves;
_mode[FX_MODE_FILLNOISE8] = &WS2812FX::mode_fillnoise8;
_mode[FX_MODE_NOISE16_1] = &WS2812FX::mode_noise16_1;
_mode[FX_MODE_NOISE16_2] = &WS2812FX::mode_noise16_2;
@ -326,6 +331,8 @@ class WS2812FX {
getPowerEstimate(uint16_t leds, uint32_t c, byte b),
getSafePowerMultiplier(double safeMilliAmps, uint16_t leds, uint32_t c, byte b);
bool paletteFade;
WS2812FX::Segment
getSegment(void);
@ -413,9 +420,11 @@ class WS2812FX {
mode_random_chase(void),
mode_oscillate(void),
mode_fire_2012(void),
mode_pride_2015(void),
mode_bpm(void),
mode_juggle(void),
mode_palette(void),
mode_colorwaves(void),
mode_fillnoise8(void),
mode_noise16_1(void),
mode_noise16_2(void),

View File

@ -171,8 +171,8 @@
case 3: gId("path1").style.fill = aC; gId("path2").style.fill = aC;
}
tgb.style.fill=(Cf.SA.value>0)?aC:dC;
fpX.style.display=(Cf.TX.selectedIndex>64)?"block":"none";
fof.style.fill=(Cf.TX.selectedIndex>64)?aC:dC;
fpX.style.display=(Cf.TX.selectedIndex>65)?"block":"none";
fof.style.fill=(Cf.TX.selectedIndex>65)?aC:dC;
fmr.style.fill=(Cf.TX.selectedIndex<1)?aC:dC;
}
function TgT()
@ -191,10 +191,10 @@
function SwFX(s)
{
var n=Cf.TX.selectedIndex+s;
if (n==-1||n==72) return;
if (n==-1||n==74) return;
Cf.TX.selectedIndex =n;
if (n < 0) Cf.TX.selectedIndex = 0;
if (n > 71) Cf.TX.selectedIndex = 65;
if (n > 73) Cf.TX.selectedIndex = 66;
GX();
}
function TgHSB()
@ -649,14 +649,16 @@
<option value="61">Random Chase (61)</option>
<option value="62">Oscillate (62)</option>
<option value="63">Fire 2012 (63)</option>
<option value="64">Juggle (64)</option>
<option value="65">Palette (65)</option>
<option value="66">BPM (66)</option>
<option value="67">Fill Noise 8 (67)</option>
<option value="68">Noise 16 1 (68)</option>
<option value="69">Noise 16 2 (69)</option>
<option value="70">Noise 16 3 (70)</option>
<option value="71">Noise 16 4 (71)</option>
<option value="64">Pride 2015 (64)</option>
<option value="65">Juggle (65)</option>
<option value="66">Palette (66)</option>
<option value="67">Colorwaves (67)</option>
<option value="68">BPM (68)</option>
<option value="69">Fill Noise 8 (69)</option>
<option value="70">Noise 16 1 (70)</option>
<option value="71">Noise 16 2 (71)</option>
<option value="72">Noise 16 3 (72)</option>
<option value="73">Noise 16 4 (73)</option>
</select><br><br>
Set secondary color to
<button type="button" onclick="CS(0)">White</button>

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -112,7 +112,8 @@ Brightness factor: <input name="BF" type="number" min="0" max="255" required> %
<h3>Transitions</h3>
Fade: <input type="checkbox" name="TF"><br>
Transition Time: <input name="TD" maxlength="5" size="2"> ms<br>
Enable transition for secondary color: <input type="checkbox" name="T2"><br>
Enable transition for secondary color: <input type="checkbox" name="T2">
Enable Palette transitions: <input type="checkbox" name="PF"><br>
<h3>Timed light</h3>
Default Duration: <input name="TL" type="number" min="1" max="255" required> min<br>
Default Target brightness: <input name="TB" type="number" min="0" max="255" required><br>

View File

@ -39,7 +39,7 @@
#include "src/dependencies/e131/E131.h"
//version in format yymmddb (b = daily build)
#define VERSION 1809062
#define VERSION 1809081
char versionString[] = "0.8.0-a";
//AP and OTA default passwords (change them!)

View File

@ -121,7 +121,7 @@ void saveSettingsToEEPROM()
EEPROM.write(371, whiteS);
EEPROM.write(372, useRGBW);
EEPROM.write(373, effectPaletteDefault);
EEPROM.write(374, strip.paletteFade);
EEPROM.write(375, apWaitTimeSecs);
EEPROM.write(376, recoveryAPDisabled);
EEPROM.write(377, EEPVER); //eeprom was updated to latest
@ -356,6 +356,7 @@ void loadSettingsFromEEPROM(bool first)
whiteS = EEPROM.read(371); white = whiteS;
useRGBW = EEPROM.read(372);
effectPaletteDefault = EEPROM.read(373); effectPalette = effectPaletteDefault;
strip.paletteFade = EEPROM.read(374);
if (lastEEPROMversion > 0) {
apWaitTimeSecs = EEPROM.read(375);

View File

@ -192,6 +192,7 @@ void getSettingsJS(byte subPage) //get values for settings form in javascript
sappend('c',"GC",useGammaCorrectionRGB);
sappend('c',"TF",fadeTransition);
sappend('v',"TD",transitionDelay);
sappend('c',"PF",strip.paletteFade);
sappend('c',"T2",!disableSecTransition);
sappend('v',"BF",briMultiplier);
sappend('v',"TB",nightlightTargetBri);

View File

@ -171,6 +171,7 @@ void handleSettingsSet(byte subPage)
transitionDelay = i;
}
}
strip.paletteFade = server.hasArg("PF");
disableSecTransition = !server.hasArg("T2");
if (server.hasArg("TB"))
{

View File

@ -5,7 +5,7 @@
void wledInit()
{
EEPROM.begin(EEPSIZE);
showWelcomePage = (EEPROM.read(233) != 233);
if (EEPROM.read(233) != 233) showWelcomePage = true;
ledCount = ((EEPROM.read(229) << 0) & 0xFF) + ((EEPROM.read(398) << 8) & 0xFF00); if (ledCount > 1200 || ledCount == 0) ledCount = 10;
//RMT eats up too much RAM
#ifdef ARDUINO_ARCH_ESP32