Default effect values.

This commit is contained in:
Blaz Kristan 2022-07-23 22:00:19 +02:00
parent d11ad39048
commit 8e9637f6d4
9 changed files with 1918 additions and 1901 deletions

View File

@ -3377,7 +3377,7 @@ uint16_t mode_exploding_fireworks(void)
return FRAMETIME;
}
#undef MAX_SPARKS
static const char *_data_FX_MODE_EXPLODING_FIREWORKS PROGMEM = "Fireworks 1D@Gravity,Firing side;!,!,;!";
static const char *_data_FX_MODE_EXPLODING_FIREWORKS PROGMEM = "Fireworks 1D@Gravity,Firing side=128;!,!,;!=11";
/*
@ -6257,7 +6257,7 @@ uint16_t mode_ripplepeak(void) { // * Ripple peak. By Andrew Tuli
return FRAMETIME;
} // mode_ripplepeak()
static const char *_data_FX_MODE_RIPPLEPEAK PROGMEM = " ♪ Ripple Peak@Fade rate,Max # of ripples,,Select bin,Volume (minimum)=0;!,!;!;mp12=0;ssim=1"; // Pixel, Beatsin
static const char *_data_FX_MODE_RIPPLEPEAK PROGMEM = " ♪ Ripple Peak@Fade rate,Max # of ripples,,Select bin,Volume (minimum)=0;!,!;!;mp12=0,ssim=1"; // Pixel, Beatsin
#ifndef WLED_DISABLE_2D
@ -6426,7 +6426,7 @@ uint16_t mode_gravcenter(void) { // Gravcenter. By Andrew Tuline.
return FRAMETIME;
} // mode_gravcenter()
static const char *_data_FX_MODE_GRAVCENTER PROGMEM = " ♪ Gravcenter@Rate of fall,Sensitivity=128;,!;!;mp12=2;ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_GRAVCENTER PROGMEM = " ♪ Gravcenter@Rate of fall,Sensitivity=128;,!;!;mp12=2,ssim=1"; // Circle, Beatsin
///////////////////////
@ -6480,7 +6480,7 @@ uint16_t mode_gravcentric(void) { // Gravcentric. By Andrew
return FRAMETIME;
} // mode_gravcentric()
static const char *_data_FX_MODE_GRAVCENTRIC PROGMEM = " ♪ Gravcentric@Rate of fall,Sensitivity=128;!;!;mp12=2;ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_GRAVCENTRIC PROGMEM = " ♪ Gravcentric@Rate of fall,Sensitivity=128;!;!;mp12=2,ssim=1"; // Circle, Beatsin
///////////////////////
@ -6530,7 +6530,7 @@ uint16_t mode_gravimeter(void) { // Gravmeter. By Andrew Tuline.
return FRAMETIME;
} // mode_gravimeter()
static const char *_data_FX_MODE_GRAVIMETER PROGMEM = " ♪ Gravimeter@Rate of fall,Sensitivity=128;,!;!;mp12=2;ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_GRAVIMETER PROGMEM = " ♪ Gravimeter@Rate of fall,Sensitivity=128;,!;!;mp12=2,ssim=1"; // Circle, Beatsin
#else
// This an abuse of the gravimeter effect for AGC debugging
// instead of sound volume, it uses the AGC gain multiplier as input
@ -6596,7 +6596,7 @@ uint16_t mode_gravimeter(void) { // Gravmeter. By Andrew Tuline.
return FRAMETIME;
} // mode_gravimeter()
static const char *_data_FX_MODE_GRAVIMETER PROGMEM = " ♪ Gravimeter@Rate of fall,Sensitivity=128,Input level=128;,!;!;mp12=2;ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_GRAVIMETER PROGMEM = " ♪ Gravimeter@Rate of fall,Sensitivity=128,Input level=128;,!;!;mp12=2,ssim=1"; // Circle, Beatsin
#endif
@ -6620,7 +6620,7 @@ uint16_t mode_juggles(void) { // Juggles. By Andrew Tuline.
return FRAMETIME;
} // mode_juggles()
static const char *_data_FX_MODE_JUGGLES PROGMEM = " ♪ Juggles@!,# of balls;,!;!;mp12=0;ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_JUGGLES PROGMEM = " ♪ Juggles@!,# of balls;,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
//////////////////////
@ -6650,7 +6650,7 @@ uint16_t mode_matripix(void) { // Matripix. By Andrew Tuline.
return FRAMETIME;
} // mode_matripix()
static const char *_data_FX_MODE_MATRIPIX PROGMEM = " ♪ Matripix@!,Brightness=64;,!;!;mp12=2;ssim=2;rev=1"; // Circle, WeWillRockYou, reverseX
static const char *_data_FX_MODE_MATRIPIX PROGMEM = " ♪ Matripix@!,Brightness=64;,!;!;mp12=2,ssim=2,rev=1,mi=1,rY=1,mY=1"; // Circle, WeWillRockYou, reverseX
//////////////////////
@ -6688,7 +6688,7 @@ uint16_t mode_midnoise(void) { // Midnoise. By Andrew Tuline.
return FRAMETIME;
} // mode_midnoise()
static const char *_data_FX_MODE_MIDNOISE PROGMEM = " ♪ Midnoise@Fade rate,Maximum length=128;,!;!;mp12=2;ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_MIDNOISE PROGMEM = " ♪ Midnoise@Fade rate,Maximum length=128;,!;!;mp12=2,ssim=1"; // Circle, Beatsin
//////////////////////
@ -6722,7 +6722,7 @@ uint16_t mode_noisefire(void) { // Noisefire. By Andrew Tuline.
return FRAMETIME;
} // mode_noisefire()
static const char *_data_FX_MODE_NOISEFIRE PROGMEM = " ♪ Noisefire@!,!;;;mp12=2;ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_NOISEFIRE PROGMEM = " ♪ Noisefire@!,!;;;mp12=2,ssim=1"; // Circle, Beatsin
///////////////////////
@ -6760,7 +6760,7 @@ uint16_t mode_noisemeter(void) { // Noisemeter. By Andrew Tuline.
return FRAMETIME;
} // mode_noisemeter()
static const char *_data_FX_MODE_NOISEMETER PROGMEM = " ♪ Noisemeter@Fade rate,Width=128;!,!;!;mp12=2;ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_NOISEMETER PROGMEM = " ♪ Noisemeter@Fade rate,Width=128;!,!;!;mp12=2,ssim=1"; // Circle, Beatsin
//////////////////////
@ -6793,7 +6793,7 @@ uint16_t mode_pixelwave(void) { // Pixelwave. By Andrew Tuline.
return FRAMETIME;
} // mode_pixelwave()
static const char *_data_FX_MODE_PIXELWAVE PROGMEM = " ♪ Pixelwave@!,Sensitivity=64;!,!;!;mp12=2;ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_PIXELWAVE PROGMEM = " ♪ Pixelwave@!,Sensitivity=64;!,!;!;mp12=2,ssim=1"; // Circle, Beatsin
//////////////////////
@ -6837,7 +6837,7 @@ uint16_t mode_plasmoid(void) { // Plasmoid. By Andrew Tuline.
return FRAMETIME;
} // mode_plasmoid()
static const char *_data_FX_MODE_PLASMOID PROGMEM = " ♪ Plasmoid@Phase=128,# of pixels=128;,!;!;mp12=0;ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_PLASMOID PROGMEM = " ♪ Plasmoid@Phase=128,# of pixels=128;,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
///////////////////////
@ -6881,7 +6881,7 @@ uint16_t mode_puddlepeak(void) { // Puddlepeak. By Andrew Tuline.
return FRAMETIME;
} // mode_puddlepeak()
static const char *_data_FX_MODE_PUDDLEPEAK PROGMEM = " ♪ Puddlepeak@Fade rate,Puddle size,,Select bin,Volume (minimum)=0;!,!;!;mp12=0;ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_PUDDLEPEAK PROGMEM = " ♪ Puddlepeak@Fade rate,Puddle size,,Select bin,Volume (minimum)=0;!,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
//////////////////////
@ -6916,7 +6916,7 @@ uint16_t mode_puddles(void) { // Puddles. By Andrew Tuline.
return FRAMETIME;
} // mode_puddles()
static const char *_data_FX_MODE_PUDDLES PROGMEM = " ♪ Puddles@Fade rate,Puddle size;!,!;!;mp12=0;ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_PUDDLES PROGMEM = " ♪ Puddles@Fade rate,Puddle size;!,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
///////////////////////////////////////////////////////////////////////////////
@ -6946,7 +6946,7 @@ uint16_t mode_pixels(void) { // Pixels. By Andrew Tuline.
return FRAMETIME;
} // mode_pixels()
static const char *_data_FX_MODE_PIXELS PROGMEM = " ♪ Pixels@Fade rate,# of pixels;,!;!;mp12=0;ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_PIXELS PROGMEM = " ♪ Pixels@Fade rate,# of pixels;,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
///////////////////////////////
@ -7028,9 +7028,9 @@ uint16_t mode_binmap(void) {
return FRAMETIME;
} // mode_binmap()
#ifdef SR_DEBUG
static const char *_data_FX_MODE_BINMAP PROGMEM = " ♫ Binmap@,,Input level=128,,Max vol;!,!;!;mp12=0;ssim=1;rY=true"; // Pixels, Beatsin, ReverseY
static const char *_data_FX_MODE_BINMAP PROGMEM = " ♫ Binmap@,,Input level=128,,Max vol;!,!;!;mp12=0,ssim=1,rY=1"; // Pixels, Beatsin, ReverseY
#else
static const char *_data_FX_MODE_BINMAP PROGMEM = " ♫ Binmap@,,Input level=128;!,!;!;mp12=0;ssim=1;rY=true"; // Pixels, Beatsin, ReverseY
static const char *_data_FX_MODE_BINMAP PROGMEM = " ♫ Binmap@,,Input level=128;!,!;!;mp12=0,ssim=1,rY=1"; // Pixels, Beatsin, ReverseY
#endif
//////////////////////
@ -7060,7 +7060,7 @@ uint16_t mode_blurz(void) { // Blurz. By Andrew Tuline.
return FRAMETIME;
} // mode_blurz()
static const char *_data_FX_MODE_BLURZ PROGMEM = " ♫ Blurz@Fade rate,Blur amount;!,Color mix;!;mp12=0;ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_BLURZ PROGMEM = " ♫ Blurz@Fade rate,Blur amount;!,Color mix;!;mp12=0,ssim=1"; // Pixels, Beatsin
/////////////////////////
@ -7097,7 +7097,7 @@ uint16_t mode_DJLight(void) { // Written by ??? Adapted by Wil
return FRAMETIME;
} // mode_DJLight()
static const char *_data_FX_MODE_DJLIGHT PROGMEM = " ♫ DJ Light@Speed;;;mp12=2;ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_DJLIGHT PROGMEM = " ♫ DJ Light@Speed;;;mp12=2,ssim=1"; // Circle, Beatsin
////////////////////
@ -7134,7 +7134,7 @@ uint16_t mode_freqmap(void) { // Map FFT_MajorPeak to SEGLEN.
return FRAMETIME;
} // mode_freqmap()
static const char *_data_FX_MODE_FREQMAP PROGMEM = " ♫ Freqmap@Fade rate,Starting color;,!;!;mp12=2;ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_FREQMAP PROGMEM = " ♫ Freqmap@Fade rate,Starting color;,!;!;mp12=2,ssim=1"; // Circle, Beatsin
///////////////////////
@ -7184,7 +7184,7 @@ uint16_t mode_freqmatrix(void) { // Freqmatrix. By Andreas Plesch
return FRAMETIME;
} // mode_freqmatrix()
static const char *_data_FX_MODE_FREQMATRIX PROGMEM = " ♫ Freqmatrix@Time delay,Sound effect,Low bin,High bin,Sensivity;;;mp12=0;ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_FREQMATRIX PROGMEM = " ♫ Freqmatrix@Time delay,Sound effect,Low bin,High bin,Sensivity;;;mp12=0,ssim=1"; // Pixels, Beatsin
//////////////////////
@ -7220,7 +7220,7 @@ uint16_t mode_freqpixels(void) { // Freqpixel. By Andrew Tuline.
return FRAMETIME;
} // mode_freqpixels()
static const char *_data_FX_MODE_FREQPIXELS PROGMEM = " ♫ Freqpixels@Fade rate,Starting colour and # of pixels;;;mp12=0;ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_FREQPIXELS PROGMEM = " ♫ Freqpixels@Fade rate,Starting colour and # of pixels;;;mp12=0,ssim=1"; // Pixels, Beatsin
//////////////////////
@ -7291,7 +7291,7 @@ uint16_t mode_freqwave(void) { // Freqwave. By Andreas Pleschun
return FRAMETIME;
} // mode_freqwave()
static const char *_data_FX_MODE_FREQWAVE PROGMEM = " ♫ Freqwave@Time delay,Sound effect,Low bin,High bin,Pre-amp;;;mp12=2;ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_FREQWAVE PROGMEM = " ♫ Freqwave@Time delay,Sound effect,Low bin,High bin,Pre-amp;;;mp12=2,ssim=1"; // Circle, Beatsin
///////////////////////
@ -7344,7 +7344,7 @@ uint16_t mode_gravfreq(void) { // Gravfreq. By Andrew Tuline.
return FRAMETIME;
} // mode_gravfreq()
static const char *_data_FX_MODE_GRAVFREQ PROGMEM = " ♫ Gravfreq@Rate of fall,Sensivity=128;,!;!;mp12=2;ssim=1"; // Circle, Beatsin
static const char *_data_FX_MODE_GRAVFREQ PROGMEM = " ♫ Gravfreq@Rate of fall,Sensivity=128;,!;!;mp12=2,ssim=1"; // Circle, Beatsin
//////////////////////
@ -7370,7 +7370,7 @@ uint16_t mode_noisemove(void) { // Noisemove. By: Andrew Tuli
return FRAMETIME;
} // mode_noisemove()
static const char *_data_FX_MODE_NOISEMOVE PROGMEM = " ♫ Noisemove@Speed of perlin movement,Fade rate;,!;!;mp12=0;ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_NOISEMOVE PROGMEM = " ♫ Noisemove@Speed of perlin movement,Fade rate;,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
//////////////////////
@ -7414,7 +7414,7 @@ uint16_t mode_rocktaves(void) { // Rocktaves. Same note from eac
return FRAMETIME;
} // mode_rocktaves()
static const char *_data_FX_MODE_ROCKTAVES PROGMEM = " ♫ Rocktaves@;,!;!;mp12=0;ssim=1"; // Pixels, Beatsin
static const char *_data_FX_MODE_ROCKTAVES PROGMEM = " ♫ Rocktaves@;,!;!;mp12=0,ssim=1"; // Pixels, Beatsin
///////////////////////
@ -7467,7 +7467,7 @@ uint16_t mode_waterfall(void) { // Waterfall. By: Andrew Tulin
return FRAMETIME;
} // mode_waterfall()
static const char *_data_FX_MODE_WATERFALL PROGMEM = " ♫ Waterfall@!,Adjust color,,Select bin, Volume (minimum)=0;!,!;!;mp12=2;ssim=1"; // Circles, Beatsin
static const char *_data_FX_MODE_WATERFALL PROGMEM = " ♫ Waterfall@!,Adjust color,,Select bin, Volume (minimum)=0;!,!;!;mp12=2,ssim=1"; // Circles, Beatsin
#ifndef WLED_DISABLE_2D

View File

@ -405,7 +405,7 @@ uint32_t Segment::getPixelColor(uint16_t i)
{
#ifndef WLED_DISABLE_2D
if (height() > 1) { // 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();
switch (map1D2D) {
case M12_Pixels:

View File

@ -369,7 +369,7 @@ button {
#sliders {
width: 300px;
margin: 0 auto;
margin: 32px auto 0;
position: sticky;
bottom: 0;
}

View File

@ -5,10 +5,10 @@ var isOn = false, nlA = false, isLv = false, isInfo = false, isNodes = false, sy
var hasWhite = false, hasRGB = false, hasCCT = false;
var nlDur = 60, nlTar = 0;
var nlMode = false;
var selectedFx = 0, prevFx = -1;
var selectedFx = 0;
var selectedPal = 0;
var csel = 0; // selected color slot (0-2)
var currentPreset = -1, prevPS = -1;
var currentPreset = -1;
var lastUpdate = 0;
var segCount = 0, ledCount = 0, lowestUnused = 0, maxSeg = 0, lSeg = 0;
var pcMode = false, pcModeA = false, lastw = 0, wW;
@ -1137,10 +1137,7 @@ function updateSelectedFx()
var selectedEffect = parent.querySelector(`.lstI[data-id="${selectedFx}"]`);
if (selectedEffect) {
selectedEffect.classList.add('selected');
var fx = (selectedFx != prevFx) && currentPreset==-1; // effect changed & preset==none
var ps = (prevPS != currentPreset) && currentPreset==-1; // preset changed & preset==none
// WLEDSR: extract the Slider and color control string from the HTML element and set it.
setEffectParameters(selectedFx, (fx || ps));
setEffectParameters(selectedFx);
var selectedName = selectedEffect.querySelector(".lstIname").innerText;
var segs = gId("segcont").querySelectorAll(`div[data-map="map2D"]`);
@ -1218,7 +1215,6 @@ function readState(s,command=false)
nlTar = s.nl.tbri;
nlFade = s.nl.fade;
syncSend = s.udpn.send;
prevPS = currentPreset;
if (s.pl<0) currentPreset = s.ps;
else currentPreset = s.pl;
@ -1296,7 +1292,6 @@ function readState(s,command=false)
showToast('Error ' + s.error + ": " + errstr, true);
}
prevFx = selectedFx;
selectedPal = i.pal;
selectedFx = i.fx;
redrawPalPrev(); // if any color changed (random palette did at least)
@ -1325,7 +1320,7 @@ function readState(s,command=false)
// Note: Effects can override default pattern behaviour
// - FadeToBlack can override the background setting
// - Defining SEGCOL(<i>) can override a specific palette using these values (e.g. Color Gradient)
function setEffectParameters(idx, applyDef=false)
function setEffectParameters(idx)
{
if (!(Array.isArray(fxdata) && fxdata.length>idx)) return;
var controlDefined = (fxdata[idx].substr(0,1) == "@");
@ -1334,14 +1329,6 @@ function setEffectParameters(idx, applyDef=false)
var slOnOff = (effectPars.length==0 || effectPars[0]=='')?[]:effectPars[0].split(",");
var coOnOff = (effectPars.length<2 || effectPars[1]=='')?[]:effectPars[1].split(",");
var paOnOff = (effectPars.length<3 || effectPars[2]=='')?[]:effectPars[2].split(",");
var obj = {"seg":{}};
// var obj = {"seg": {"rev": false, "rY": false}};
//assign extra parameters to segment
for (let i=3;i<effectPars.length;i++) {
let keyval = effectPars[i].split("=");
obj.seg[keyval[0]] = keyval[1]=="true"?true:keyval[1]=="false"?false:keyval[1];
}
// set html slider items on/off
var nSliders = Math.min(5,Math.floor(gId("sliders").children.length)); // div for each slider
@ -1354,10 +1341,6 @@ function setEffectParameters(idx, applyDef=false)
if (slOnOff.length>i && slOnOff[i].indexOf("=")>0) {
// embeded default values
var dPos = slOnOff[i].indexOf("=");
var v = Math.max(0,Math.min(255,parseInt(slOnOff[i].substr(dPos+1))));
if (i==0) { if (applyDef) gId("sliderSpeed").value = v; obj.seg.sx = v; }
else if (i==1) { if (applyDef) gId("sliderIntensity").value = v; obj.seg.ix = v; }
else { if (applyDef) gId("sliderC"+(i-1)).value = v; obj.seg["c"+(i-1)] = v}
slOnOff[i] = slOnOff[i].substring(0,dPos);
}
if (slOnOff.length>i && slOnOff[i]!="!") label.innerHTML = slOnOff[i];
@ -1365,18 +1348,15 @@ function setEffectParameters(idx, applyDef=false)
else if (i==1) label.innerHTML = "Effect intensity";
else label.innerHTML = "Custom" + (i-1);
sldCnt++;
//if (sldCnt++===0) slider.classList.add("top");
slider.classList.remove("hide");
//slider.setAttribute('title',label.innerHTML);
} else {
slider.classList.add("hide");
//slider.classList.remove("top");
}
}
// set the bottom position of selected effect (sticky) as the top of sliders div
let top = parseInt(getComputedStyle(gId("sliders")).height);
/*if (sldCnt===1)*/ top += 28; // size of tooltip
top += 28; // size of tooltip
let sel = d.querySelector('#fxlist .selected');
if (sel) sel.style.bottom = top + "px"; // we will need to remove this when unselected (in setX())
@ -1426,11 +1406,6 @@ function setEffectParameters(idx, applyDef=false)
// embeded default values
var dPos = paOnOff[0].indexOf("=");
var v = Math.max(0,Math.min(255,parseInt(paOnOff[0].substr(dPos+1))));
var p = d.querySelector(`#pallist input[name="palette"][value="${v}"]`);
if (applyDef && p) {
p.checked = true;
obj.seg.pal = v;
}
paOnOff[0] = paOnOff[0].substring(0,dPos);
}
if (paOnOff.length>0 && paOnOff[0] != "!") pall.innerHTML = paOnOff[0];
@ -1439,14 +1414,11 @@ function setEffectParameters(idx, applyDef=false)
// disable palett list
pall.innerHTML = '<i class="icons sel-icon" onclick="tglHex()">&#xe2b3;</i> Color palette not used';
palw.style.display = "none";
// if numeric set as selected palette
if (paOnOff.length>0 && paOnOff[0]!="" && !isNaN(paOnOff[0]) && parseInt(paOnOff[0])!=selectedPal) obj.seg.pal = parseInt(paOnOff[0]);
}
// not all color selectors shown, hide palettes created from color selectors
for (let e of (gId('pallist').querySelectorAll('.lstI')||[])) {
if (cslCnt < 3 && e.querySelector('.lstIname').innerText.indexOf("* C")>=0) e.classList.add('hide'); else e.classList.remove('hide');
}
if (!isEmpty(obj.seg) && applyDef) requestJson(obj); // update default values (may need throttling on ESP8266)
}
var jsonTimeout;
@ -2063,11 +2035,13 @@ function setPalette(paletteId = null)
} else {
d.querySelector(`#pallist input[name="palette"][value="${paletteId}"]`).checked = true;
}
/*
var selElement = d.querySelector('#pallist .selected');
if (selElement) {
selElement.classList.remove('selected')
}
d.querySelector(`#pallist .lstI[data-id="${paletteId}"]`).classList.add('selected');
*/
var obj = {"seg": {"pal": paletteId}};
requestJson(obj);
}

View File

@ -324,7 +324,8 @@ bool isAsterisksOnly(const char* str, byte maxLen);
bool requestJSONBufferLock(uint8_t module=255);
void releaseJSONBufferLock();
uint8_t extractModeName(uint8_t mode, const char *src, char *dest, uint8_t maxLen);
uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxLen);
uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxLen, uint8_t *var = nullptr);
int16_t extractModeDefaults(uint8_t mode, const char *segVar);
uint16_t crc16(const unsigned char* data_p, size_t length);
//wled_eeprom.cpp

File diff suppressed because it is too large Load Diff

View File

@ -162,11 +162,10 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
}
#endif
seg.setOption(SEG_OPTION_SELECTED, elem[F("sel")] | seg.getOption(SEG_OPTION_SELECTED));
seg.setOption(SEG_OPTION_REVERSED, elem["rev"] | seg.getOption(SEG_OPTION_REVERSED));
seg.setOption(SEG_OPTION_MIRROR , elem[F("mi")] | seg.getOption(SEG_OPTION_MIRROR ));
seg.setOption(SEG_OPTION_SELECTED, elem["sel"] | seg.getOption(SEG_OPTION_SELECTED));
seg.setOption(SEG_OPTION_REVERSED, elem["rev"] | seg.getOption(SEG_OPTION_REVERSED));
seg.setOption(SEG_OPTION_MIRROR , elem[F("mi")] | seg.getOption(SEG_OPTION_MIRROR ));
#ifndef WLED_DISABLE_2D
// 2D options
seg.setOption(SEG_OPTION_REVERSED_Y, elem[F("rY")] | seg.getOption(SEG_OPTION_REVERSED_Y));
seg.setOption(SEG_OPTION_MIRROR_Y , elem[F("mY")] | seg.getOption(SEG_OPTION_MIRROR_Y ));
seg.setOption(SEG_OPTION_TRANSPOSED, elem[F("tp")] | seg.getOption(SEG_OPTION_TRANSPOSED));
@ -178,10 +177,35 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
strip.setMode(id, fx);
}
// load default values from effect string if effect is selected without
// any other effect parameter (i.e. effect clicked in UI)
if (elem[F("sx")].isNull() && elem[F("ix")].isNull() && elem["pal"].isNull() && elem[F("c1")].isNull() && elem[F("c2")].isNull() && elem[F("c3")].isNull()) {
char buf[5]; // dummy buffer
for (int i=0; i<5; i++) {
uint8_t *var;
switch (i) {
case 0: var = &seg.speed; break;
case 1: var = &seg.intensity; break;
case 2: var = &seg.custom1; break;
case 3: var = &seg.custom2; break;
case 4: var = &seg.custom3; break;
}
extractModeSlider(fx, i, buf, 4, var);
}
extractModeSlider(fx, 255, buf, 4, &seg.palette);
int16_t 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.setOption(SEG_OPTION_REVERSED, (bool)sOpt);
sOpt = extractModeDefaults(fx, SET_F("mi")); if (sOpt >= 0) seg.setOption(SEG_OPTION_MIRROR, (bool)sOpt);
sOpt = extractModeDefaults(fx, SET_F("rY")); if (sOpt >= 0) seg.setOption(SEG_OPTION_REVERSED_Y, (bool)sOpt);
sOpt = extractModeDefaults(fx, SET_F("mY")); if (sOpt >= 0) seg.setOption(SEG_OPTION_MIRROR_Y, (bool)sOpt);
}
//getVal also supports inc/decrementing and random
getVal(elem[F("sx")], &seg.speed);
getVal(elem[F("ix")], &seg.intensity);
getVal(elem["pal"], &seg.palette, 1, strip.getPaletteCount());
getVal(elem["pal"], &seg.palette, 1, strip.getPaletteCount());
getVal(elem[F("c1")], &seg.custom1);
getVal(elem[F("c2")], &seg.custom2);
getVal(elem[F("c3")], &seg.custom3);

View File

@ -281,7 +281,7 @@ uint8_t extractModeName(uint8_t mode, const char *src, char *dest, uint8_t maxLe
// extracts effect slider data (1st group after @)
uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxLen)
uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxLen, uint8_t *var)
{
dest[0] = '\0'; // start by clearing buffer
@ -291,30 +291,48 @@ uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxL
int16_t start = lineBuffer.indexOf('@');
int16_t stop = lineBuffer.indexOf(';', start);
if (start>0 && stop>0) {
String names = lineBuffer.substring(start+1, stop);
int16_t nameBegin = 0, nameEnd;
for (size_t i=0; i<=slider; i++) {
const char *tmpstr;
dest[0] = '\0'; //clear dest buffer
if (i > 0 && nameBegin == 0) break; // there are no more names
nameEnd = names.indexOf(',', nameBegin);
if (names.charAt(nameBegin) == '!') {
switch (i) {
case 0: tmpstr = PSTR("FX Speed"); break;
case 1: tmpstr = PSTR("FX Intensity"); break;
case 2: tmpstr = PSTR("FX Custom 1"); break;
case 3: tmpstr = PSTR("FX Custom 2"); break;
case 4: tmpstr = PSTR("FX Custom 3"); break;
default: tmpstr = PSTR("FX Custom"); break;
String names = lineBuffer.substring(start, stop); // include @
int16_t nameBegin = 1, nameEnd, nameDefault;
if (slider < 10) {
for (size_t i=0; i<=slider; i++) {
const char *tmpstr;
dest[0] = '\0'; //clear dest buffer
if (nameBegin == 0) break; // there are no more names
nameEnd = names.indexOf(',', nameBegin);
if (i == slider) {
nameDefault = names.indexOf('=', nameBegin); // find default value
if (nameDefault > 0 && var && ((nameEnd>0 && nameDefault<nameEnd) || nameEnd<0)) {
*var = (uint8_t)atoi(names.substring(nameDefault+1).c_str());
}
if (names.charAt(nameBegin) == '!') {
switch (slider) {
case 0: tmpstr = PSTR("FX Speed"); break;
case 1: tmpstr = PSTR("FX Intensity"); break;
case 2: tmpstr = PSTR("FX Custom 1"); break;
case 3: tmpstr = PSTR("FX Custom 2"); break;
case 4: tmpstr = PSTR("FX Custom 3"); break;
default: tmpstr = PSTR("FX Custom"); break;
}
} else {
if (nameEnd<0) tmpstr = names.substring(nameBegin).c_str(); // did not find ",", last name?
else tmpstr = names.substring(nameBegin, nameEnd).c_str();
}
strlcpy(dest, tmpstr, maxLen); // copy the name into buffer (replacing previous)
}
nameBegin = nameEnd+1; // next name (if "," is not found it will be 0)
} // next slider
} else if (slider == 255) {
// palette
strlcpy(dest, "pal", maxLen);
names = lineBuffer.substring(stop+1); // stop has index of color slot names
nameBegin = names.indexOf(';'); // look for palette
if (nameBegin >= 0) {
if (!isdigit(names[nameBegin+1])) nameBegin = names.indexOf('=', nameBegin+1); // look for default value
if (nameBegin >= 0 && var) {
*var = (uint8_t)atoi(names.substring(nameBegin+1).c_str());
}
} else {
if (nameEnd<0) tmpstr = names.substring(nameBegin).c_str(); // did not find ",", last name?
else tmpstr = names.substring(nameBegin, nameEnd).c_str();
}
strncpy(dest, tmpstr, maxLen); // copy the name into buffer (replacing previous)
nameBegin = nameEnd+1; // next name (if "," is not found it will be 0)
} // next slider
}
// we have slider name (including default value) in the dest buffer
for (size_t i=0; i<strlen(dest); i++) if (dest[i]=='=') { dest[i]='\0'; break; } // truncate default value
@ -324,6 +342,7 @@ uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxL
case 0: strncpy_P(dest, PSTR("FX Speed"), maxLen); break;
case 1: strncpy_P(dest, PSTR("FX Intensity"), maxLen); break;
}
dest[maxLen] = '\0'; // strncpy does not necessarily null terminate string
}
}
return strlen(dest);
@ -332,6 +351,23 @@ uint8_t extractModeSlider(uint8_t mode, uint8_t slider, char *dest, uint8_t maxL
}
int16_t extractModeDefaults(uint8_t mode, const char *segVar)
{
if (mode < strip.getModeCount()) {
String lineBuffer = strip.getModeData(mode);
if (lineBuffer.length() > 0) {
int16_t start = lineBuffer.lastIndexOf(';');
if (start<0) return -1;
int16_t stop = lineBuffer.indexOf(segVar, start+1);
if (stop<0) return -1;
return atoi(lineBuffer.substring(stop+strlen(segVar)+1).c_str());
}
}
return -1;
}
uint16_t crc16(const unsigned char* data_p, size_t length) {
uint8_t x;
uint16_t crc = 0xFFFF;

View File

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