Fix sliders on page load if black is set

pull/2393/head
cschwinne 2021-12-01 00:16:43 +01:00
rodzic f6e5b67f0d
commit 33036e7599
5 zmienionych plików z 831 dodań i 826 usunięć

Wyświetl plik

@ -2,6 +2,12 @@
### Builds after release 0.12.0
#### Build 2111300
- Added CCT and white balance correction support (PR #2285)
- Unified UI slider style
- Added LED settings config template upload
#### Build 2111220
- Fixed preset cycle not working from preset called by UI

Wyświetl plik

@ -82,6 +82,7 @@ void onAlexaChange(EspalexaDevice* dev)
uint8_t cctPrev = seg.cct;
seg.setCCT(k, segid);
if (seg.cct != cctPrev) effectChanged = true; //send UDP
col[0]= 0; col[1]= 0; col[2]= 0; col[3]= 255;
} else if (strip.isRgbw) {
switch (ct) { //these values empirically look good on RGBW
case 199: col[0]=255; col[1]=255; col[2]=255; col[3]=255; break;

Wyświetl plik

@ -840,6 +840,7 @@ function loadNodes()
});
}
//update the 'sliderdisplay' background div of a slider for a visual indication of slider position
function updateTrail(e)
{
if (e==null) return;
@ -851,6 +852,7 @@ function updateTrail(e)
e.parentNode.getElementsByClassName('sliderdisplay')[0].style.background = val;
}
//rangetouch slider function
function updateBubble(e)
{
var bubble = e.target.parentNode.getElementsByTagName('output')[0];
@ -859,11 +861,13 @@ function updateBubble(e)
}
}
//rangetouch slider function
function toggleBubble(e)
{
e.target.parentNode.querySelector('output').classList.toggle('hidden');
}
//updates segment length upon input of segment values
function updateLen(s)
{
if (!d.getElementById(`seg${s}s`)) return;
@ -889,22 +893,23 @@ function updateLen(s)
d.getElementById(`seg${s}len`).innerHTML = out;
}
//updates background color of currently selected preset
function updatePA()
{
var ps = d.getElementsByClassName("seg");
var ps = d.getElementsByClassName("seg"); //reset all preset buttons
for (let i = 0; i < ps.length; i++) {
ps[i].style.backgroundColor = "var(--c-2)";
}
ps = d.getElementsByClassName("psts");
ps = d.getElementsByClassName("psts"); //reset all quick selectors
for (let i = 0; i < ps.length; i++) {
ps[i].style.backgroundColor = "var(--c-2)";
}
if (currentPreset > 0) {
var acv = d.getElementById(`p${currentPreset}o`);
if (acv && !expanded[currentPreset+100])
acv.style.background = "var(--c-6)";
acv.style.background = "var(--c-6)"; //highlight current preset
acv = d.getElementById(`p${currentPreset}qlb`);
if (acv) acv.style.background = "var(--c-6)";
if (acv) acv.style.background = "var(--c-6)"; //highlight quick selector
}
}
@ -922,8 +927,7 @@ function updateUI()
d.getElementById('kwrap').style.display = (lastinfo.leds.cct) ? "none":"block";
updatePA();
//updateHex();
//updateRgb();
updatePSliders();
}
function displayRover(i,s)
@ -1001,7 +1005,6 @@ function readState(s,command=false) {
if (isRgbw) whites[e] = parseInt(i.col[e][3]);
selectSlot(csel);
}
//d.getElementById('sliderW').value = whites[csel];
if (i.cct != null && i.cct>=0) d.getElementById("sliderA").value = i.cct;
d.getElementById('sliderSpeed').value = i.sx;
@ -1701,10 +1704,10 @@ function selectSlot(b) {
cd[csel].style.margin="2px";
cd[csel].style.width="50px";
cpick.color.set(cd[csel].style.backgroundColor);
//force slider update on initial load (picker "color:change" not fired if black)
if (cd[csel].style.backgroundColor == 'rgb(0, 0, 0)') updatePSliders();
d.getElementById('sliderW').value = whites[csel];
updateTrail(d.getElementById('sliderW'));
//updateHex();
//updateRgb();
redrawPalPrev();
}
@ -1725,20 +1728,7 @@ function pC(col)
}
function updatePSliders() {
updateRgb();
updateHex();
var v = d.getElementById('sliderV');
v.value = cpick.color.value;
var hsv = {"h":cpick.color.hue,"s":cpick.color.saturation,"v":100};
var c = iro.Color.hsvToRgb(hsv);
var cs = 'rgb('+c.r+','+c.g+','+c.b+')';
v.parentNode.getElementsByClassName('sliderdisplay')[0].style.setProperty('--bg',cs);
updateTrail(v);
d.getElementById('sliderK').value = cpick.color.kelvin;
}
function updateRgb()
{
//update RGB sliders
var col = cpick.color.rgb;
var s = d.getElementById('sliderR');
s.value = col.r; updateTrail(s,1);
@ -1746,16 +1736,26 @@ function updateRgb()
s.value = col.g; updateTrail(s,2);
s = d.getElementById('sliderB');
s.value = col.b; updateTrail(s,3);
}
function updateHex()
{
var str = cpick.color.hexString;
str = str.substring(1);
//update hex field
var str = cpick.color.hexString.substring(1);
var w = whites[csel];
if (w > 0) str += w.toString(16);
d.getElementById('hexc').value = str;
d.getElementById('hexcnf').style.backgroundColor = "var(--c-3)";
//update value slider
var v = d.getElementById('sliderV');
v.value = cpick.color.value;
//background color as if color had full value
var hsv = {"h":cpick.color.hue,"s":cpick.color.saturation,"v":100};
var c = iro.Color.hsvToRgb(hsv);
var cs = 'rgb('+c.r+','+c.g+','+c.b+')';
v.parentNode.getElementsByClassName('sliderdisplay')[0].style.setProperty('--bg',cs);
updateTrail(v);
//update Kelvin slider
d.getElementById('sliderK').value = cpick.color.kelvin;
}
function hexEnter() {
@ -1807,8 +1807,6 @@ function setColor(sr) {
} else if (csel == 2) {
obj = {"seg": {"col": [[],[],[col.r, col.g, col.b, whites[csel]]]}};
}
//updateHex();
//updateRgb();
requestJson(obj);
}

Plik diff jest za duży Load Diff

Wyświetl plik

@ -8,7 +8,7 @@
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2111280
#define VERSION 2111300
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG
@ -270,7 +270,7 @@ WLED_GLOBAL byte bootPreset _INIT(0); // save preset to load
//but not on LED settings save if there is more than one segment currently
WLED_GLOBAL bool autoSegments _INIT(false);
WLED_GLOBAL bool correctWB _INIT(false); //CCT color correction of RGB color
WLED_GLOBAL bool cctFromRgb _INIT(true); //CCT is calculated from RGB instead of using seg.cct
WLED_GLOBAL bool cctFromRgb _INIT(false); //CCT is calculated from RGB instead of using seg.cct
WLED_GLOBAL byte col[] _INIT_N(({ 255, 160, 0, 0 })); // current RGB(W) primary color. col[] should be updated if you want to change the color.
WLED_GLOBAL byte colSec[] _INIT_N(({ 0, 0, 0, 0 })); // current RGB(W) secondary color