Added Colortwinkle effect 74
This commit is contained in:
parent
81c810eba4
commit
9904c10984
@ -40,7 +40,6 @@
|
||||
|
||||
|
||||
#include "WS2812FX.h"
|
||||
#include "FastLED.h"
|
||||
#include "palettes.h"
|
||||
|
||||
void WS2812FX::init(bool supportWhite, uint16_t countPixels, bool skipFirst)
|
||||
@ -90,6 +89,12 @@ void WS2812FX::clear()
|
||||
bus->ClearTo(RgbColor(0));
|
||||
}
|
||||
|
||||
bool WS2812FX::modeUsesLock(uint8_t m)
|
||||
{
|
||||
if (m == FX_MODE_FIRE_2012 || m == FX_MODE_COLORTWINKLE) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void WS2812FX::setPixelColor(uint16_t n, uint32_t c) {
|
||||
uint8_t w = (c >> 24) & 0xFF;
|
||||
uint8_t r = (c >> 16) & 0xFF;
|
||||
@ -100,7 +105,7 @@ void WS2812FX::setPixelColor(uint16_t n, uint32_t c) {
|
||||
|
||||
void WS2812FX::setPixelColor(uint16_t i, byte r, byte g, byte b, byte w)
|
||||
{
|
||||
if (_locked[i] && SEGMENT.mode != FX_MODE_FIRE_2012) return;
|
||||
if (_locked[i] && !modeUsesLock(SEGMENT.mode)) return;
|
||||
if (_reverseMode) i = _length - 1 -i;
|
||||
if (IS_REVERSE) i = SEGMENT.stop - (i - SEGMENT.start); //reverse just individual segment
|
||||
if (!_cronixieMode)
|
||||
@ -177,7 +182,7 @@ void WS2812FX::trigger() {
|
||||
|
||||
void WS2812FX::setMode(uint8_t m) {
|
||||
RESET_RUNTIME;
|
||||
bool ua = _segments[0].mode == FX_MODE_FIRE_2012 && m != FX_MODE_FIRE_2012;
|
||||
bool ua = modeUsesLock(_segments[0].mode) && !modeUsesLock(m);
|
||||
_segments[0].mode = constrain(m, 0, MODE_COUNT - 1);
|
||||
if (ua) unlockAll();
|
||||
setBrightness(_brightness);
|
||||
@ -318,7 +323,7 @@ void WS2812FX::resetSegments() {
|
||||
|
||||
void WS2812FX::setIndividual(uint16_t i, uint32_t col)
|
||||
{
|
||||
if (SEGMENT.mode == FX_MODE_FIRE_2012) return;
|
||||
if (modeUsesLock(SEGMENT.mode)) return;
|
||||
if (i >= 0 && i < _length)
|
||||
{
|
||||
_locked[i] = false;
|
||||
@ -340,13 +345,13 @@ void WS2812FX::setRange(uint16_t i, uint16_t i2, uint32_t col)
|
||||
|
||||
void WS2812FX::lock(uint16_t i)
|
||||
{
|
||||
if (SEGMENT.mode == FX_MODE_FIRE_2012) return;
|
||||
if (modeUsesLock(SEGMENT.mode)) return;
|
||||
if (i >= 0 && i < _length) _locked[i] = true;
|
||||
}
|
||||
|
||||
void WS2812FX::lockRange(uint16_t i, uint16_t i2)
|
||||
{
|
||||
if (SEGMENT.mode == FX_MODE_FIRE_2012) return;
|
||||
if (modeUsesLock(SEGMENT.mode)) return;
|
||||
for (uint16_t x = i; x <= i2; x++)
|
||||
{
|
||||
if (i >= 0 && i < _length) _locked[i] = true;
|
||||
@ -355,13 +360,13 @@ void WS2812FX::lockRange(uint16_t i, uint16_t i2)
|
||||
|
||||
void WS2812FX::unlock(uint16_t i)
|
||||
{
|
||||
if (SEGMENT.mode == FX_MODE_FIRE_2012) return;
|
||||
if (modeUsesLock(SEGMENT.mode)) return;
|
||||
if (i >= 0 && i < _length) _locked[i] = false;
|
||||
}
|
||||
|
||||
void WS2812FX::unlockRange(uint16_t i, uint16_t i2)
|
||||
{
|
||||
if (SEGMENT.mode == FX_MODE_FIRE_2012) return;
|
||||
if (modeUsesLock(SEGMENT.mode)) return;
|
||||
for (uint16_t x = i; x < i2; x++)
|
||||
{
|
||||
if (x >= 0 && x < _length) _locked[x] = false;
|
||||
@ -377,7 +382,7 @@ void WS2812FX::setTransitionMode(bool t)
|
||||
{
|
||||
SEGMENT_RUNTIME.trans_act = (t) ? 1:2;
|
||||
if (!t) return;
|
||||
unsigned long waitMax = millis() + 20; //refresh after 20 seconds if transition enabled
|
||||
unsigned long waitMax = millis() + 20; //refresh after 20 ms if transition enabled
|
||||
if (SEGMENT.mode == FX_MODE_STATIC && SEGMENT_RUNTIME.next_time > waitMax) SEGMENT_RUNTIME.next_time = waitMax;
|
||||
}
|
||||
|
||||
@ -2051,6 +2056,15 @@ uint16_t WS2812FX::mode_lightning(void)
|
||||
}
|
||||
|
||||
|
||||
CRGB WS2812FX::fastled_from_col(uint32_t color)
|
||||
{
|
||||
CRGB fastled_col;
|
||||
fastled_col.red = (color >> 16 & 0xFF);
|
||||
fastled_col.green = (color >> 8 & 0xFF);
|
||||
fastled_col.blue = (color & 0xFF);
|
||||
return fastled_col;
|
||||
}
|
||||
|
||||
// Pride2015
|
||||
// Animated, ever-changing rainbows.
|
||||
// by Mark Kriegsman: https://gist.github.com/kriegsman/964de772d64c502760e5
|
||||
@ -2085,11 +2099,7 @@ uint16_t WS2812FX::mode_pride_2015(void)
|
||||
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);
|
||||
fastled_col = fastled_from_col(getPixelColor(i));
|
||||
|
||||
nblend( fastled_col, newcolor, 64);
|
||||
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
||||
@ -2107,10 +2117,7 @@ uint16_t WS2812FX::mode_juggle(void){
|
||||
byte dothue = 0;
|
||||
for ( byte i = 0; i < 8; i++) {
|
||||
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);
|
||||
fastled_col.blue = (color & 0xFF);
|
||||
fastled_col = fastled_from_col(getPixelColor(index));
|
||||
fastled_col |= CHSV(dothue, 220, 255);
|
||||
setPixelColor(index, fastled_col.red, fastled_col.green, fastled_col.blue);
|
||||
dothue += 32;
|
||||
@ -2161,17 +2168,11 @@ void WS2812FX::handle_palette(void)
|
||||
_lastPaletteChange = millis();
|
||||
} break;}
|
||||
case 2: {//primary color only
|
||||
CRGB prim;
|
||||
prim.red = (SEGMENT.colors[0] >> 16 & 0xFF);
|
||||
prim.green = (SEGMENT.colors[0] >> 8 & 0xFF);
|
||||
prim.blue = (SEGMENT.colors[0] & 0xFF);
|
||||
CRGB prim = fastled_from_col(SEGMENT.colors[0]);
|
||||
targetPalette = CRGBPalette16(prim); break;}
|
||||
case 3: {//based on primary
|
||||
//considering performance implications
|
||||
CRGB prim;
|
||||
prim.red = (SEGMENT.colors[0] >> 16 & 0xFF);
|
||||
prim.green = (SEGMENT.colors[0] >> 8 & 0xFF);
|
||||
prim.blue = (SEGMENT.colors[0] & 0xFF);
|
||||
CRGB prim = fastled_from_col(SEGMENT.colors[0]);
|
||||
CHSV prim_hsv = rgb2hsv_approximate(prim);
|
||||
targetPalette = CRGBPalette16(
|
||||
CHSV(prim_hsv.h, prim_hsv.s, prim_hsv.v), //color itself
|
||||
@ -2180,24 +2181,12 @@ void WS2812FX::handle_palette(void)
|
||||
CHSV(prim_hsv.h, prim_hsv.s, prim_hsv.v)); //color itself
|
||||
break;}
|
||||
case 4: {//primary + secondary
|
||||
CRGB prim;
|
||||
prim.red = (SEGMENT.colors[0] >> 16 & 0xFF);
|
||||
prim.green = (SEGMENT.colors[0] >> 8 & 0xFF);
|
||||
prim.blue = (SEGMENT.colors[0] & 0xFF);
|
||||
CRGB sec;
|
||||
sec.red = (SEGMENT.colors[1] >> 16 & 0xFF);
|
||||
sec.green = (SEGMENT.colors[1] >> 8 & 0xFF);
|
||||
sec.blue = (SEGMENT.colors[1] & 0xFF);
|
||||
CRGB prim = fastled_from_col(SEGMENT.colors[0]);
|
||||
CRGB sec = fastled_from_col(SEGMENT.colors[1]);
|
||||
targetPalette = CRGBPalette16(sec,prim); break;}
|
||||
case 5: {//based on primary + secondary
|
||||
CRGB prim;
|
||||
prim.red = (SEGMENT.colors[0] >> 16 & 0xFF);
|
||||
prim.green = (SEGMENT.colors[0] >> 8 & 0xFF);
|
||||
prim.blue = (SEGMENT.colors[0] & 0xFF);
|
||||
CRGB sec;
|
||||
sec.red = (SEGMENT.colors[1] >> 16 & 0xFF);
|
||||
sec.green = (SEGMENT.colors[1] >> 8 & 0xFF);
|
||||
sec.blue = (SEGMENT.colors[1] & 0xFF);
|
||||
CRGB prim = fastled_from_col(SEGMENT.colors[0]);
|
||||
CRGB sec = fastled_from_col(SEGMENT.colors[1]);
|
||||
targetPalette = CRGBPalette16(sec,prim,CRGB::White); break;}
|
||||
case 6: //Party colors
|
||||
targetPalette = PartyColors_p; break;
|
||||
@ -2359,11 +2348,7 @@ uint16_t WS2812FX::mode_colorwaves(void)
|
||||
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);
|
||||
fastled_col = fastled_from_col(getPixelColor(i));
|
||||
|
||||
nblend(fastled_col, newcolor, 128);
|
||||
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
||||
@ -2497,3 +2482,47 @@ uint16_t WS2812FX::mode_noise16_4(void)
|
||||
}
|
||||
return 20;
|
||||
}
|
||||
|
||||
|
||||
uint16_t WS2812FX::mode_colortwinkle()
|
||||
{
|
||||
CRGB fastled_col, prev;
|
||||
fract8 fadeUpAmount = 8 + (SEGMENT.speed/4), fadeDownAmount = 5 + (SEGMENT.speed/7);
|
||||
for( uint16_t i = SEGMENT.start; i <= SEGMENT.stop; i++) {
|
||||
fastled_col = fastled_from_col(getPixelColor(i));
|
||||
prev = fastled_col;
|
||||
if(_locked[i]) {
|
||||
CRGB incrementalColor = fastled_col;
|
||||
incrementalColor.nscale8_video( fadeUpAmount);
|
||||
fastled_col += incrementalColor;
|
||||
|
||||
if( fastled_col.red == 255 || fastled_col.green == 255 || fastled_col.blue == 255) {
|
||||
_locked[i] = false;
|
||||
}
|
||||
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
||||
|
||||
if (fastled_from_col(getPixelColor(i)) == prev) //fix "stuck" pixels
|
||||
{
|
||||
fastled_col += fastled_col;
|
||||
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
||||
}
|
||||
} else {
|
||||
fastled_col.nscale8( 255 - fadeDownAmount);
|
||||
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
||||
}
|
||||
}
|
||||
|
||||
if( random8() <= SEGMENT.intensity ) {
|
||||
for (uint8_t times = 0; times < 5; times++) //attempt to spawn a new pixel 5 times
|
||||
{
|
||||
int i = SEGMENT.start + random16(SEGMENT_LENGTH);
|
||||
if(getPixelColor(i) == 0) {
|
||||
fastled_col = ColorFromPalette( currentPalette, random8(), 64, NOBLEND);
|
||||
_locked[i] = true;
|
||||
setPixelColor(i, fastled_col.red, fastled_col.green, fastled_col.blue);
|
||||
return 20; //only spawn 1 new pixel per frame
|
||||
}
|
||||
}
|
||||
}
|
||||
return 20;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@
|
||||
#define WS2812FX_h
|
||||
|
||||
#include "NpbWrapper.h"
|
||||
#include "FastLED.h"
|
||||
|
||||
#define DEFAULT_BRIGHTNESS (uint8_t)50
|
||||
#define DEFAULT_MODE (uint8_t)0
|
||||
@ -82,7 +83,7 @@
|
||||
#define REVERSE (uint8_t)0x80
|
||||
#define IS_REVERSE ((SEGMENT.options & REVERSE) == REVERSE)
|
||||
|
||||
#define MODE_COUNT 74
|
||||
#define MODE_COUNT 75
|
||||
|
||||
#define FX_MODE_STATIC 0
|
||||
#define FX_MODE_BLINK 1
|
||||
@ -159,6 +160,7 @@
|
||||
#define FX_MODE_NOISE16_2 71
|
||||
#define FX_MODE_NOISE16_3 72
|
||||
#define FX_MODE_NOISE16_4 73
|
||||
#define FX_MODE_COLORTWINKLE 74
|
||||
|
||||
class WS2812FX {
|
||||
typedef uint16_t (WS2812FX::*mode_ptr)(void);
|
||||
@ -261,6 +263,7 @@ class WS2812FX {
|
||||
_mode[FX_MODE_NOISE16_2] = &WS2812FX::mode_noise16_2;
|
||||
_mode[FX_MODE_NOISE16_3] = &WS2812FX::mode_noise16_3;
|
||||
_mode[FX_MODE_NOISE16_4] = &WS2812FX::mode_noise16_4;
|
||||
_mode[FX_MODE_COLORTWINKLE] = &WS2812FX::mode_colortwinkle;
|
||||
|
||||
_brightness = DEFAULT_BRIGHTNESS;
|
||||
_running = false;
|
||||
@ -434,16 +437,20 @@ class WS2812FX {
|
||||
mode_noise16_2(void),
|
||||
mode_noise16_3(void),
|
||||
mode_noise16_4(void),
|
||||
mode_colortwinkle(void),
|
||||
mode_lightning(void);
|
||||
|
||||
private:
|
||||
NeoPixelWrapper *bus;
|
||||
|
||||
CRGB fastled_from_col(uint32_t);
|
||||
|
||||
uint16_t _length;
|
||||
uint16_t _rand16seed;
|
||||
uint8_t _brightness;
|
||||
|
||||
void handle_palette(void);
|
||||
bool modeUsesLock(uint8_t);
|
||||
|
||||
double
|
||||
_cronixieSecMultiplier;
|
||||
|
@ -192,10 +192,10 @@
|
||||
function SwFX(s)
|
||||
{
|
||||
var n=Cf.TX.selectedIndex+s;
|
||||
if (n==-1||n==74) return;
|
||||
if (n==-1||n==75) return;
|
||||
Cf.TX.selectedIndex =n;
|
||||
if (n < 0) Cf.TX.selectedIndex = 0;
|
||||
if (n > 73) Cf.TX.selectedIndex = 65;
|
||||
if (n > 74) Cf.TX.selectedIndex = 65;
|
||||
GX();
|
||||
}
|
||||
function TgHSB()
|
||||
@ -660,6 +660,7 @@
|
||||
<option value="71">Noise 16 2 (71)</option>
|
||||
<option value="72">Noise 16 3 (72)</option>
|
||||
<option value="73">Noise 16 4 (73)</option>
|
||||
<option value="74">Colortwinkle (74)</option>
|
||||
</select><br><br>
|
||||
Set secondary color to
|
||||
<button type="button" onclick="CS(0)">White</button>
|
||||
|
@ -432,7 +432,8 @@
|
||||
<li onclick="X(70)">Noise 16 1</li>
|
||||
<li onclick="X(71)">Noise 16 2</li>
|
||||
<li onclick="X(72)">Noise 16 3</li>
|
||||
<li onclick="X(73)">Noise 16 4</li>
|
||||
<li onclick="X(73)">Noise 16 4</li>
|
||||
<li onclick="X(74)">Colortwinkle</li>
|
||||
<li><a href="#">Go to top</a></li>
|
||||
<p style="margin-left:-37px">FastLED Palette (Effects 56-73)</p>
|
||||
<li onclick="P(0)">Default</li>
|
||||
|
File diff suppressed because one or more lines are too long
@ -63,7 +63,7 @@
|
||||
|
||||
|
||||
//version code in format yymmddb (b = daily build)
|
||||
#define VERSION 1811012
|
||||
#define VERSION 1811041
|
||||
char versionString[] = "0.8.1";
|
||||
|
||||
|
||||
|
@ -206,6 +206,7 @@ void handleNotifications()
|
||||
if (udpIn[1] == 0)
|
||||
{
|
||||
realtimeActive = false;
|
||||
return;
|
||||
} else {
|
||||
arlsLock(udpIn[1]*1000);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user