UI fixes & revert forcing ULTRAWHITE for on/off bus

Reduce min heap for 8266
This commit is contained in:
Blaz Kristan 2023-03-02 18:21:55 +01:00
parent b8489724ef
commit c151221d12
7 changed files with 1987 additions and 1981 deletions

View File

@ -415,6 +415,10 @@ void Segment::set(uint16_t i1, uint16_t i2, uint8_t grp, uint8_t spc, uint16_t o
bool Segment::setColor(uint8_t slot, uint32_t c) { //returns true if changed bool Segment::setColor(uint8_t slot, uint32_t c) { //returns true if changed
if (slot >= NUM_COLORS || c == colors[slot]) return false; if (slot >= NUM_COLORS || c == colors[slot]) return false;
if (!_isRGB && !_hasW) {
if (slot == 0 && c == BLACK) return false; // on/off segment cannot have primary color black
if (slot == 1 && c != BLACK) return false; // on/off segment cannot have secondary color non black
}
if (fadeTransition) startTransition(strip.getTransition()); // start transition prior to change if (fadeTransition) startTransition(strip.getTransition()); // start transition prior to change
colors[slot] = c; colors[slot] = c;
stateChanged = true; // send UDP/WS broadcast stateChanged = true; // send UDP/WS broadcast

View File

@ -361,7 +361,7 @@ void BusOnOff::setPixelColor(uint16_t pix, uint32_t c) {
uint8_t b = B(c); uint8_t b = B(c);
uint8_t w = W(c); uint8_t w = W(c);
_data = bool((r+g+b+w) && _bri) ? 0xFF : 0; _data = bool(r|g|b|w) && bool(_bri) ? 0xFF : 0;
} }
uint32_t BusOnOff::getPixelColor(uint16_t pix) { uint32_t BusOnOff::getPixelColor(uint16_t pix) {

View File

@ -404,7 +404,11 @@
#endif #endif
//#define MIN_HEAP_SIZE (MAX_LED_MEMORY+2048) //#define MIN_HEAP_SIZE (MAX_LED_MEMORY+2048)
#define MIN_HEAP_SIZE (8192) #ifdef ESP8266
#define MIN_HEAP_SIZE 6144
#else
#define MIN_HEAP_SIZE 8192
#endif
// Maximum size of node map (list of other WLED instances) // Maximum size of node map (list of other WLED instances)
#ifdef ESP8266 #ifdef ESP8266

View File

@ -111,7 +111,7 @@
</div> </div>
<div id="kwrap" class="slider"> <div id="kwrap" class="slider">
<div class="sliderwrap il"> <div class="sliderwrap il">
<input id="sliderK" class="noslide" ninput="fromK()" onchange="setColor(0)" max="10091" min="1900" type="range" value="6550" /> <input id="sliderK" class="noslide" oninput="fromK()" onchange="setColor(0)" max="10091" min="1900" type="range" value="6550" />
<div class="sliderdisplay"></div> <div class="sliderdisplay"></div>
</div> </div>
<span class="tooltiptext">Kelvin/Temperature</span> <span class="tooltiptext">Kelvin/Temperature</span>

View File

@ -61,13 +61,10 @@ function setCSL(cs)
let w = cs.dataset.w ? parseInt(cs.dataset.w) : 0; let w = cs.dataset.w ? parseInt(cs.dataset.w) : 0;
let hasShadow = getComputedStyle(cs).textShadow !== "none"; let hasShadow = getComputedStyle(cs).textShadow !== "none";
if (hasRGB && !isRgbBlack(cs.dataset)) { if (hasRGB && !isRgbBlack(cs.dataset)) {
cs.style.backgroundColor = rgbStr(cs.dataset);
if (!hasShadow) cs.style.color = rgbBri(cs.dataset) > 127 ? "#000":"#fff"; // if text has no CSS "shadow" if (!hasShadow) cs.style.color = rgbBri(cs.dataset) > 127 ? "#000":"#fff"; // if text has no CSS "shadow"
if (hasWhite && w > 0) { cs.style.background = (hasWhite && w > 0) ? `linear-gradient(180deg, ${rgbStr(cs.dataset)} 30%, rgb(${w},${w},${w}))` : rgbStr(cs.dataset);
cs.style.background = `linear-gradient(180deg, ${rgbStr(cs.dataset)} 30%, rgb(${w},${w},${w}))`;
}
} else { } else {
if (!hasWhite) w = 0; if (hasRGB && !hasWhite) w = 0;
cs.style.background = `rgb(${w},${w},${w})`; cs.style.background = `rgb(${w},${w},${w})`;
if (!hasShadow) cs.style.color = w > 127 ? "#000":"#fff"; if (!hasShadow) cs.style.color = w > 127 ? "#000":"#fff";
} }
@ -1181,7 +1178,7 @@ function updateUI()
gId('kwrap').style.display = (hasRGB && !hasCCT) ? "block":"none"; // Kelvin slider gId('kwrap').style.display = (hasRGB && !hasCCT) ? "block":"none"; // Kelvin slider
gId('rgbwrap').style.display = (hasRGB && ccfg.rgb) ? "block":"none"; // RGB sliders gId('rgbwrap').style.display = (hasRGB && ccfg.rgb) ? "block":"none"; // RGB sliders
gId('qcs-w').style.display = (hasRGB && ccfg.quick) ? "block":"none"; // quick selection gId('qcs-w').style.display = (hasRGB && ccfg.quick) ? "block":"none"; // quick selection
gId('csl').style.display = (hasRGB || hasWhite) ? "block":"none"; // color selectors (hide for On/Off bus) //gId('csl').style.display = (hasRGB || hasWhite) ? "block":"none"; // color selectors (hide for On/Off bus)
//gId('palw').style.display = (hasRGB) ? "inline-block":"none"; // palettes are shown/hidden in setEffectParameters() //gId('palw').style.display = (hasRGB) ? "inline-block":"none"; // palettes are shown/hidden in setEffectParameters()
updatePA(); updatePA();
@ -1231,7 +1228,13 @@ function updateSelectedFx()
var fxs = parent.querySelectorAll('.lstI'); var fxs = parent.querySelectorAll('.lstI');
for (const fx of fxs) { for (const fx of fxs) {
let opts = fx.dataset.opt.split(";"); let opts = fx.dataset.opt.split(";");
if (fx.dataset.id>0 && segLmax<2 && (!opts[3] || opts[3].indexOf("0")<0)) fx.classList.add('hide'); else fx.classList.remove('hide'); if (fx.dataset.id>0) {
if (segLmax==0) fx.classList.add('hide'); // none of the segments selected (hide all effects)
else {
if (segLmax==1 && (!opts[3] || opts[3].indexOf("0")<0)) fx.classList.add('hide');
else fx.classList.remove('hide');
}
}
} }
// hide 2D mapping and/or sound simulation options // hide 2D mapping and/or sound simulation options
var selectedName = selectedEffect.querySelector(".lstIname").innerText; var selectedName = selectedEffect.querySelector(".lstIname").innerText;
@ -1356,7 +1359,7 @@ function readState(s,command=false)
cd[e].dataset.r = i.col[e][0]; cd[e].dataset.r = i.col[e][0];
cd[e].dataset.g = i.col[e][1]; cd[e].dataset.g = i.col[e][1];
cd[e].dataset.b = i.col[e][2]; cd[e].dataset.b = i.col[e][2];
if (hasWhite) { cd[e].dataset.w = i.col[e][3]; } if (hasWhite || (!hasRGB && !hasWhite)) { cd[e].dataset.w = i.col[e][3]; }
setCSL(cd[e]); setCSL(cd[e]);
} }
selectSlot(csel); selectSlot(csel);

File diff suppressed because it is too large Load Diff

View File

@ -107,6 +107,8 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
if (stop > start && of > len -1) of = len -1; if (stop > start && of > len -1) of = len -1;
seg.set(start, stop, grp, spc, of, startY, stopY); seg.set(start, stop, grp, spc, of, startY, stopY);
if (seg.reset && seg.stop == 0) return; // segment was deleted & is marked for reset, no need to change anything else
byte segbri = seg.opacity; byte segbri = seg.opacity;
if (getVal(elem["bri"], &segbri)) { if (getVal(elem["bri"], &segbri)) {
if (segbri > 0) seg.setOpacity(segbri); if (segbri > 0) seg.setOpacity(segbri);
@ -125,43 +127,36 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
JsonArray colarr = elem["col"]; JsonArray colarr = elem["col"];
if (!colarr.isNull()) if (!colarr.isNull())
{ {
if (seg.hasRGB() || seg.hasWhite()) { for (size_t i = 0; i < 3; i++)
// segment has RGB or White {
for (size_t i = 0; i < 3; i++) int rgbw[] = {0,0,0,0};
{ bool colValid = false;
int rgbw[] = {0,0,0,0}; JsonArray colX = colarr[i];
bool colValid = false; if (colX.isNull()) {
JsonArray colX = colarr[i]; byte brgbw[] = {0,0,0,0};
if (colX.isNull()) { const char* hexCol = colarr[i];
byte brgbw[] = {0,0,0,0}; if (hexCol == nullptr) { //Kelvin color temperature (or invalid), e.g 2400
const char* hexCol = colarr[i]; int kelvin = colarr[i] | -1;
if (hexCol == nullptr) { //Kelvin color temperature (or invalid), e.g 2400 if (kelvin < 0) continue;
int kelvin = colarr[i] | -1; if (kelvin == 0) seg.setColor(i, 0);
if (kelvin < 0) continue; if (kelvin > 0) colorKtoRGB(kelvin, brgbw);
if (kelvin == 0) seg.setColor(i, 0);
if (kelvin > 0) colorKtoRGB(kelvin, brgbw);
colValid = true;
} else { //HEX string, e.g. "FFAA00"
colValid = colorFromHexString(brgbw, hexCol);
}
for (size_t c = 0; c < 4; c++) rgbw[c] = brgbw[c];
} else { //Array of ints (RGB or RGBW color), e.g. [255,160,0]
byte sz = colX.size();
if (sz == 0) continue; //do nothing on empty array
copyArray(colX, rgbw, 4);
colValid = true; colValid = true;
} else { //HEX string, e.g. "FFAA00"
colValid = colorFromHexString(brgbw, hexCol);
} }
for (size_t c = 0; c < 4; c++) rgbw[c] = brgbw[c];
} else { //Array of ints (RGB or RGBW color), e.g. [255,160,0]
byte sz = colX.size();
if (sz == 0) continue; //do nothing on empty array
if (!colValid) continue; copyArray(colX, rgbw, 4);
colValid = true;
seg.setColor(i, RGBW32(rgbw[0],rgbw[1],rgbw[2],rgbw[3]));
if (seg.mode == FX_MODE_STATIC) strip.trigger(); //instant refresh
} }
} else {
// non RGB & non White segment (usually On/Off bus) if (!colValid) continue;
seg.setColor(0, ULTRAWHITE);
seg.setColor(1, BLACK); seg.setColor(i, RGBW32(rgbw[0],rgbw[1],rgbw[2],rgbw[3]));
if (seg.mode == FX_MODE_STATIC) strip.trigger(); //instant refresh
} }
} }