Accept hex color strings in individual LED API

Version bump to 0.13.0-b2 "Toki"
Fixed transition property not applying unless power/bri/color changed next
Moved transition field below segments (temporarily)
This commit is contained in:
cschwinne 2021-07-10 16:14:17 +02:00
parent 0862859f93
commit 6a8ed1192f
12 changed files with 2221 additions and 2211 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{
"name": "wled",
"version": "0.13.0-b1",
"version": "0.13.0-b2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "wled",
"version": "0.13.0-b1",
"version": "0.13.0-b2",
"description": "Tools for WLED project",
"main": "tools/cdata.js",
"directories": {

View File

@ -32,7 +32,7 @@ def bin_rename_copy(source, target, env):
release_name = _get_cpp_define_value(env, "WLED_RELEASE_NAME")
if release_name and os.getenv("WLED_RELEASE"):
if release_name:
_create_dirs(["release"])
version = _get_cpp_define_value(env, "WLED_VERSION")
release_file = "{}release{}WLED_{}_{}.bin".format(OUTPUT_DIR, os.path.sep, version, release_name)

View File

@ -236,7 +236,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
JsonObject if_sync_recv = if_sync["recv"];
CJSON(receiveNotificationBrightness, if_sync_recv["bri"]);
CJSON(receiveNotificationColor, if_sync_recv["col"]);
CJSON(receiveNotificationEffects, if_sync_recv[F("fx")]);
CJSON(receiveNotificationEffects, if_sync_recv["fx"]);
//! following line might be a problem if called after boot
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);

View File

@ -612,6 +612,9 @@ input[type=range]:active + .sliderbubble {
margin-top: 5px;
display: none;
}
#tt {
text-align: center;
}
.cl {
width: 42px;
@ -653,7 +656,7 @@ input[type=number], input[type=text] {
background: var(--c-3);
color: var(--c-f);
border: 0px solid white;
border-radius: 5px;
border-radius: 25px;
padding: 8px;
margin: 6px 6px 6px 0;
font-size: 19px;
@ -683,7 +686,6 @@ textarea {
input[type=text] {
width: 100px;
border-radius: 25px;
text-align: center;
}
@ -706,7 +708,6 @@ input[type=number]::-webkit-outer-spin-button {
}
.pln {
border-radius: 25px !important;
width: 67px !important;
margin: 0 2px 8px 0 !important;
text-align: center;
@ -723,6 +724,7 @@ input[type=number]::-webkit-outer-spin-button {
}
.segn {
border-radius: 5px !important;
margin: 3px 0 6px 0 !important;
}

View File

@ -153,6 +153,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>
</div>
<div id="Favorites" class="tabcontent">
@ -164,8 +165,7 @@
</div>
<div id="pcont">
Loading...
</div><br>
Transition <input id="tt" class="noslide" type="number" min="0" max="65.5" step="0.1" value="0.7">s
</div>
</div>
</div>

View File

@ -1062,6 +1062,11 @@ function requestJson(command, rinfo = true) {
{
command.v = true; //get complete API response
command.time = Math.floor(Date.now() / 1000);
var t = d.getElementById('tt');
if (t.validity.valid) {
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
}
@ -1156,7 +1161,6 @@ function requestJson(command, rinfo = true) {
function togglePower() {
isOn = !isOn;
var obj = {"on": isOn};
obj.transition = parseInt(d.getElementById('tt').value*10);
requestJson(obj);
}
@ -1543,7 +1547,6 @@ function setPalette(paletteId = null)
function setBri() {
var obj = {"bri": parseInt(d.getElementById('sliderBri').value)};
obj.transition = parseInt(d.getElementById('tt').value*10);
requestJson(obj);
}
@ -1756,7 +1759,6 @@ function setColor(sr) {
}
updateHex();
updateRgb();
obj.transition = parseInt(d.getElementById('tt').value*10);
requestJson(obj);
}

View File

@ -42,7 +42,7 @@ function B(){window.history.back()}function U(){document.getElementById("uf").st
.bt{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.3ch solid #333;display:inline-block;font-size:20px;margin:8px;margin-top:12px}input[type=file]{font-size:16px}body{font-family:Verdana,sans-serif;text-align:center;background:#222;color:#fff;line-height:200%}#msg{display:none}
</style></head><body><h2>WLED Software Update</h2><form method="POST"
action="/update" id="uf" enctype="multipart/form-data" onsubmit="U()">
Installed version: 0.13.0-b1<br>Download the latest binary: <a
Installed version: 0.13.0-b2<br>Download the latest binary: <a
href="https://github.com/Aircoookie/WLED/releases" target="_blank"><img
src="https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square">
</a><br><input type="file" class="bt" name="update" required><br><input

View File

@ -383,7 +383,7 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form
<h3>Software Update</h3><button type="button" onclick="U()">Manual OTA Update
</button><br>Enable ArduinoOTA: <input type="checkbox" name="AO"><br><h3>About
</h3><a href="https://github.com/Aircoookie/WLED/" target="_blank">WLED</a>
version 0.13.0-b1<br><br><a
version 0.13.0-b2<br><br><a
href="https://github.com/Aircoookie/WLED/wiki/Contributors-and-credits"
target="_blank">Contributors, dependencies and special thanks</a><br>
A huge thank you to everyone who helped me create WLED!<br><br>

File diff suppressed because it is too large Load Diff

View File

@ -110,13 +110,13 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
//temporary, strip object gets updated via colorUpdated()
if (id == strip.getMainSegmentId()) {
byte effectPrev = effectCurrent;
effectCurrent = elem[F("fx")] | effectCurrent;
effectCurrent = elem["fx"] | effectCurrent;
if (!presetId && effectCurrent != effectPrev) unloadPlaylist(); //stop playlist if active and FX changed manually
effectSpeed = elem[F("sx")] | effectSpeed;
effectIntensity = elem[F("ix")] | effectIntensity;
effectPalette = elem["pal"] | effectPalette;
} else { //permanent
byte fx = elem[F("fx")] | seg.mode;
byte fx = elem["fx"] | seg.mode;
if (fx != seg.mode && fx < strip.getModeCount()) {
strip.setMode(id, fx);
if (!presetId) unloadPlaylist(); //stop playlist if active and FX changed manually
@ -148,15 +148,19 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
stop = iarr[i];
set = 2;
}
} else {
JsonArray icol = iarr[i];
if (icol.isNull()) break;
byte sz = icol.size();
if (sz == 0 || sz > 4) break;
} else { //color
int rgbw[] = {0,0,0,0};
copyArray(icol, rgbw);
JsonArray icol = iarr[i];
if (!icol.isNull()) { //array, e.g. [255,0,0]
byte sz = icol.size();
if (sz > 0 || sz < 5) copyArray(icol, rgbw);
} else { //hex string, e.g. "FF0000"
byte brgbw[] = {0,0,0,0};
const char* hexCol = iarr[i];
if (colorFromHexString(brgbw, hexCol)) {
for (uint8_t c = 0; c < 4; c++) rgbw[c] = brgbw[c];
}
}
if (set < 2) stop = start + 1;
for (uint16_t i = start; i < stop; i++) {
@ -171,7 +175,7 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
} else { //return to regular effect
seg.setOption(SEG_OPTION_FREEZE, false);
}
return; // seg.hasChanged(prev);
return; // seg.differs(prev);
}
bool deserializeState(JsonObject root, byte callMode, byte presetId)
@ -214,6 +218,7 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId)
nightlightDelayMins = nl[F("dur")] | nightlightDelayMins;
nightlightMode = nl[F("mode")] | nightlightMode;
nightlightTargetBri = nl[F("tbri")] | nightlightTargetBri;
getJsonValue(nl[F("tbri")], nightlightTargetBri);
JsonObject udpn = root["udpn"];
notifyDirect = udpn["send"] | notifyDirect;
@ -358,7 +363,7 @@ void serializeSegment(JsonObject& root, WS2812FX::Segment& seg, byte id, bool fo
strcat(colstr,"]");
root["col"] = serialized(colstr);
root[F("fx")] = seg.mode;
root["fx"] = seg.mode;
root[F("sx")] = seg.speed;
root[F("ix")] = seg.intensity;
root["pal"] = seg.palette;

View File

@ -3,12 +3,12 @@
/*
Main sketch, global variable declarations
@title WLED project sketch
@version 0.13.0-b1
@version 0.13.0-b2
@author Christian Schwinne
*/
// version code in format yymmddb (b = daily build)
#define VERSION 2107091
#define VERSION 2107100
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG
@ -503,7 +503,7 @@ WLED_GLOBAL bool blynkEnabled _INIT(false);
//playlists
WLED_GLOBAL unsigned long presetCycledTime _INIT(0);
WLED_GLOBAL int16_t currentPlaylist _INIT(0);
WLED_GLOBAL int16_t currentPlaylist _INIT(-1);
//still used for "PL=~" HTTP API command
WLED_GLOBAL byte presetCycleMin _INIT(1), presetCycleMax _INIT(5);
WLED_GLOBAL byte presetCycCurr _INIT(presetCycleMin);