Blend tweaking.
This commit is contained in:
parent
9a87a2ff0d
commit
93a1616933
@ -2475,12 +2475,6 @@ static const char _data_FX_MODE_RIPPLE_RAINBOW[] PROGMEM = "Ripple Rainbow@!,Wav
|
||||
//
|
||||
// TwinkleFOX: Twinkling 'holiday' lights that fade in and out.
|
||||
// Colors are chosen from a palette. Read more about this effect using the link above!
|
||||
|
||||
// If COOL_LIKE_INCANDESCENT is set to 1, colors will
|
||||
// fade out slighted 'reddened', similar to how
|
||||
// incandescent bulbs change color as they get dim down.
|
||||
#define COOL_LIKE_INCANDESCENT 1
|
||||
|
||||
CRGB twinklefox_one_twinkle(uint32_t ms, uint8_t salt, bool cat)
|
||||
{
|
||||
// Overall twinkle speed (changed)
|
||||
@ -2519,7 +2513,7 @@ CRGB twinklefox_one_twinkle(uint32_t ms, uint8_t salt, bool cat)
|
||||
CRGB c;
|
||||
if (bright > 0) {
|
||||
c = ColorFromPalette(SEGPALETTE, hue, bright, NOBLEND);
|
||||
if(COOL_LIKE_INCANDESCENT == 1) {
|
||||
if (!SEGMENT.check1) {
|
||||
// This code takes a pixel, and if its in the 'fading down'
|
||||
// part of the cycle, it adjusts the color a little bit like the
|
||||
// way that incandescent bulbs fade toward 'red' as they dim.
|
||||
@ -2605,14 +2599,14 @@ uint16_t mode_twinklefox()
|
||||
{
|
||||
return twinklefox_base(false);
|
||||
}
|
||||
static const char _data_FX_MODE_TWINKLEFOX[] PROGMEM = "Twinklefox@!,Twinkle rate;;!";
|
||||
static const char _data_FX_MODE_TWINKLEFOX[] PROGMEM = "Twinklefox@!,Twinkle rate,,,,Cool;;!";
|
||||
|
||||
|
||||
uint16_t mode_twinklecat()
|
||||
{
|
||||
return twinklefox_base(true);
|
||||
}
|
||||
static const char _data_FX_MODE_TWINKLECAT[] PROGMEM = "Twinklecat@!,Twinkle rate;;!";
|
||||
static const char _data_FX_MODE_TWINKLECAT[] PROGMEM = "Twinklecat@!,Twinkle rate,,,,Cool;;!";
|
||||
|
||||
|
||||
//inspired by https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/#LEDStripEffectBlinkingHalloweenEyes
|
||||
@ -5763,7 +5757,7 @@ uint16_t mode_2Dfloatingblobs(void) {
|
||||
if (SEGENV.aux0 != cols || SEGENV.aux1 != rows) {
|
||||
SEGENV.aux0 = cols; // re-initialise if virtual size changes
|
||||
SEGENV.aux1 = rows;
|
||||
SEGMENT.fill(BLACK);
|
||||
//SEGMENT.fill(BLACK);
|
||||
for (size_t i = 0; i < MAX_BLOBS; i++) {
|
||||
blob->r[i] = random8(1, cols>8 ? (cols/4) : 2);
|
||||
blob->sX[i] = (float) random8(3, cols) / (float)(256 - SEGMENT.speed); // speed x
|
||||
@ -5777,7 +5771,7 @@ uint16_t mode_2Dfloatingblobs(void) {
|
||||
}
|
||||
}
|
||||
|
||||
SEGMENT.fadeToBlackBy(20);
|
||||
SEGMENT.fadeToBlackBy((SEGMENT.custom2>>3)+1);
|
||||
|
||||
// Bounce balls around
|
||||
for (size_t i = 0; i < Amount; i++) {
|
||||
@ -5833,7 +5827,7 @@ uint16_t mode_2Dfloatingblobs(void) {
|
||||
return FRAMETIME;
|
||||
}
|
||||
#undef MAX_BLOBS
|
||||
static const char _data_FX_MODE_2DBLOBS[] PROGMEM = "Blobs@!,# blobs,Blur;!;!;2;c1=8";
|
||||
static const char _data_FX_MODE_2DBLOBS[] PROGMEM = "Blobs@!,# blobs,Blur,Trail;!;!;2;c1=8";
|
||||
|
||||
|
||||
////////////////////////////
|
||||
|
10
wled00/FX.h
10
wled00/FX.h
@ -416,13 +416,14 @@ typedef struct Segment {
|
||||
static uint16_t _usedSegmentData;
|
||||
|
||||
// perhaps this should be per segment, not static
|
||||
static CRGBPalette16 _randomPalette;
|
||||
static CRGBPalette16 _newRandomPalette;
|
||||
static unsigned long _lastPaletteChange;
|
||||
static CRGBPalette16 _randomPalette; // actual random palette
|
||||
static CRGBPalette16 _newRandomPalette; // target random palette
|
||||
static unsigned long _lastPaletteChange; // last random palette change time in millis()
|
||||
static bool _modeBlend; // mode/effect blending semaphore
|
||||
|
||||
// transition data, valid only if transitional==true, holds values during transition (72 bytes)
|
||||
struct Transition {
|
||||
tmpsegd_t _tmpSeg;
|
||||
tmpsegd_t _tmpSeg; // previous segment environment
|
||||
uint8_t _briT; // temporary brightness
|
||||
uint8_t _cctT; // temporary CCT
|
||||
uint8_t _modeT; // previous mode/effect
|
||||
@ -530,6 +531,7 @@ typedef struct Segment {
|
||||
|
||||
static uint16_t getUsedSegmentData(void) { return _usedSegmentData; }
|
||||
static void addUsedSegmentData(int len) { _usedSegmentData += len; }
|
||||
static void modeBlend(bool blend) { _modeBlend = blend; }
|
||||
static void handleRandomPalette();
|
||||
|
||||
void setUp(uint16_t i1, uint16_t i2, uint8_t grp=1, uint8_t spc=0, uint16_t ofs=UINT16_MAX, uint16_t i1Y=0, uint16_t i2Y=1, uint8_t segId = 255);
|
||||
|
@ -223,7 +223,7 @@ void /*IRAM_ATTR*/ Segment::setPixelColorXY(int x, int y, uint32_t col)
|
||||
if (xX >= width() || yY >= height()) continue; // we have reached one dimension's end
|
||||
|
||||
// if blending modes, blend with underlying pixel
|
||||
if (transitional && _t && currentMode(mode) != _t->_modeT) tmpCol = color_blend(strip.getPixelColorXY(start + xX, startY + yY), col, progress(), true);
|
||||
if (_modeBlend) tmpCol = color_blend(strip.getPixelColorXY(start + xX, startY + yY), col, progress(), true);
|
||||
|
||||
strip.setPixelColorXY(start + xX, startY + yY, tmpCol);
|
||||
|
||||
|
@ -81,6 +81,8 @@ CRGBPalette16 Segment::_randomPalette = CRGBPalette16(DEFAULT_COLOR);
|
||||
CRGBPalette16 Segment::_newRandomPalette = CRGBPalette16(DEFAULT_COLOR);
|
||||
unsigned long Segment::_lastPaletteChange = 0; // perhaps it should be per segment
|
||||
|
||||
bool Segment::_modeBlend = false;
|
||||
|
||||
// copy constructor
|
||||
Segment::Segment(const Segment &orig) {
|
||||
//DEBUG_PRINTLN(F("-- Copy segment constructor --"));
|
||||
@ -708,12 +710,12 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
|
||||
uint16_t indexMir = stop - indexSet + start - 1;
|
||||
indexMir += offset; // offset/phase
|
||||
if (indexMir >= stop) indexMir -= len; // wrap
|
||||
if (transitional && _t && currentMode(mode) != _t->_modeT) tmpCol = color_blend(strip.getPixelColor(indexMir), col, progress(), true);
|
||||
if (_modeBlend) tmpCol = color_blend(strip.getPixelColor(indexMir), col, progress(), true);
|
||||
strip.setPixelColor(indexMir, tmpCol);
|
||||
}
|
||||
indexSet += offset; // offset/phase
|
||||
if (indexSet >= stop) indexSet -= len; // wrap
|
||||
if (transitional && _t && currentMode(mode) != _t->_modeT) tmpCol = color_blend(strip.getPixelColor(indexSet), col, progress(), true);
|
||||
if (_modeBlend) tmpCol = color_blend(strip.getPixelColor(indexSet), col, progress(), true);
|
||||
strip.setPixelColor(indexSet, tmpCol);
|
||||
}
|
||||
}
|
||||
@ -920,7 +922,7 @@ void Segment::fade_out(uint8_t rate) {
|
||||
const uint16_t rows = virtualHeight(); // will be 1 for 1D
|
||||
|
||||
rate = (255-rate) >> 1;
|
||||
float mappedRate = float(rate) +1.1;
|
||||
float mappedRate = float(rate) +1.1f;
|
||||
|
||||
uint32_t color = colors[1]; // SEGCOLOR(1); // target color
|
||||
int w2 = W(color);
|
||||
@ -1184,12 +1186,14 @@ void WS2812FX::service() {
|
||||
Segment::tmpsegd_t _tmpSegData;
|
||||
seg.saveSegenv(&_tmpSegData);
|
||||
uint8_t tmpMode = seg.currentMode(seg.mode);
|
||||
if (seg.mode != tmpMode) seg.restoreSegenv(nullptr); // restore transition data (including temporary opacity)
|
||||
if (seg.mode != tmpMode) seg.restoreSegenv(); // restore transition data (including temporary opacity)
|
||||
delay = (*_mode[tmpMode])(); // run old mode
|
||||
if (seg.mode != tmpMode) {
|
||||
if (tmpMode != FX_MODE_HALLOWEEN_EYES) seg.call++;
|
||||
seg.restoreSegenv(&_tmpSegData); // restore mode state
|
||||
Segment::modeBlend(true); // set semaphore
|
||||
uint16_t d2 = (*_mode[seg.mode])(); // run new mode
|
||||
Segment::modeBlend(false); // unset semaphore
|
||||
delay = MIN(delay,d2); // use shortest delay
|
||||
}
|
||||
if (seg.mode != FX_MODE_HALLOWEEN_EYES) seg.call++;
|
||||
|
Loading…
Reference in New Issue
Block a user