@@ -223,30 +223,17 @@ bool deserializeSegment(JsonObject elem, byte it, byte presetId)
223223 #endif
224224
225225 byte fx = seg.mode ;
226- byte last = strip.getModeCount ();
227- // partial fix for #3605
228- if (!elem[" fx" ].isNull () && elem[" fx" ].is <const char *>()) {
229- const char *tmp = elem[" fx" ].as <const char *>();
230- if (strlen (tmp) > 3 && (strchr (tmp,' r' ) || strchr (tmp,' ~' ) != strrchr (tmp,' ~' ))) last = 0 ; // we have "X~Y(r|[w]~[-])" form
231- }
232- // end fix
233- if (getVal (elem[" fx" ], &fx, 0 , last)) { // load effect ('r' random, '~' inc/dec, 0-255 exact value, 5~10r pick random between 5 & 10)
226+ if (getVal (elem[" fx" ], &fx, 0 , strip.getModeCount ())) {
234227 if (!presetId && currentPlaylist>=0 ) unloadPlaylist ();
235228 if (fx != seg.mode ) seg.setMode (fx, elem[F (" fxdef" )]);
236229 }
237230
238- // getVal also supports inc/decrementing and random
239231 getVal (elem[" sx" ], &seg.speed );
240232 getVal (elem[" ix" ], &seg.intensity );
241233
242234 uint8_t pal = seg.palette ;
243- last = strip.getPaletteCount ();
244- if (!elem[" pal" ].isNull () && elem[" pal" ].is <const char *>()) {
245- const char *tmp = elem[" pal" ].as <const char *>();
246- if (strlen (tmp) > 3 && (strchr (tmp,' r' ) || strchr (tmp,' ~' ) != strrchr (tmp,' ~' ))) last = 0 ; // we have "X~Y(r|[w]~[-])" form
247- }
248235 if (seg.getLightCapabilities () & 1 ) { // ignore palette for White and On/Off segments
249- if (getVal (elem[" pal" ], &pal, 0 , last )) seg.setPalette (pal);
236+ if (getVal (elem[" pal" ], &pal, 0 , strip. getPaletteCount () )) seg.setPalette (pal);
250237 }
251238
252239 getVal (elem[" c1" ], &seg.custom1 );
@@ -467,7 +454,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
467454 DEBUG_PRINTF_P (PSTR (" Preset direct: %d\n " ), currentPreset);
468455 } else if (!root[" ps" ].isNull ()) {
469456 // we have "ps" call (i.e. from button or external API call) or "pd" that includes "ps" (i.e. from UI call)
470- if (root[" win" ].isNull () && getVal (root[" ps" ], &presetCycCurr, 0 , 0 ) && presetCycCurr > 0 && presetCycCurr < 251 && presetCycCurr != currentPreset) {
457+ if (root[" win" ].isNull () && getVal (root[" ps" ], &presetCycCurr, 1 , 250 ) && presetCycCurr > 0 && presetCycCurr < 251 && presetCycCurr != currentPreset) {
471458 DEBUG_PRINTF_P (PSTR (" Preset select: %d\n " ), presetCycCurr);
472459 // b) preset ID only or preset that does not change state (use embedded cycling limits if they exist in getVal())
473460 applyPreset (presetCycCurr, callMode); // async load from file system (only preset ID was specified)
0 commit comments