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)
{
//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;
if (!SEGENV.allocateData(dataSize)) return mode_static(); //allocation failed

View File

@ -567,7 +567,11 @@ void WS2812FX::setSegment(uint8_t n, uint16_t i1, uint16_t i2, uint8_t grouping,
if (seg.stop) setRange(seg.start, seg.stop -1, 0); //turn old segment range off
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
{
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>
<div class="il">
<div class="staytop fnd">
<input type="text" class="fnd" placeholder="Search" oninput="search(this,'pallist')" onfocus="search(this)" />
<span onclick="clean(this)" class="icons">&#xe38f;</span>
<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>
<input type="text" class="fnd" placeholder="Search" oninput="search(this,'pallist')" onfocus="search(this,'pallist')" />
<i class="icons clear-icon" onclick="clean(this)">&#xe38f;</i>
<i class="icons search-icon">&#xe0a1;</i>
</div>
<div id="pallist" class="list">
<div class="lstI" data-id="0">
@ -153,9 +153,9 @@
<div class="il">
<p class="labels">Effect mode</p>
<div class="staytop fnd" id="staytop2">
<input type="text" class="fnd" placeholder="Search" oninput="search(this,'fxlist')" onfocus="search(this)" />
<span onclick="clean(this);" class="icons">&#xe38f;</span>
<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>
<input type="text" class="fnd" placeholder="Search" oninput="search(this,'fxlist')" onfocus="search(this,'fxlist')" />
<i class="icons clear-icon" onclick="clean(this);">&#xe38f;</i>
<i class="icons search-icon">&#xe0a1;</i>
</div>
<div id="fxlist" class="list">
Loading...
@ -172,7 +172,7 @@
<div id="segutil2">
<button class="btn btn-s" id="rsbtn" onclick="rSegs()">Reset segments</button>
</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 id="Presets" class="tabcontent">

View File

@ -1125,7 +1125,6 @@ function readState(s,command=false)
syncSend = s.udpn.send;
if (s.pl<0) currentPreset = s.ps;
else currentPreset = s.pl;
gId('tt').value = s.transition/10;
var selc=0; var ind=0;
populateSegments(s);
@ -1210,11 +1209,13 @@ function requestJson(command=null)
command.v = true; // force complete /json/si API response
command.time = Math.floor(Date.now() / 1000);
var t = d.getElementById('tt');
/*
var t = d.gId('tt');
if (t.validity.valid && command.transition==null) {
var tn = parseInt(t.value*10);
if (tn != tr) command.transition = tn;
}
*/
req = JSON.stringify(command);
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";
}
function tglSegn(s)
{
d.gId(`seg${s}t`).style.display =
(window.getComputedStyle(d.gId(`seg${s}t`)).display === "none") ? "inline":"none";
}
function selSegEx(s)
{
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;
int stop = elem["stop"] | -1;
if (stop < 0) {
uint16_t len = elem[F("len")];
stop = (len > 0) ? start + len : seg.stop;
}
if (elem["n"]) {
// name field exists
if (seg.name) {
if (seg.name) { //clear old name
delete[] seg.name;
seg.name = nullptr;
}
String name = elem["n"];
if (name.length()) {
seg.name = new char[name.length()+1];
if (seg.name != nullptr) strcpy(seg.name, name.c_str());
const char * name = elem["n"].as<const char*>();
size_t len = 0;
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 {
// but is empty
// but is empty (already deleted above)
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
if (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 spc = elem[F("spc")] | seg.spacing;
strip.setSegment(id, start, stop, grp, spc);
@ -227,14 +230,6 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
transitionDelayTemp = transitionDelay;
}
}
tr = root[F("tt")] | -1;
if (tr >= 0)
{
transitionDelayTemp = tr;
transitionDelayTemp *= 100;
jsonTransitionOnce = true;
}
strip.setTransition(transitionDelayTemp);
tr = root[F("tb")] | -1;
@ -374,7 +369,7 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool fo
byte segbri = seg.opacity;
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
// 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");
break;
case 2: //primary color only
curPalette.add(F("c1"));
curPalette.add("c1");
break;
case 3: //primary + secondary
curPalette.add(F("c1"));
curPalette.add(F("c1"));
curPalette.add(F("c2"));
curPalette.add(F("c2"));
curPalette.add("c1");
curPalette.add("c1");
curPalette.add("c2");
curPalette.add("c2");
break;
case 4: //primary + secondary + tertiary
curPalette.add(F("c3"));
curPalette.add(F("c2"));
curPalette.add(F("c1"));
curPalette.add("c3");
curPalette.add("c2");
curPalette.add("c1");
break;
case 5: {//primary + secondary (+tert if not off), more distinct
curPalette.add(F("c1"));
curPalette.add(F("c1"));
curPalette.add(F("c1"));
curPalette.add(F("c1"));
curPalette.add(F("c1"));
curPalette.add(F("c2"));
curPalette.add(F("c2"));
curPalette.add(F("c2"));
curPalette.add(F("c2"));
curPalette.add(F("c2"));
curPalette.add(F("c3"));
curPalette.add(F("c3"));
curPalette.add(F("c3"));
curPalette.add(F("c3"));
curPalette.add(F("c3"));
curPalette.add(F("c1"));
curPalette.add("c1");
curPalette.add("c1");
curPalette.add("c1");
curPalette.add("c1");
curPalette.add("c1");
curPalette.add("c2");
curPalette.add("c2");
curPalette.add("c2");
curPalette.add("c2");
curPalette.add("c2");
curPalette.add("c3");
curPalette.add("c3");
curPalette.add("c3");
curPalette.add("c3");
curPalette.add("c3");
curPalette.add("c1");
break;}
case 6: //Party colors
setPaletteColors(curPalette, PartyColors_p);

View File

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

View File

@ -8,7 +8,7 @@
*/
// 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
//#define WLED_USE_MY_CONFIG