Segment names fixes.

Minor UI changes:
 - new font
 - removed transition
This commit is contained in:
Blaz Kristan 2021-09-18 13:15:19 +02:00
parent 56167f84ad
commit bc6652f443
9 changed files with 2269 additions and 2312 deletions

View File

@ -2909,7 +2909,7 @@ uint16_t WS2812FX::mode_starburst(void) {
uint16_t WS2812FX::mode_exploding_fireworks(void) uint16_t WS2812FX::mode_exploding_fireworks(void)
{ {
//allocate segment data //allocate segment data
uint16_t numSparks = min(2 + (SEGLEN >> 2), MAX_SPARKS); // max 58 for 32 segment ESP32, 20 for 16 segment ESP8266 uint16_t numSparks = min(2 + (SEGLEN >> 1), MAX_SPARKS); // max 58 for 32 segment ESP32, 20 for 16 segment ESP8266
uint16_t dataSize = sizeof(spark) * numSparks; uint16_t dataSize = sizeof(spark) * numSparks;
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed

View File

@ -568,6 +568,10 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping,
if (i2 <= i1) //disable segment if (i2 <= i1) //disable segment
{ {
seg.stop = 0; seg.stop = 0;
if (seg.name) {
delete[] seg.name;
seg.name = nullptr;
}
if (n == mainSegment) //if main segment is deleted, set first active as main segment if (n == mainSegment) //if main segment is deleted, set first active as main segment
{ {
for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++) for (uint8_t i = 0; i < MAX_NUM_SEGMENTS; i++)

File diff suppressed because one or more lines are too long

View File

@ -102,9 +102,9 @@
<p class="labels"><i class="icons sel-icon" onclick="tglHex()">&#xe2b3;</i> Color palette</p> <p class="labels"><i class="icons sel-icon" onclick="tglHex()">&#xe2b3;</i> Color palette</p>
<div class="il"> <div class="il">
<div class="staytop fnd"> <div class="staytop fnd">
<input type="text" class="fnd" placeholder="Search" oninput="search(this,'pallist')" onfocus="search(this)" /> <input type="text" class="fnd" placeholder="Search" oninput="search(this,'pallist')" onfocus="search(this,'pallist')" />
<span onclick="clean(this)" class="icons">&#xe38f;</span> <i class="icons clear-icon" onclick="clean(this)">&#xe38f;</i>
<div class="icons"><svg xmlns='http://www.w3.org/2000/svg' class='fndIcn'><circle cx='8' cy='8' r='6' /><line x1='12' y1='12' x2='24' y2='12' transform='rotate(45,12,12)' /></svg></div> <i class="icons search-icon">&#xe0a1;</i>
</div> </div>
<div id="pallist" class="list"> <div id="pallist" class="list">
<div class="lstI" data-id="0"> <div class="lstI" data-id="0">
@ -153,9 +153,9 @@
<div class="il"> <div class="il">
<p class="labels">Effect mode</p> <p class="labels">Effect mode</p>
<div class="staytop fnd" id="staytop2"> <div class="staytop fnd" id="staytop2">
<input type="text" class="fnd" placeholder="Search" oninput="search(this,'fxlist')" onfocus="search(this)" /> <input type="text" class="fnd" placeholder="Search" oninput="search(this,'fxlist')" onfocus="search(this,'fxlist')" />
<span onclick="clean(this);" class="icons">&#xe38f;</span> <i class="icons clear-icon" onclick="clean(this);">&#xe38f;</i>
<div class="icons"><svg xmlns='http://www.w3.org/2000/svg' class='fndIcn'><circle cx='8' cy='8' r='6' /><line x1='12' y1='12' x2='24' y2='12' transform='rotate(45,12,12)' /></svg></div> <i class="icons search-icon">&#xe0a1;</i>
</div> </div>
<div id="fxlist" class="list"> <div id="fxlist" class="list">
Loading... Loading...
@ -172,7 +172,7 @@
<div id="segutil2"> <div id="segutil2">
<button class="btn btn-s" id="rsbtn" onclick="rSegs()">Reset segments</button> <button class="btn btn-s" id="rsbtn" onclick="rSegs()">Reset segments</button>
</div> </div>
<p>Transition: <input id="tt" class="noslide" type="number" min="0" max="65.5" step="0.1" value="0.7">s</p> <!--p>Transition: <input id="tt" class="noslide" type="number" min="0" max="65.5" step="0.1" value="0.7">s</p-->
</div> </div>
<div id="Presets" class="tabcontent"> <div id="Presets" class="tabcontent">

View File

@ -1125,7 +1125,6 @@ function readState(s,command=false)
syncSend = s.udpn.send; syncSend = s.udpn.send;
if (s.pl<0) currentPreset = s.ps; if (s.pl<0) currentPreset = s.ps;
else currentPreset = s.pl; else currentPreset = s.pl;
gId('tt').value = s.transition/10;
var selc=0; var ind=0; var selc=0; var ind=0;
populateSegments(s); populateSegments(s);
@ -1210,11 +1209,13 @@ function requestJson(command=null)
command.v = true; // force complete /json/si API response command.v = true; // force complete /json/si API response
command.time = Math.floor(Date.now() / 1000); command.time = Math.floor(Date.now() / 1000);
var t = d.getElementById('tt'); /*
var t = d.gId('tt');
if (t.validity.valid && command.transition==null) { if (t.validity.valid && command.transition==null) {
var tn = parseInt(t.value*10); var tn = parseInt(t.value*10);
if (tn != tr) command.transition = tn; if (tn != tr) command.transition = tn;
} }
*/
req = JSON.stringify(command); req = JSON.stringify(command);
if (req.length > 1000) useWs = false; //do not send very long requests over websocket if (req.length > 1000) useWs = false; //do not send very long requests over websocket
@ -1561,6 +1562,12 @@ function tglCs(i)
gId(`p${i}o2`).style.display = !pss? "block" : "none"; gId(`p${i}o2`).style.display = !pss? "block" : "none";
} }
function tglSegn(s)
{
d.gId(`seg${s}t`).style.display =
(window.getComputedStyle(d.gId(`seg${s}t`)).display === "none") ? "inline":"none";
}
function selSegEx(s) function selSegEx(s)
{ {
var obj = {"seg":[]}; var obj = {"seg":[]};

File diff suppressed because it is too large Load Diff

View File

@ -17,22 +17,29 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
uint16_t start = elem[F("start")] | seg.start; uint16_t start = elem[F("start")] | seg.start;
int stop = elem["stop"] | -1; int stop = elem["stop"] | -1;
if (stop < 0) {
uint16_t len = elem[F("len")];
stop = (len > 0) ? start + len : seg.stop;
}
if (elem["n"]) { if (elem["n"]) {
// name field exists // name field exists
if (seg.name) { if (seg.name) { //clear old name
delete[] seg.name; delete[] seg.name;
seg.name = nullptr; seg.name = nullptr;
} }
String name = elem["n"];
if (name.length()) { const char * name = elem["n"].as<const char*>();
seg.name = new char[name.length()+1]; size_t len = 0;
if (seg.name != nullptr) strcpy(seg.name, name.c_str()); if (name != nullptr) len = strlen(name);
if (len > 0 && len < 33) {
seg.name = new char[len+1];
if (seg.name) strlcpy(seg.name, name, 33);
} else { } else {
// but is empty // but is empty (already deleted above)
elem.remove("n"); elem.remove("n");
} }
} else if (elem[F("start")] || elem["stop"]) { } else if (start != seg.start || stop != seg.stop) {
// clearing or setting segment without name field // clearing or setting segment without name field
if (seg.name) { if (seg.name) {
delete[] seg.name; delete[] seg.name;
@ -40,10 +47,6 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
} }
} }
if (stop < 0) {
uint16_t len = elem[F("len")];
stop = (len > 0) ? start + len : seg.stop;
}
uint16_t grp = elem["grp"] | seg.grouping; uint16_t grp = elem["grp"] | seg.grouping;
uint16_t spc = elem[F("spc")] | seg.spacing; uint16_t spc = elem[F("spc")] | seg.spacing;
strip.setSegment(id, start, stop, grp, spc); strip.setSegment(id, start, stop, grp, spc);
@ -227,14 +230,6 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
transitionDelayTemp = transitionDelay; transitionDelayTemp = transitionDelay;
} }
} }
tr = root[F("tt")] | -1;
if (tr >= 0)
{
transitionDelayTemp = tr;
transitionDelayTemp *= 100;
jsonTransitionOnce = true;
}
strip.setTransition(transitionDelayTemp); strip.setTransition(transitionDelayTemp);
tr = root[F("tb")] | -1; tr = root[F("tb")] | -1;
@ -374,7 +369,7 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool fo
byte segbri = seg.opacity; byte segbri = seg.opacity;
root["bri"] = (segbri) ? segbri : 255; root["bri"] = (segbri) ? segbri : 255;
if (seg.name != nullptr) root["n"] = String(seg.name); if (segmentBounds && seg.name != nullptr) root["n"] = reinterpret_cast<const char *>(seg.name);
// to conserve RAM we will serialize the col array manually // to conserve RAM we will serialize the col array manually
// this will reduce RAM footprint from ~300 bytes to 84 bytes per segment // this will reduce RAM footprint from ~300 bytes to 84 bytes per segment
@ -703,37 +698,37 @@ void serializePalettes(JsonObject root, AsyncWebServerRequest* request)
curPalette.add("r"); curPalette.add("r");
break; break;
case 2: //primary color only case 2: //primary color only
curPalette.add(F("c1")); curPalette.add("c1");
break; break;
case 3: //primary + secondary case 3: //primary + secondary
curPalette.add(F("c1")); curPalette.add("c1");
curPalette.add(F("c1")); curPalette.add("c1");
curPalette.add(F("c2")); curPalette.add("c2");
curPalette.add(F("c2")); curPalette.add("c2");
break; break;
case 4: //primary + secondary + tertiary case 4: //primary + secondary + tertiary
curPalette.add(F("c3")); curPalette.add("c3");
curPalette.add(F("c2")); curPalette.add("c2");
curPalette.add(F("c1")); curPalette.add("c1");
break; break;
case 5: {//primary + secondary (+tert if not off), more distinct case 5: {//primary + secondary (+tert if not off), more distinct
curPalette.add(F("c1")); curPalette.add("c1");
curPalette.add(F("c1")); curPalette.add("c1");
curPalette.add(F("c1")); curPalette.add("c1");
curPalette.add(F("c1")); curPalette.add("c1");
curPalette.add(F("c1")); curPalette.add("c1");
curPalette.add(F("c2")); curPalette.add("c2");
curPalette.add(F("c2")); curPalette.add("c2");
curPalette.add(F("c2")); curPalette.add("c2");
curPalette.add(F("c2")); curPalette.add("c2");
curPalette.add(F("c2")); curPalette.add("c2");
curPalette.add(F("c3")); curPalette.add("c3");
curPalette.add(F("c3")); curPalette.add("c3");
curPalette.add(F("c3")); curPalette.add("c3");
curPalette.add(F("c3")); curPalette.add("c3");
curPalette.add(F("c3")); curPalette.add("c3");
curPalette.add(F("c1")); curPalette.add("c1");
break;} break;}
case 6: //Party colors case 6: //Party colors
setPaletteColors(curPalette, PartyColors_p); setPaletteColors(curPalette, PartyColors_p);

View File

@ -180,7 +180,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
fadeTransition = request->hasArg(F("TF")); fadeTransition = request->hasArg(F("TF"));
t = request->arg(F("TD")).toInt(); t = request->arg(F("TD")).toInt();
if (t > 0) transitionDelay = t; if (t >= 0) transitionDelay = t;
transitionDelayDefault = t; transitionDelayDefault = t;
strip.paletteFade = request->hasArg(F("PF")); strip.paletteFade = request->hasArg(F("PF"));

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2109151 #define VERSION 2109181
//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