Optimisations.

This commit is contained in:
Blaz Kristan 2022-07-30 14:20:36 +02:00
parent 1abf0fc134
commit f16558c126
4 changed files with 55 additions and 58 deletions

View File

@ -75,7 +75,7 @@ int8_t tristate_square8(uint8_t x, uint8_t pulsewidth, uint8_t attdec) {
*/ */
uint16_t mode_static(void) { uint16_t mode_static(void) {
SEGMENT.fill(SEGCOLOR(0)); SEGMENT.fill(SEGCOLOR(0));
return (SEGMENT.getOption(SEG_OPTION_TRANSITIONAL)) ? FRAMETIME : 350; //update faster if in transition return /*(SEGMENT.getOption(SEG_OPTION_TRANSITIONAL)) ? FRAMETIME :*/ 350; //update faster if in transition
} }
static const char *_data_FX_MODE_STATIC PROGMEM = "Solid"; static const char *_data_FX_MODE_STATIC PROGMEM = "Solid";

View File

@ -56,10 +56,6 @@
#define RGBW32(r,g,b,w) (uint32_t((byte(w) << 24) | (byte(r) << 16) | (byte(g) << 8) | (byte(b)))) #define RGBW32(r,g,b,w) (uint32_t((byte(w) << 24) | (byte(r) << 16) | (byte(g) << 8) | (byte(b))))
#endif #endif
//colors.cpp (.h does not like including other .h)
uint32_t color_blend(uint32_t,uint32_t,uint16_t,bool b16);
uint32_t color_add(uint32_t,uint32_t);
/* Not used in all effects yet */ /* Not used in all effects yet */
#define WLED_FPS 42 #define WLED_FPS 42
#define FRAMETIME_FIXED (1000/WLED_FPS) #define FRAMETIME_FIXED (1000/WLED_FPS)
@ -71,12 +67,12 @@ uint32_t color_add(uint32_t,uint32_t);
#ifdef ESP8266 #ifdef ESP8266
#define MAX_NUM_SEGMENTS 16 #define MAX_NUM_SEGMENTS 16
/* How much data bytes all segments combined may allocate */ /* How much data bytes all segments combined may allocate */
#define MAX_SEGMENT_DATA 4096 #define MAX_SEGMENT_DATA 5120
#else #else
#ifndef MAX_NUM_SEGMENTS #ifndef MAX_NUM_SEGMENTS
#define MAX_NUM_SEGMENTS 32 #define MAX_NUM_SEGMENTS 32
#endif #endif
#define MAX_SEGMENT_DATA 32768 #define MAX_SEGMENT_DATA 32767
#endif #endif
/* How much data bytes each segment should max allocate to leave enough space for other segments, /* How much data bytes each segment should max allocate to leave enough space for other segments,
@ -88,7 +84,7 @@ uint32_t color_add(uint32_t,uint32_t);
#define NUM_COLORS 3 /* number of colors per segment */ #define NUM_COLORS 3 /* number of colors per segment */
#define SEGMENT strip._segments[strip.getCurrSegmentId()] #define SEGMENT strip._segments[strip.getCurrSegmentId()]
#define SEGENV strip._segments[strip.getCurrSegmentId()] #define SEGENV strip._segments[strip.getCurrSegmentId()]
//#define SEGCOLOR(x) strip._segments[s//trip.getCurrSegmentId()].currentColor(x, strip._segments[strip.getCurrSegmentId()].colors[x]) //#define SEGCOLOR(x) strip._segments[strip.getCurrSegmentId()].currentColor(x, strip._segments[strip.getCurrSegmentId()].colors[x])
//#define SEGLEN strip._segments[strip.getCurrSegmentId()].virtualLength() //#define SEGLEN strip._segments[strip.getCurrSegmentId()].virtualLength()
#define SEGCOLOR(x) strip.segColor(x) /* saves us a few kbytes of code */ #define SEGCOLOR(x) strip.segColor(x) /* saves us a few kbytes of code */
#define SEGPALETTE strip._currentPalette #define SEGPALETTE strip._currentPalette
@ -427,6 +423,7 @@ typedef struct Segment {
}; };
}; };
uint16_t _dataLen; uint16_t _dataLen;
static uint16_t _usedSegmentData;
// transition data, valid only if getOption(SEG_OPTION_TRANSITIONAL)==true, holds values during transition // transition data, valid only if getOption(SEG_OPTION_TRANSITIONAL)==true, holds values during transition
//struct Transition { //struct Transition {
@ -504,12 +501,16 @@ typedef struct Segment {
inline bool getOption(uint8_t n) { return ((options >> n) & 0x01); } inline bool getOption(uint8_t n) { return ((options >> n) & 0x01); }
inline bool isSelected(void) { return getOption(0); } inline bool isSelected(void) { return getOption(0); }
inline bool isActive(void) { return stop > start; } inline bool isActive(void) { return stop > start; }
inline bool is2D(void) { return !(startY == 0 && stopY == 1); }
inline uint16_t width(void) { return stop - start; } inline uint16_t width(void) { return stop - start; }
inline uint16_t height(void) { return stopY - startY; } inline uint16_t height(void) { return stopY - startY; }
inline uint16_t length(void) { return width(); } inline uint16_t length(void) { return width(); }
inline uint16_t groupLength(void) { return grouping + spacing; } inline uint16_t groupLength(void) { return grouping + spacing; }
inline uint8_t getLightCapabilities(void) { return _capabilities; } inline uint8_t getLightCapabilities(void) { return _capabilities; }
static uint16_t getUsedSegmentData(void) { return _usedSegmentData; }
static void addUsedSegmentData(int len) { _usedSegmentData += len; }
bool setColor(uint8_t slot, uint32_t c); //returns true if changed bool setColor(uint8_t slot, uint32_t c); //returns true if changed
void setCCT(uint16_t k); void setCCT(uint16_t k);
void setOpacity(uint8_t o); void setOpacity(uint8_t o);
@ -518,9 +519,9 @@ typedef struct Segment {
void refreshLightCapabilities(void); void refreshLightCapabilities(void);
// runtime data functions // runtime data functions
bool allocateData(uint16_t len);
void deallocateData(void);
inline uint16_t dataSize(void) { return _dataLen; } inline uint16_t dataSize(void) { return _dataLen; }
bool allocateData(size_t len);
void deallocateData(void);
void resetIfRequired(void); void resetIfRequired(void);
/** /**
* Flags that before the next effect is calculated, * Flags that before the next effect is calculated,
@ -535,7 +536,7 @@ typedef struct Segment {
void handleTransition(void); void handleTransition(void);
uint16_t progress(void); //transition progression between 0-65535 uint16_t progress(void); //transition progression between 0-65535
uint8_t currentBri(uint8_t briNew, bool useCct = false); uint8_t currentBri(uint8_t briNew, bool useCct = false);
uint32_t currentColor(uint8_t slot, uint32_t colorNew) { return getOption(SEG_OPTION_TRANSITIONAL) /*&& !_t*/ ? color_blend(/*_t->*/_colorT[slot], colorNew, progress(), true) : colorNew; } uint32_t currentColor(uint8_t slot, uint32_t colorNew);
CRGBPalette16 &loadPalette(CRGBPalette16 &tgt, uint8_t pal); CRGBPalette16 &loadPalette(CRGBPalette16 &tgt, uint8_t pal);
CRGBPalette16 &currentPalette(CRGBPalette16 &tgt, uint8_t paletteID); CRGBPalette16 &currentPalette(CRGBPalette16 &tgt, uint8_t paletteID);
@ -633,13 +634,11 @@ class WS2812FX { // 96 bytes
#endif #endif
// semi-private (just obscured) used in effect functions through macros // semi-private (just obscured) used in effect functions through macros
_currentPalette(CRGBPalette16(CRGB::Black)), _currentPalette(CRGBPalette16(CRGB::Black)),
_bri_t(0),
_colors_t{0,0,0}, _colors_t{0,0,0},
_virtualSegmentLength(0), _virtualSegmentLength(0),
// true private variables // true private variables
_length(DEFAULT_LED_COUNT), _length(DEFAULT_LED_COUNT),
_brightness(DEFAULT_BRIGHTNESS), _brightness(DEFAULT_BRIGHTNESS),
_usedSegmentData(0),
_transitionDur(750), _transitionDur(750),
_targetFps(WLED_FPS), _targetFps(WLED_FPS),
_frametime(FRAMETIME_FIXED), _frametime(FRAMETIME_FIXED),
@ -707,7 +706,6 @@ class WS2812FX { // 96 bytes
inline void setShowCallback(show_callback cb) { _callback = cb; } inline void setShowCallback(show_callback cb) { _callback = cb; }
inline void setTransition(uint16_t t) { _transitionDur = t; } inline void setTransition(uint16_t t) { _transitionDur = t; }
inline void appendSegment(const Segment &seg = Segment()) { _segments.push_back(seg); } inline void appendSegment(const Segment &seg = Segment()) { _segments.push_back(seg); }
inline void addUsedSegmentData(int16_t size) { _usedSegmentData += size; }
bool bool
gammaCorrectBri, gammaCorrectBri,
@ -753,7 +751,6 @@ class WS2812FX { // 96 bytes
inline uint16_t getMinShowDelay(void) { return MIN_SHOW_DELAY; } inline uint16_t getMinShowDelay(void) { return MIN_SHOW_DELAY; }
inline uint16_t getLengthTotal(void) { return _length; } inline uint16_t getLengthTotal(void) { return _length; }
inline uint16_t getTransition(void) { return _transitionDur; } inline uint16_t getTransition(void) { return _transitionDur; }
inline uint16_t getUsedSegmentData(void) { return _usedSegmentData; }
uint32_t uint32_t
now, now,
@ -823,7 +820,6 @@ class WS2812FX { // 96 bytes
// using public variables to reduce code size increase due to inline function getSegment() (with bounds checking) // using public variables to reduce code size increase due to inline function getSegment() (with bounds checking)
// and color transitions // and color transitions
uint8_t _bri_t; // opacity used for effect (includes transition)
uint32_t _colors_t[3]; // color used for effect (includes transition) uint32_t _colors_t[3]; // color used for effect (includes transition)
uint16_t _virtualSegmentLength; uint16_t _virtualSegmentLength;
@ -833,7 +829,6 @@ class WS2812FX { // 96 bytes
private: private:
uint16_t _length; uint16_t _length;
uint8_t _brightness; uint8_t _brightness;
uint16_t _usedSegmentData;
uint16_t _transitionDur; uint16_t _transitionDur;
uint8_t _targetFps; uint8_t _targetFps;

View File

@ -152,8 +152,7 @@ void IRAM_ATTR Segment::setPixelColorXY(int x, int y, uint32_t col)
#ifndef WLED_DISABLE_2D #ifndef WLED_DISABLE_2D
if (!strip.isMatrix) return; // not a matrix set-up if (!strip.isMatrix) return; // not a matrix set-up
uint8_t _bri_t = strip._bri_t; uint8_t _bri_t = currentBri(getOption(SEG_OPTION_ON) ? opacity : 0);
//uint8_t _bri_t = currentBri(getOption(SEG_OPTION_ON) ? opacity : 0);
if (_bri_t < 255) { if (_bri_t < 255) {
byte r = scale8(R(col), _bri_t); byte r = scale8(R(col), _bri_t);
byte g = scale8(G(col), _bri_t); byte g = scale8(G(col), _bri_t);

View File

@ -73,6 +73,7 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Segment class implementation // Segment class implementation
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
uint16_t Segment::_usedSegmentData = 0U; // amount of RAM all segments use for their data[]
Segment::Segment(const Segment &orig) { Segment::Segment(const Segment &orig) {
DEBUG_PRINTLN(F("-- Segment duplicated --")); DEBUG_PRINTLN(F("-- Segment duplicated --"));
@ -138,11 +139,10 @@ Segment& Segment::operator= (Segment &&orig) noexcept {
return *this; return *this;
} }
bool Segment::allocateData(uint16_t len) { bool Segment::allocateData(size_t len) {
if (data && _dataLen == len) return true; //already allocated if (data && _dataLen == len) return true; //already allocated
deallocateData(); deallocateData();
// TODO: move out to WS2812FX class: for (seg : _segments) sum += seg.dataSize(); if (Segment::getUsedSegmentData() + len > MAX_SEGMENT_DATA) return false; //not enough memory
if (strip.getUsedSegmentData() + len > MAX_SEGMENT_DATA) return false; //not enough memory
// if possible use SPI RAM on ESP32 // if possible use SPI RAM on ESP32
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM) #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_PSRAM)
if (psramFound()) if (psramFound())
@ -151,7 +151,7 @@ bool Segment::allocateData(uint16_t len) {
#endif #endif
data = (byte*) malloc(len); data = (byte*) malloc(len);
if (!data) return false; //allocation failed if (!data) return false; //allocation failed
strip.addUsedSegmentData(len); // TODO: move out to WS2812FX class: for (seg : _segments) sum += seg.dataSize(); Segment::addUsedSegmentData(len);
_dataLen = len; _dataLen = len;
memset(data, 0, len); memset(data, 0, len);
DEBUG_PRINTF("-- Allocated data %p (%d)\n", data, (int)len); DEBUG_PRINTF("-- Allocated data %p (%d)\n", data, (int)len);
@ -159,13 +159,12 @@ bool Segment::allocateData(uint16_t len) {
} }
void Segment::deallocateData() { void Segment::deallocateData() {
// NOTE: deallocating data sometimes produces corrupt heap.
if (!data) return; if (!data) return;
DEBUG_PRINTF("-- Deallocating data: %p (%d)\n", data, (int)_dataLen); DEBUG_PRINTF("-- Deallocating data: %p (%d)\n", data, (int)_dataLen);
free(data); free(data);
DEBUG_PRINTLN(F("-- Data freed.")); DEBUG_PRINTLN(F("-- Data freed."));
data = nullptr; data = nullptr;
strip.addUsedSegmentData(-(int16_t)_dataLen); // TODO: move out to WS2812FX class: for (seg : _segments) sum -= seg.dataSize(); Segment::addUsedSegmentData(-_dataLen);
_dataLen = 0; _dataLen = 0;
DEBUG_PRINTLN(F("-- Dealocated data.")); DEBUG_PRINTLN(F("-- Dealocated data."));
} }
@ -216,16 +215,20 @@ uint16_t Segment::progress() { //transition progression between 0-65535
} }
uint8_t Segment::currentBri(uint8_t briNew, bool useCct) { uint8_t Segment::currentBri(uint8_t briNew, bool useCct) {
//if (!_t) return (useCct) ? cct : opacity; //if (_t) {
if (getOption(SEG_OPTION_TRANSITIONAL)) { if (getOption(SEG_OPTION_TRANSITIONAL)) {
uint32_t prog = progress() + 1; uint32_t prog = progress() + 1;
if (useCct) return ((briNew * prog) + /*_t->*/_cctT * (0x10000 - prog)) >> 16; if (useCct) return ((briNew * prog) + /*_t->*/_cctT * (0x10000 - prog)) >> 16;
else return ((briNew * prog) + /*_t->*/_briT * (0x10000 - prog)) >> 16; else return ((briNew * prog) + /*_t->*/_briT * (0x10000 - prog)) >> 16;
} else { } else {
return (useCct) ? cct : (getOption(SEG_OPTION_ON) ? opacity : 0); return briNew;
} }
} }
uint32_t Segment::currentColor(uint8_t slot, uint32_t colorNew) {
return getOption(SEG_OPTION_TRANSITIONAL) /*&& _t*/ ? color_blend(/*_t->*/_colorT[slot], colorNew, progress(), true) : colorNew;
}
CRGBPalette16 &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) { CRGBPalette16 &Segment::loadPalette(CRGBPalette16 &targetPalette, uint8_t pal) {
static unsigned long _lastPaletteChange = 0; // perhaps it should be per segment static unsigned long _lastPaletteChange = 0; // perhaps it should be per segment
byte tcp[72]; byte tcp[72];
@ -375,7 +378,7 @@ uint16_t Segment::virtualHeight() {
// 1D strip // 1D strip
uint16_t Segment::virtualLength() { uint16_t Segment::virtualLength() {
#ifndef WLED_DISABLE_2D #ifndef WLED_DISABLE_2D
if (height() > 1) { if (is2D()) {
uint16_t vW = virtualWidth(); uint16_t vW = virtualWidth();
uint16_t vH = virtualHeight(); uint16_t vH = virtualHeight();
uint32_t vLen = vW * vH; // use all pixels from segment uint32_t vLen = vW * vH; // use all pixels from segment
@ -400,7 +403,7 @@ uint16_t Segment::virtualLength() {
void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col) void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
{ {
#ifndef WLED_DISABLE_2D #ifndef WLED_DISABLE_2D
if (height() > 1) { // if this does not work use strip.isMatrix if (is2D()) { // if this does not work use strip.isMatrix
uint16_t vH = virtualHeight(); // segment height in logical pixels uint16_t vH = virtualHeight(); // segment height in logical pixels
uint16_t vW = virtualWidth(); uint16_t vW = virtualWidth();
switch (map1D2D) { switch (map1D2D) {
@ -431,8 +434,7 @@ void IRAM_ATTR Segment::setPixelColor(int i, uint32_t col)
#endif #endif
uint16_t len = length(); uint16_t len = length();
uint8_t _bri_t = strip._bri_t; uint8_t _bri_t = currentBri(getOption(SEG_OPTION_ON) ? opacity : 0);
//uint8_t _bri_t = currentBri(getOption(SEG_OPTION_ON) ? opacity : 0);
if (_bri_t < 255) { if (_bri_t < 255) {
byte r = scale8(R(col), _bri_t); byte r = scale8(R(col), _bri_t);
byte g = scale8(G(col), _bri_t); byte g = scale8(G(col), _bri_t);
@ -501,7 +503,7 @@ void Segment::setPixelColor(float i, uint32_t col, bool aa)
uint32_t Segment::getPixelColor(uint16_t i) uint32_t Segment::getPixelColor(uint16_t i)
{ {
#ifndef WLED_DISABLE_2D #ifndef WLED_DISABLE_2D
if (height() > 1) { // if this does not work use strip.isMatrix if (is2D()) { // if this does not work use strip.isMatrix
uint16_t vH = virtualHeight(); // segment height in logical pixels uint16_t vH = virtualHeight(); // segment height in logical pixels
uint16_t vW = virtualWidth(); uint16_t vW = virtualWidth();
switch (map1D2D) { switch (map1D2D) {
@ -589,10 +591,10 @@ void Segment::refreshLightCapabilities() {
* Fills segment with color * Fills segment with color
*/ */
void Segment::fill(uint32_t c) { void Segment::fill(uint32_t c) {
const uint16_t cols = strip.isMatrix ? virtualWidth() : virtualLength(); const uint16_t cols = is2D() ? virtualWidth() : virtualLength();
const uint16_t rows = virtualHeight(); // will be 1 for 1D const uint16_t rows = virtualHeight(); // will be 1 for 1D
for(uint16_t y = 0; y < rows; y++) for (uint16_t x = 0; x < cols; x++) { for(uint16_t y = 0; y < rows; y++) for (uint16_t x = 0; x < cols; x++) {
if (strip.isMatrix) setPixelColorXY(x, y, c); if (is2D()) setPixelColorXY(x, y, c);
else setPixelColor(x, c); else setPixelColor(x, c);
} }
} }
@ -611,7 +613,7 @@ void Segment::addPixelColor(uint16_t n, uint32_t color) {
* fade out function, higher rate = quicker fade * fade out function, higher rate = quicker fade
*/ */
void Segment::fade_out(uint8_t rate) { void Segment::fade_out(uint8_t rate) {
const uint16_t cols = strip.isMatrix ? virtualWidth() : virtualLength(); const uint16_t cols = is2D() ? virtualWidth() : virtualLength();
const uint16_t rows = virtualHeight(); // will be 1 for 1D const uint16_t rows = virtualHeight(); // will be 1 for 1D
rate = (255-rate) >> 1; rate = (255-rate) >> 1;
@ -624,7 +626,7 @@ void Segment::fade_out(uint8_t rate) {
int b2 = B(color); int b2 = B(color);
for (uint16_t y = 0; y < rows; y++) for (uint16_t x = 0; x < cols; x++) { for (uint16_t y = 0; y < rows; y++) for (uint16_t x = 0; x < cols; x++) {
color = strip.isMatrix ? getPixelColorXY(x, y) : getPixelColor(x); color = is2D() ? getPixelColorXY(x, y) : getPixelColor(x);
int w1 = W(color); int w1 = W(color);
int r1 = R(color); int r1 = R(color);
int g1 = G(color); int g1 = G(color);
@ -641,18 +643,18 @@ void Segment::fade_out(uint8_t rate) {
gdelta += (g2 == g1) ? 0 : (g2 > g1) ? 1 : -1; gdelta += (g2 == g1) ? 0 : (g2 > g1) ? 1 : -1;
bdelta += (b2 == b1) ? 0 : (b2 > b1) ? 1 : -1; bdelta += (b2 == b1) ? 0 : (b2 > b1) ? 1 : -1;
if (strip.isMatrix) setPixelColorXY(x, y, r1 + rdelta, g1 + gdelta, b1 + bdelta, w1 + wdelta); if (is2D()) setPixelColorXY(x, y, r1 + rdelta, g1 + gdelta, b1 + bdelta, w1 + wdelta);
else setPixelColor(x, r1 + rdelta, g1 + gdelta, b1 + bdelta, w1 + wdelta); else setPixelColor(x, r1 + rdelta, g1 + gdelta, b1 + bdelta, w1 + wdelta);
} }
} }
// fades all pixels to black using nscale8() // fades all pixels to black using nscale8()
void Segment::fadeToBlackBy(uint8_t fadeBy) { void Segment::fadeToBlackBy(uint8_t fadeBy) {
const uint16_t cols = strip.isMatrix ? virtualWidth() : virtualLength(); const uint16_t cols = is2D() ? virtualWidth() : virtualLength();
const uint16_t rows = virtualHeight(); // will be 1 for 1D const uint16_t rows = virtualHeight(); // will be 1 for 1D
for (uint16_t y = 0; y < rows; y++) for (uint16_t x = 0; x < cols; x++) { for (uint16_t y = 0; y < rows; y++) for (uint16_t x = 0; x < cols; x++) {
if (strip.isMatrix) setPixelColorXY(x, y, CRGB(getPixelColorXY(x,y)).nscale8(255-fadeBy)); if (is2D()) setPixelColorXY(x, y, CRGB(getPixelColorXY(x,y)).nscale8(255-fadeBy));
else setPixelColor(x, CRGB(getPixelColor(x)).nscale8(255-fadeBy)); else setPixelColor(x, CRGB(getPixelColor(x)).nscale8(255-fadeBy));
} }
} }
@ -662,7 +664,8 @@ void Segment::fadeToBlackBy(uint8_t fadeBy) {
*/ */
void Segment::blur(uint8_t blur_amount) void Segment::blur(uint8_t blur_amount)
{ {
if (strip.isMatrix) { #ifndef WLED_DISABLE_2D
if (is2D()) {
// compatibility with 2D // compatibility with 2D
const uint16_t cols = virtualWidth(); const uint16_t cols = virtualWidth();
const uint16_t rows = virtualHeight(); const uint16_t rows = virtualHeight();
@ -670,6 +673,7 @@ void Segment::blur(uint8_t blur_amount)
for (uint16_t k = 0; k < cols; k++) blurCol(k, blur_amount); // blur all columns for (uint16_t k = 0; k < cols; k++) blurCol(k, blur_amount); // blur all columns
return; return;
} }
#endif
uint8_t keep = 255 - blur_amount; uint8_t keep = 255 - blur_amount;
uint8_t seep = blur_amount >> 1; uint8_t seep = blur_amount >> 1;
CRGB carryover = CRGB::Black; CRGB carryover = CRGB::Black;
@ -844,25 +848,24 @@ void WS2812FX::service() {
if (!seg.getOption(SEG_OPTION_FREEZE)) { //only run effect function if not frozen if (!seg.getOption(SEG_OPTION_FREEZE)) { //only run effect function if not frozen
_virtualSegmentLength = seg.virtualLength(); _virtualSegmentLength = seg.virtualLength();
_bri_t = seg.currentBri(seg.getOption(SEG_OPTION_ON) ? seg.opacity : 0);
uint8_t _cct_t = seg.currentBri(seg.cct, true);
_colors_t[0] = seg.currentColor(0, seg.colors[0]); _colors_t[0] = seg.currentColor(0, seg.colors[0]);
_colors_t[1] = seg.currentColor(1, seg.colors[1]); _colors_t[1] = seg.currentColor(1, seg.colors[1]);
_colors_t[2] = seg.currentColor(2, seg.colors[2]); _colors_t[2] = seg.currentColor(2, seg.colors[2]);
seg.currentPalette(_currentPalette, seg.palette); seg.currentPalette(_currentPalette, seg.palette);
seg.handleTransition(); if (!cctFromRgb || correctWB) busses.setSegmentCCT(seg.currentBri(seg.cct, true), correctWB);
if (!cctFromRgb || correctWB) busses.setSegmentCCT(_cct_t, correctWB);
for (uint8_t c = 0; c < NUM_COLORS; c++) { for (uint8_t c = 0; c < NUM_COLORS; c++) {
_colors_t[c] = gamma32(_colors_t[c]); _colors_t[c] = gamma32(_colors_t[c]);
} }
seg.handleTransition();
// effect blending (execute previous effect) // effect blending (execute previous effect)
// actual code may be a bit more involved as effects have runtime data including allocated memory // actual code may be a bit more involved as effects have runtime data including allocated memory
//if (getOption(SEG_OPTION_TRANSITIONAL) && seg._modeP) (*_mode[seg._modeP])(progress()); //if (getOption(SEG_OPTION_TRANSITIONAL) && seg._modeP) (*_mode[seg._modeP])(progress());
delay = (*_mode[seg.mode])(); delay = (*_mode[seg.mode])();
if (seg.mode != FX_MODE_HALLOWEEN_EYES) seg.call++; if (seg.mode != FX_MODE_HALLOWEEN_EYES) seg.call++;
if (seg.transitional && delay > FRAMETIME) delay = FRAMETIME; // foce faster updates during transition
} }
seg.next_time = nowUp + delay; seg.next_time = nowUp + delay;