Merge branch '0_14' of https://github.com/aircoookie/WLED into merge-0_14

This commit is contained in:
Blaz Kristan 2022-09-29 15:53:51 +02:00
commit 8d372bee67
5 changed files with 19 additions and 25 deletions

View File

@ -114,8 +114,8 @@ class Animated_Staircase : public Usermod {
// We may need to copy mode and colors from segment 0 to make sure // We may need to copy mode and colors from segment 0 to make sure
// changes are propagated even when the config is changed during a wipe // changes are propagated even when the config is changed during a wipe
// segments->mode = mainsegment.mode; // seg.setMode(mainsegment.mode);
// segments->colors[0] = mainsegment.colors[0]; // seg.setColor(0, mainsegment.colors[0]);
} else { } else {
seg.setOption(SEG_OPTION_ON, false); seg.setOption(SEG_OPTION_ON, false);
} }

View File

@ -531,11 +531,11 @@ public:
for (byte i=0; i<strip.getSegmentsNum(); i++) { for (byte i=0; i<strip.getSegmentsNum(); i++) {
Segment& seg = strip.getSegment(i); Segment& seg = strip.getSegment(i);
if (!seg.isActive()) continue; if (!seg.isActive()) continue;
strip.setMode(i, effectCurrent); seg.setMode(effectCurrent);
} }
} else { } else {
//Segment& seg = strip.getSegment(strip.getMainSegmentId()); Segment& seg = strip.getSegment(strip.getMainSegmentId());
strip.setMode(strip.getMainSegmentId(), effectCurrent); seg.setMode(effectCurrent);
} }
lampUdated(); lampUdated();
#ifdef USERMOD_FOUR_LINE_DISPLAY #ifdef USERMOD_FOUR_LINE_DISPLAY
@ -661,11 +661,11 @@ public:
for (byte i=0; i<strip.getSegmentsNum(); i++) { for (byte i=0; i<strip.getSegmentsNum(); i++) {
Segment& seg = strip.getSegment(i); Segment& seg = strip.getSegment(i);
if (!seg.isActive()) continue; if (!seg.isActive()) continue;
seg.palette = effectPalette; seg.setPalette(effectPalette);
} }
} else { } else {
Segment& seg = strip.getSegment(strip.getMainSegmentId()); Segment& seg = strip.getSegment(strip.getMainSegmentId());
seg.palette = effectPalette; seg.setPalette(effectPalette);
} }
lampUdated(); lampUdated();
#ifdef USERMOD_FOUR_LINE_DISPLAY #ifdef USERMOD_FOUR_LINE_DISPLAY

View File

@ -397,6 +397,7 @@ void Segment::setOption(uint8_t n, bool val) {
} }
void Segment::setMode(uint8_t fx, bool loadDefaults) { void Segment::setMode(uint8_t fx, bool loadDefaults) {
// if we have a valid mode & is not reserved
if (fx < strip.getModeCount() && strncmp_P("RSVD", strip.getModeData(fx), 4)) { if (fx < strip.getModeCount() && strncmp_P("RSVD", strip.getModeData(fx), 4)) {
if (fx != mode) { if (fx != mode) {
startTransition(strip.getTransition()); // set effect transitions startTransition(strip.getTransition()); // set effect transitions
@ -429,10 +430,12 @@ void Segment::setMode(uint8_t fx, bool loadDefaults) {
} }
void Segment::setPalette(uint8_t pal) { void Segment::setPalette(uint8_t pal) {
if (pal < strip.getPaletteCount()) {
if (pal != palette) { if (pal != palette) {
if (strip.paletteFade && !transitional) startTransition(strip.getTransition()); if (strip.paletteFade) startTransition(strip.getTransition());
palette = pal; palette = pal;
} }
}
} }
// 2D matrix // 2D matrix

View File

@ -174,18 +174,16 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
byte fx = seg.mode; byte fx = seg.mode;
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.setMode(fx, elem[F("fxdef")]);
seg.setMode(fx, elem[F("fxdef")]);
}
} }
//getVal also supports inc/decrementing and random //getVal also supports inc/decrementing and random
getVal(elem["sx"], &seg.speed); getVal(elem["sx"], &seg.speed);
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())) seg.setPalette(pal);
seg.setPalette(pal);
}
getVal(elem["c1"], &seg.custom1); getVal(elem["c1"], &seg.custom1);
getVal(elem["c2"], &seg.custom2); getVal(elem["c2"], &seg.custom2);
uint8_t cust3 = seg.custom3; uint8_t cust3 = seg.custom3;

View File

@ -888,17 +888,10 @@ bool handleSet(AsyncWebServerRequest *request, const String& req, bool apply)
for (uint8_t i = 0; i < strip.getSegmentsNum(); i++) { for (uint8_t i = 0; i < strip.getSegmentsNum(); i++) {
Segment& seg = strip.getSegment(i); Segment& seg = strip.getSegment(i);
if (i != selectedSeg && (singleSegment || !seg.isActive() || !seg.isSelected())) continue; // skip non main segments if not applying to all if (i != selectedSeg && (singleSegment || !seg.isActive() || !seg.isSelected())) continue; // skip non main segments if not applying to all
if (fxModeChanged) { if (fxModeChanged) seg.setMode(effectIn, req.indexOf(F("FXD="))>0); // apply defaults if FXD= is specified
seg.startTransition(strip.getTransition());
seg.mode = effectIn;
// TODO: we should load defaults here as well
}
if (speedChanged) seg.speed = speedIn; if (speedChanged) seg.speed = speedIn;
if (intensityChanged) seg.intensity = intensityIn; if (intensityChanged) seg.intensity = intensityIn;
if (paletteChanged) { if (paletteChanged) seg.setPalette(paletteIn);
if (strip.paletteBlend) seg.startTransition(strip.getTransition());
seg.palette = paletteIn;
}
} }
//set advanced overlay //set advanced overlay