Invalid FX bugfix.

This commit is contained in:
Blaz Kristan 2022-09-26 21:26:00 +02:00
parent 6306cfff96
commit dc700c41fb
4 changed files with 44 additions and 32 deletions

View File

@ -502,6 +502,8 @@ typedef struct Segment {
void setCCT(uint16_t k); void setCCT(uint16_t k);
void setOpacity(uint8_t o); void setOpacity(uint8_t o);
void setOption(uint8_t n, bool val); void setOption(uint8_t n, bool val);
void setMode(uint8_t fx, bool loadDefaults = false);
void setPalette(uint8_t pal);
uint8_t differs(Segment& b) const; uint8_t differs(Segment& b) const;
void refreshLightCapabilities(void); void refreshLightCapabilities(void);

View File

@ -396,6 +396,45 @@ void Segment::setOption(uint8_t n, bool val) {
else options &= ~(0x01 << n); else options &= ~(0x01 << n);
} }
void Segment::setMode(uint8_t fx, bool loadDefaults) {
if (fx < strip.getModeCount() && strncmp_P("RSVD", strip.getModeData(fx), 4)) {
if (fx != mode) {
startTransition(strip.getTransition()); // set effect transitions
//markForReset(); // transition will handle this
mode = fx;
// load default values from effect string
if (loadDefaults) {
int16_t sOpt;
sOpt = extractModeDefaults(fx, "sx"); if (sOpt >= 0) speed = sOpt;
sOpt = extractModeDefaults(fx, "ix"); if (sOpt >= 0) intensity = sOpt;
sOpt = extractModeDefaults(fx, "c1"); if (sOpt >= 0) custom1 = sOpt;
sOpt = extractModeDefaults(fx, "c2"); if (sOpt >= 0) custom2 = sOpt;
sOpt = extractModeDefaults(fx, "c3"); if (sOpt >= 0) custom3 = sOpt;
sOpt = extractModeDefaults(fx, "mp12"); if (sOpt >= 0) map1D2D = constrain(sOpt, 0, 7);
sOpt = extractModeDefaults(fx, "ssim"); if (sOpt >= 0) soundSim = constrain(sOpt, 0, 7);
sOpt = extractModeDefaults(fx, "rev"); if (sOpt >= 0) reverse = (bool)sOpt;
sOpt = extractModeDefaults(fx, "mi"); if (sOpt >= 0) mirror = (bool)sOpt; // NOTE: setting this option is a risky business
sOpt = extractModeDefaults(fx, "rY"); if (sOpt >= 0) reverse_y = (bool)sOpt;
sOpt = extractModeDefaults(fx, "mY"); if (sOpt >= 0) mirror_y = (bool)sOpt; // NOTE: setting this option is a risky business
sOpt = extractModeDefaults(fx, "pal");
if (sOpt >= 0 && (size_t)sOpt < strip.getPaletteCount() + strip.customPalettes.size()) {
if (sOpt != palette) {
palette = sOpt;
}
}
}
}
}
}
void Segment::setPalette(uint8_t pal) {
if (pal != palette) {
if (strip.paletteFade && !transitional) startTransition(strip.getTransition());
palette = pal;
}
}
// 2D matrix // 2D matrix
uint16_t Segment::virtualWidth() const { uint16_t Segment::virtualWidth() const {
uint16_t groupLen = groupLength(); uint16_t groupLen = groupLength();

View File

@ -175,33 +175,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
if (getVal(elem["fx"], &fx, 0, strip.getModeCount())) { //load effect ('r' random, '~' inc/dec, 0-255 exact value) if (getVal(elem["fx"], &fx, 0, strip.getModeCount())) { //load effect ('r' random, '~' inc/dec, 0-255 exact value)
if (!presetId && currentPlaylist>=0) unloadPlaylist(); if (!presetId && currentPlaylist>=0) unloadPlaylist();
if (fx != seg.mode) { if (fx != seg.mode) {
seg.startTransition(strip.getTransition()); // set effect transitions seg.setMode(fx, elem[F("fxdef")]);
//seg.markForReset();
seg.mode = fx;
}
}
// load default values from effect string
if (elem[F("fxdef")])
{
int16_t sOpt;
sOpt = extractModeDefaults(fx, "sx"); if (sOpt >= 0) seg.speed = sOpt;
sOpt = extractModeDefaults(fx, "ix"); if (sOpt >= 0) seg.intensity = sOpt;
sOpt = extractModeDefaults(fx, "c1"); if (sOpt >= 0) seg.custom1 = sOpt;
sOpt = extractModeDefaults(fx, "c2"); if (sOpt >= 0) seg.custom2 = sOpt;
sOpt = extractModeDefaults(fx, "c3"); if (sOpt >= 0) seg.custom3 = sOpt;
sOpt = extractModeDefaults(fx, "mp12"); if (sOpt >= 0) seg.map1D2D = constrain(sOpt, 0, 7);
sOpt = extractModeDefaults(fx, "ssim"); if (sOpt >= 0) seg.soundSim = constrain(sOpt, 0, 7);
sOpt = extractModeDefaults(fx, "rev"); if (sOpt >= 0) seg.reverse = (bool)sOpt;
sOpt = extractModeDefaults(fx, "mi"); if (sOpt >= 0) seg.mirror = (bool)sOpt; // NOTE: setting this option is a risky business
sOpt = extractModeDefaults(fx, "rY"); if (sOpt >= 0) seg.reverse_y = (bool)sOpt;
sOpt = extractModeDefaults(fx, "mY"); if (sOpt >= 0) seg.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.paletteFade && !seg.transitional) seg.startTransition(strip.getTransition());
seg.palette = sOpt;
}
} }
} }
@ -210,10 +184,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
getVal(elem["ix"], &seg.intensity); getVal(elem["ix"], &seg.intensity);
uint8_t pal = seg.palette; uint8_t pal = seg.palette;
if (getVal(elem["pal"], &pal, 1, strip.getPaletteCount())) { if (getVal(elem["pal"], &pal, 1, strip.getPaletteCount())) {
if (pal != seg.palette) { seg.setPalette(pal);
if (strip.paletteFade && !seg.transitional) seg.startTransition(strip.getTransition());
seg.palette = pal;
}
} }
getVal(elem["c1"], &seg.custom1); getVal(elem["c1"], &seg.custom1);
getVal(elem["c2"], &seg.custom2); getVal(elem["c2"], &seg.custom2);

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2209211 #define VERSION 2209261
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG