cctFromRgb option
This commit is contained in:
parent
3dec4a6651
commit
ba8a00764a
@ -259,7 +259,7 @@ class WS2812FX {
|
||||
uint8_t grouping, spacing;
|
||||
uint8_t opacity;
|
||||
uint32_t colors[NUM_COLORS];
|
||||
int16_t cct; //-1==auto (no RGB balance correction), 0==1900K, 255==10091K
|
||||
uint16_t cct; //0==1900K, 255==10091K, or Kelvin value >=1900
|
||||
char *name;
|
||||
bool setColor(uint8_t slot, uint32_t c, uint8_t segn) { //returns true if changed
|
||||
if (slot >= NUM_COLORS || segn >= MAX_NUM_SEGMENTS) return false;
|
||||
|
@ -138,7 +138,7 @@ void WS2812FX::service() {
|
||||
|
||||
if (!SEGMENT.getOption(SEG_OPTION_FREEZE)) { //only run effect function if not frozen
|
||||
_virtualSegmentLength = SEGMENT.virtualLength();
|
||||
busses.setSegmentCCT(SEGMENT.cct, correctWB);
|
||||
if (!cctFromRgb || correctWB) busses.setSegmentCCT(SEGMENT.cct, correctWB);
|
||||
_bri_t = SEGMENT.opacity; _colors_t[0] = SEGMENT.colors[0]; _colors_t[1] = SEGMENT.colors[1]; _colors_t[2] = SEGMENT.colors[2];
|
||||
if (!IS_SEGMENT_ON) _bri_t = 0;
|
||||
for (uint8_t t = 0; t < MAX_NUM_TRANSITIONS; t++) {
|
||||
@ -605,7 +605,7 @@ void WS2812FX::resetSegments() {
|
||||
_segments[0].setOption(SEG_OPTION_SELECTED, 1);
|
||||
_segments[0].setOption(SEG_OPTION_ON, 1);
|
||||
_segments[0].opacity = 255;
|
||||
_segments[0].cct = -1;
|
||||
_segments[0].cct = 127;
|
||||
|
||||
for (uint16_t i = 1; i < MAX_NUM_SEGMENTS; i++)
|
||||
{
|
||||
@ -613,7 +613,7 @@ void WS2812FX::resetSegments() {
|
||||
_segments[i].grouping = 1;
|
||||
_segments[i].setOption(SEG_OPTION_ON, 1);
|
||||
_segments[i].opacity = 255;
|
||||
_segments[i].cct = -1;
|
||||
_segments[i].cct = 127;
|
||||
_segments[i].speed = DEFAULT_SPEED;
|
||||
_segments[i].intensity = DEFAULT_INTENSITY;
|
||||
_segment_runtimes[i].reset();
|
||||
|
@ -81,6 +81,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
||||
CJSON(strip.milliampsPerLed, hw_led[F("ledma")]);
|
||||
uint8_t rgbwMode = hw_led[F("rgbwm")] | RGBW_MODE_DUAL; // use global setting (legacy)
|
||||
CJSON(correctWB, hw_led["cct"]);
|
||||
CJSON(cctFromRgb, hw_led[F("cr")]);
|
||||
|
||||
JsonArray ins = hw_led["ins"];
|
||||
|
||||
@ -521,6 +522,7 @@ void serializeConfig() {
|
||||
hw_led[F("maxpwr")] = strip.ablMilliampsMax;
|
||||
hw_led[F("ledma")] = strip.milliampsPerLed;
|
||||
hw_led["cct"] = correctWB;
|
||||
hw_led[F("cr")] = cctFromRgb;
|
||||
|
||||
JsonArray hw_led_ins = hw_led.createNestedArray("ins");
|
||||
|
||||
|
@ -471,7 +471,9 @@ img {
|
||||
#rwrap .sliderdisplay { --bg: #f00; }
|
||||
#gwrap .sliderdisplay { --bg: #0f0; }
|
||||
#bwrap .sliderdisplay { --bg: #00f; }
|
||||
#wbal .sliderdisplay { background: linear-gradient(90deg, #ff8f1f 0%, #fff 50%, #cbdbff); }
|
||||
#wbal .sliderdisplay, #kwrap .sliderdisplay {
|
||||
background: linear-gradient(90deg, #ff8f1f 0%, #fff 50%, #cbdbff);
|
||||
}
|
||||
|
||||
.sliderbubble {
|
||||
width: 36px;
|
||||
@ -534,7 +536,7 @@ input[type=range]:active + .sliderbubble {
|
||||
display: inline;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
#wwrap {
|
||||
#wwrap, #wbal {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
@ -47,13 +47,13 @@
|
||||
<div id="picker" class="noslide"></div>
|
||||
<div id="vwrap">
|
||||
<div class="sliderwrap il" id="vwrap">
|
||||
<input id="sliderV" class="noslide" onchange="setColor(0)" oninput="fromV()" max="100" min="0" type="range" value="128" step="any" />
|
||||
<input id="sliderV" class="noslide" oninput="fromV()" onchange="setColor(0)" max="100" min="0" type="range" value="128" step="any" />
|
||||
<div class="sliderdisplay"></div>
|
||||
</div><br>
|
||||
</div>
|
||||
<div id="wbal">
|
||||
<div id="kwrap">
|
||||
<div class="sliderwrap il">
|
||||
<input id="sliderA" class="noslide" oninput="fromA()" onchange="setBalance(this.value)" 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>
|
||||
</div>
|
||||
@ -79,6 +79,13 @@
|
||||
<div class="sliderdisplay"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="wbal">
|
||||
<p class="labels">White balance</p>
|
||||
<div class="sliderwrap il">
|
||||
<input id="sliderA" class="noslide" onchange="setBalance(this.value)" max="255" min="0" type="range" value="128" />
|
||||
<div class="sliderdisplay"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="qcs-w">
|
||||
<div class="qcs" onclick="pC('#ff0000');" title="Red" style="background-color:#ff0000;"></div>
|
||||
<div class="qcs" onclick="pC('#ffa000');" title="Orange" style="background-color:#ffa000;"></div>
|
||||
|
@ -4,7 +4,6 @@ var noNewSegs = false;
|
||||
var isOn = false, nlA = false, isLv = false, isInfo = false, isNodes = false, syncSend = false, syncTglRecv = true, isRgbw = false;
|
||||
var whites = [0,0,0];
|
||||
var selColors;
|
||||
var mcct = false; //manual CCT (if false, CCT from RGB)
|
||||
var expanded = [false];
|
||||
var powered = [true];
|
||||
var nlDur = 60, nlTar = 0;
|
||||
@ -70,6 +69,7 @@ function applyCfg()
|
||||
d.getElementById('hexw').style.display = ccfg.hex ? "block":"none";
|
||||
d.getElementById('picker').style.display = ccfg.picker ? "block":"none";
|
||||
d.getElementById('vwrap').style.display = ccfg.picker ? "block":"none";
|
||||
d.getElementById('kwrap').style.display = ccfg.picker ? "block":"none";
|
||||
d.getElementById('rgbwrap').style.display = ccfg.rgb ? "block":"none";
|
||||
d.getElementById('qcs-w').style.display = ccfg.quick ? "block":"none";
|
||||
var l = cfg.comp.labels;
|
||||
@ -922,8 +922,9 @@ function updateUI()
|
||||
updateTrail(d.getElementById('sliderBri'));
|
||||
updateTrail(d.getElementById('sliderSpeed'));
|
||||
updateTrail(d.getElementById('sliderIntensity'));
|
||||
//updateTrail(d.getElementById('sliderW'));
|
||||
d.getElementById('wwrap').style.display = (isRgbw) ? "block":"none";
|
||||
d.getElementById('wbal').style.display = (lastinfo.leds.cct) ? "block":"none";
|
||||
d.getElementById('kwrap').style.display = (lastinfo.leds.cct) ? "none":"block";
|
||||
|
||||
updatePA();
|
||||
//updateHex();
|
||||
@ -1006,7 +1007,7 @@ function readState(s,command=false) {
|
||||
selectSlot(csel);
|
||||
}
|
||||
//d.getElementById('sliderW').value = whites[csel];
|
||||
if (mcct & i.cct && i.cct>=0) d.getElementById("sliderA").value = i.cct;
|
||||
if (i.cct != null && i.cct>=0) d.getElementById("sliderA").value = i.cct;
|
||||
|
||||
d.getElementById('sliderSpeed').value = i.sx;
|
||||
d.getElementById('sliderIntensity').value = i.ix;
|
||||
@ -1154,9 +1155,6 @@ function requestJson(command, rinfo = true) {
|
||||
}
|
||||
d.title = name;
|
||||
isRgbw = info.leds.wv;
|
||||
mcct = info.leds.cct;
|
||||
let wsld = d.getElementById("wbal");
|
||||
if (mcct) wsld.parentNode.insertBefore(wsld,d.getElementById('qcs-w'));
|
||||
ledCount = info.leds.count;
|
||||
syncTglRecv = info.str;
|
||||
maxSeg = info.leds.maxseg;
|
||||
@ -1742,7 +1740,7 @@ function updatePSliders() {
|
||||
var cs = 'rgb('+c.r+','+c.g+','+c.b+')';
|
||||
v.parentNode.getElementsByClassName('sliderdisplay')[0].style.setProperty('--bg',cs);
|
||||
updateTrail(v);
|
||||
if (!mcct) d.getElementById('sliderA').value = cpick.color.kelvin;
|
||||
d.getElementById('sliderK').value = cpick.color.kelvin;
|
||||
}
|
||||
|
||||
function updateRgb()
|
||||
@ -1789,9 +1787,9 @@ function fromV()
|
||||
cpick.color.setChannel('hsv', 'v', d.getElementById('sliderV').value);
|
||||
}
|
||||
|
||||
function fromA()
|
||||
function fromK()
|
||||
{
|
||||
if (!mcct) cpick.color.set({ kelvin: d.getElementById('sliderA').value });
|
||||
cpick.color.set({ kelvin: d.getElementById('sliderK').value });
|
||||
}
|
||||
|
||||
function fromRgb()
|
||||
@ -1822,7 +1820,6 @@ function setColor(sr) {
|
||||
|
||||
function setBalance(b)
|
||||
{
|
||||
if (!mcct) {setColor(0); return;}
|
||||
var obj = {"seg": {"cct": parseInt(b)}};
|
||||
requestJson(obj);
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ ${i+1}:
|
||||
Make a segment for each output: <input type="checkbox" name="MS"> <br>
|
||||
Custom bus start indices: <input type="checkbox" onchange="tglSi(this.checked)" id="si"> <br>
|
||||
White Balance correction: <input type="checkbox" name="CCT"> <br>
|
||||
Calculate CCT from RGB: TODO<br>
|
||||
Calculate CCT from RGB: <input type="checkbox" name="CR"> <br>
|
||||
CCT blending mode: TODO<br>
|
||||
<hr style="width:260px">
|
||||
<div id="btns"></div>
|
||||
|
@ -118,22 +118,22 @@ id="wreason">800 LEDs per output</span> for the best experience!<br></div><hr
|
||||
style="width:260px">Make a segment for each output: <input type="checkbox"
|
||||
name="MS"><br>Custom bus start indices: <input type="checkbox"
|
||||
onchange="tglSi(this.checked)" id="si"><br>White Balance correction: <input
|
||||
type="checkbox" name="CCT"><br>Calculate CCT from RGB: TODO<br>
|
||||
CCT blending mode: TODO<br><hr style="width:260px"><div id="btns"></div>
|
||||
Touch threshold: <input type="number" class="s" min="0" max="100" name="TT"
|
||||
required><br>IR GPIO: <input type="number" min="-1" max="40" name="IR"
|
||||
onchange="UI()" class="xs"><select name="IT" onchange="UI()"><option value="0">
|
||||
Remote disabled</option><option value="1">24-key RGB</option><option value="2">
|
||||
24-key with CT</option><option value="3">40-key blue</option><option value="4">
|
||||
44-key RGB</option><option value="5">21-key RGB</option><option value="6">
|
||||
6-key black</option><option value="7">9-key red</option><option value="8">
|
||||
JSON remote</option></select><span style="cursor:pointer" onclick='off("IR")'>
|
||||
×</span><br><div id="json" style="display:none">JSON file: <input
|
||||
type="file" name="data" accept=".json"> <input type="button" value="Upload"
|
||||
onclick='uploadFile("/ir.json")'><br></div><div id="toast"></div><a
|
||||
href="https://kno.wled.ge/interfaces/infrared/" target="_blank">IR info</a><br>
|
||||
Relay GPIO: <input type="number" min="-1" max="33" name="RL" onchange="UI()"
|
||||
class="xs"> Invert <input type="checkbox" name="RM"><span
|
||||
type="checkbox" name="CCT"><br>Calculate CCT from RGB: <input type="checkbox"
|
||||
name="CR"><br>CCT blending mode: TODO<br><hr style="width:260px"><div id="btns">
|
||||
</div>Touch threshold: <input type="number" class="s" min="0" max="100"
|
||||
name="TT" required><br>IR GPIO: <input type="number" min="-1" max="40"
|
||||
name="IR" onchange="UI()" class="xs"><select name="IT" onchange="UI()"><option
|
||||
value="0">Remote disabled</option><option value="1">24-key RGB</option><option
|
||||
value="2">24-key with CT</option><option value="3">40-key blue</option><option
|
||||
value="4">44-key RGB</option><option value="5">21-key RGB</option><option
|
||||
value="6">6-key black</option><option value="7">9-key red</option><option
|
||||
value="8">JSON remote</option></select><span style="cursor:pointer"
|
||||
onclick='off("IR")'> ×</span><br><div id="json" style="display:none">
|
||||
JSON file: <input type="file" name="data" accept=".json"> <input type="button"
|
||||
value="Upload" onclick='uploadFile("/ir.json")'><br></div><div id="toast"></div>
|
||||
<a href="https://kno.wled.ge/interfaces/infrared/" target="_blank">IR info</a>
|
||||
<br>Relay GPIO: <input type="number" min="-1" max="33" name="RL"
|
||||
onchange="UI()" class="xs"> Invert <input type="checkbox" name="RM"><span
|
||||
style="cursor:pointer" onclick='off("RL")'> ×</span><br><hr
|
||||
style="width:260px"><h3>Defaults</h3>Turn LEDs on after power up/reset: <input
|
||||
type="checkbox" name="BO"><br>Default brightness: <input name="CA"
|
||||
|
4348
wled00/html_ui.h
4348
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@ -388,7 +388,10 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool fo
|
||||
root["on"] = seg.getOption(SEG_OPTION_ON);
|
||||
byte segbri = seg.opacity;
|
||||
root["bri"] = (segbri) ? segbri : 255;
|
||||
root["cct"] = seg.cct;
|
||||
uint16_t cct = seg.cct;
|
||||
if (cct >= 1900) cct = (cct - 1900) >> 5; //convert K to 0-255
|
||||
if (cct > 255) cct = 255;
|
||||
root["cct"] = cct;
|
||||
|
||||
if (segmentBounds && seg.name != nullptr) root["n"] = reinterpret_cast<const char *>(seg.name); //not good practice, but decreases required JSON buffer
|
||||
|
||||
@ -512,7 +515,7 @@ void serializeInfo(JsonObject root)
|
||||
switch (bus->getType()) {
|
||||
case TYPE_ANALOG_5CH:
|
||||
case TYPE_ANALOG_2CH:
|
||||
leds["cct"] = true;
|
||||
if (!cctFromRgb) leds["cct"] = true;
|
||||
break;
|
||||
}
|
||||
switch (bus->getAutoWhiteMode()) {
|
||||
|
@ -96,6 +96,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
|
||||
autoSegments = request->hasArg(F("MS"));
|
||||
correctWB = request->hasArg(F("CCT"));
|
||||
cctFromRgb = request->hasArg(F("CR"));
|
||||
|
||||
for (uint8_t s = 0; s < WLED_MAX_BUSSES; s++) {
|
||||
char lp[4] = "L0"; lp[2] = 48+s; lp[3] = 0; //ascii 0-9 //strip data pin
|
||||
|
@ -269,7 +269,8 @@ WLED_GLOBAL byte bootPreset _INIT(0); // save preset to load
|
||||
//if false, only one segment spanning the total LEDs is created,
|
||||
//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
|
||||
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 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
|
||||
|
@ -371,6 +371,7 @@ void getSettingsJS(byte subPage, char* dest)
|
||||
|
||||
sappend('c',SET_F("MS"),autoSegments);
|
||||
sappend('c',SET_F("CCT"),correctWB);
|
||||
sappend('c',SET_F("CR"),cctFromRgb);
|
||||
|
||||
for (uint8_t s=0; s < busses.getNumBusses(); s++) {
|
||||
Bus* bus = busses.getBus(s);
|
||||
|
Loading…
Reference in New Issue
Block a user