- defult transitions
- conditional 2D compile
This commit is contained in:
Blaz Kristan 2022-07-30 10:49:54 +02:00
parent 52b863fe36
commit b0ba1b2ecc
2 changed files with 21 additions and 4 deletions

View File

@ -1297,7 +1297,11 @@ void WS2812FX::restartRuntime() {
void WS2812FX::resetSegments() {
_segments.clear(); // destructs all Segment as part of clearing
#ifndef WLED_DISABLE_2D
segment seg = isMatrix ? Segment(0, matrixWidth, 0, matrixHeight) : Segment(0, _length);
#else
segment seg = Segment(0, _length);
#endif
_segments.push_back(seg);
_mainSegment = 0;
/*

View File

@ -187,6 +187,8 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
&& elem[F("c2")].isNull()
&& elem[F("c3")].isNull() )
{
int16_t sOpt;
uint8_t tmp = 255;
// compatibility mode begin
char buf[5]; // dummy buffer
for (int i=0; i<5; i++) {
@ -200,21 +202,32 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
}
extractModeSlider(fx, i, buf, 4, var);
}
extractModeSlider(fx, 255, buf, 4, &seg.palette);
extractModeSlider(fx, 255, buf, 4, &tmp);
if (tmp < strip.getPaletteCount() + strip.customPalettes.size()) {
if (tmp != seg.palette) {
if (strip.paletteBlend && !seg.transitional) seg.startTransition(strip.getTransition());
seg.palette = tmp;
}
}
//end compatibility mode
int16_t sOpt;
sOpt = extractModeDefaults(fx, SET_F("sx")); if (sOpt >= 0) seg.speed = sOpt;
sOpt = extractModeDefaults(fx, SET_F("ix")); if (sOpt >= 0) seg.intensity = sOpt;
sOpt = extractModeDefaults(fx, SET_F("c1")); if (sOpt >= 0) seg.custom1 = sOpt;
sOpt = extractModeDefaults(fx, SET_F("c2")); if (sOpt >= 0) seg.custom2 = sOpt;
sOpt = extractModeDefaults(fx, SET_F("c3")); if (sOpt >= 0) seg.custom3 = sOpt;
sOpt = extractModeDefaults(fx, "pal"); if (sOpt >= 0 && sOpt < strip.getPaletteCount()) seg.palette = sOpt;
sOpt = extractModeDefaults(fx, SET_F("mp12")); if (sOpt >= 0) seg.map1D2D = sOpt & 0x03;
sOpt = extractModeDefaults(fx, SET_F("ssim")); if (sOpt >= 0) seg.soundSim = sOpt & 0x07;
sOpt = extractModeDefaults(fx, "rev"); if (sOpt >= 0) seg.reverse = (bool)sOpt; // setOption(SEG_OPTION_REVERSED, (bool)sOpt); // NOTE: setting this option is a risky business
sOpt = extractModeDefaults(fx, SET_F("mi")); if (sOpt >= 0) seg.mirror = (bool)sOpt; // setOption(SEG_OPTION_MIRROR, (bool)sOpt); // NOTE: setting this option is a risky business
sOpt = extractModeDefaults(fx, SET_F("rY")); if (sOpt >= 0) seg.reverse_y = (bool)sOpt; // setOption(SEG_OPTION_REVERSED_Y, (bool)sOpt); // NOTE: setting this option is a risky business
sOpt = extractModeDefaults(fx, SET_F("mY")); if (sOpt >= 0) seg.mirror_y = (bool)sOpt; // setOption(SEG_OPTION_MIRROR_Y, (bool)sOpt); // NOTE: setting this option is a risky business
sOpt = extractModeDefaults(fx, "pal");
if (sOpt >= 0 && sOpt < strip.getPaletteCount() + strip.customPalettes.size()) {
if (sOpt != seg.palette) {
if (strip.paletteBlend && !seg.transitional) seg.startTransition(strip.getTransition());
seg.palette = sOpt;
}
}
}
}
}
@ -225,7 +238,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
uint8_t pal = seg.palette;
if (getVal(elem["pal"], &pal, 1, strip.getPaletteCount())) {
if (pal != seg.palette) {
if (strip.paletteBlend) seg.startTransition(strip.getTransition());
if (strip.paletteBlend && !seg.transitional) seg.startTransition(strip.getTransition());
seg.palette = pal;
}
}