Skip to content

Commit 768d6c0

Browse files
authored
Merge branch 'wled:main' into main
2 parents 9dc4472 + 93e011d commit 768d6c0

File tree

17 files changed

+144
-74
lines changed

17 files changed

+144
-74
lines changed

wled00/FXparticleSystem.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ void ParticleSystem2D::render() {
601601
hsv2rgb(baseHSV, baseRGB.color32); // convert back to RGB
602602
}
603603
}
604-
if(gammaCorrectBri) brightness = gamma8(brightness); // apply gamma correction, used for gamma-inverted brightness distribution
604+
if(gammaCorrectCol) brightness = gamma8(brightness); // apply gamma correction, used for gamma-inverted brightness distribution
605605
renderParticle(i, brightness, baseRGB, particlesettings.wrapX, particlesettings.wrapY);
606606
}
607607

@@ -675,7 +675,7 @@ __attribute__((optimize("O2"))) void ParticleSystem2D::renderParticle(const uint
675675
// - scale brigthness with gamma correction (done in render())
676676
// - apply inverse gamma correction to brightness values
677677
// - gamma is applied again in show() -> the resulting brightness distribution is linear but gamma corrected in total
678-
if(gammaCorrectBri) {
678+
if(gammaCorrectCol) {
679679
pxlbrightness[0] = gamma8inv(pxlbrightness[0]); // use look-up-table for invers gamma
680680
pxlbrightness[1] = gamma8inv(pxlbrightness[1]);
681681
pxlbrightness[2] = gamma8inv(pxlbrightness[2]);
@@ -1458,7 +1458,7 @@ void ParticleSystem1D::render() {
14581458
hsv2rgb(baseHSV, baseRGB.color32); // convert back to RGB
14591459
}
14601460
}
1461-
if(gammaCorrectBri) brightness = gamma8(brightness); // apply gamma correction, used for gamma-inverted brightness distribution
1461+
if(gammaCorrectCol) brightness = gamma8(brightness); // apply gamma correction, used for gamma-inverted brightness distribution
14621462
renderParticle(i, brightness, baseRGB, particlesettings.wrap);
14631463
}
14641464
// apply smear-blur to rendered frame
@@ -1519,7 +1519,7 @@ __attribute__((optimize("O2"))) void ParticleSystem1D::renderParticle(const uint
15191519
// - scale brigthness with gamma correction (done in render())
15201520
// - apply inverse gamma correction to brightness values
15211521
// - gamma is applied again in show() -> the resulting brightness distribution is linear but gamma corrected in total
1522-
if(gammaCorrectBri) {
1522+
if(gammaCorrectCol) {
15231523
pxlbrightness[0] = gamma8inv(pxlbrightness[0]); // use look-up-table for invers gamma
15241524
pxlbrightness[1] = gamma8inv(pxlbrightness[1]);
15251525
}

wled00/bus_manager.cpp

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <Arduino.h>
66
#include <IPAddress.h>
77
#ifdef ARDUINO_ARCH_ESP32
8+
#include <ESPmDNS.h>
9+
#include "src/dependencies/network/Network.h" // for isConnected() (& WiFi)
810
#include "driver/ledc.h"
911
#include "soc/ledc_struct.h"
1012
#if !(defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32S3))
@@ -25,6 +27,7 @@
2527
#include "bus_wrapper.h"
2628
#include <bits/unique_ptr.h>
2729

30+
extern char cmDNS[];
2831
extern bool cctICused;
2932
extern bool useParallelI2S;
3033

@@ -102,7 +105,7 @@ void Bus::calculateCCT(uint32_t c, uint8_t &ww, uint8_t &cw) {
102105
} else {
103106
cct = (approximateKelvinFromRGB(c) - 1900) >> 5; // convert K (from RGB value) to relative format
104107
}
105-
108+
106109
//0 - linear (CCT 127 = 50% warm, 50% cold), 127 - additive CCT blending (CCT 127 = 100% warm, 100% cold)
107110
if (cct < _cctBlend) ww = 255;
108111
else ww = ((255-cct) * 255) / (255 - _cctBlend);
@@ -699,6 +702,10 @@ BusNetwork::BusNetwork(const BusConfig &bc)
699702
_hasCCT = false;
700703
_UDPchannels = _hasWhite + 3;
701704
_client = IPAddress(bc.pins[0],bc.pins[1],bc.pins[2],bc.pins[3]);
705+
#ifdef ARDUINO_ARCH_ESP32
706+
_hostname = bc.text;
707+
resolveHostname(); // resolve hostname to IP address if needed
708+
#endif
702709
_data = (uint8_t*)d_calloc(_len, _UDPchannels);
703710
_valid = (_data != nullptr);
704711
DEBUGBUS_PRINTF_P(PSTR("%successfully inited virtual strip with type %u and IP %u.%u.%u.%u\n"), _valid?"S":"Uns", bc.type, bc.pins[0], bc.pins[1], bc.pins[2], bc.pins[3]);
@@ -733,6 +740,19 @@ size_t BusNetwork::getPins(uint8_t* pinArray) const {
733740
return 4;
734741
}
735742

743+
#ifdef ARDUINO_ARCH_ESP32
744+
void BusNetwork::resolveHostname() {
745+
static unsigned long nextResolve = 0;
746+
if (Network.isConnected() && millis() > nextResolve && _hostname.length() > 0) {
747+
nextResolve = millis() + 600000; // resolve only every 10 minutes
748+
IPAddress clnt;
749+
if (strlen(cmDNS) > 0) clnt = MDNS.queryHost(_hostname);
750+
else WiFi.hostByName(_hostname.c_str(), clnt);
751+
if (clnt != IPAddress()) _client = clnt;
752+
}
753+
}
754+
#endif
755+
736756
// credit @willmmiles & @netmindz https://github.com/wled/WLED/pull/4056
737757
std::vector<LEDType> BusNetwork::getLEDTypes() {
738758
return {
@@ -918,6 +938,13 @@ void BusManager::on() {
918938
}
919939
}
920940
}
941+
#else
942+
for (auto &bus : busses) if (bus->isVirtual()) {
943+
// virtual/network bus should check for IP change if hostname is specified
944+
// otherwise there are no endpoints to force DNS resolution
945+
BusNetwork &b = static_cast<BusNetwork&>(*bus);
946+
b.resolveHostname();
947+
}
921948
#endif
922949
#ifdef ESP32_DATA_IDLE_HIGH
923950
esp32RMTInvertIdle();

wled00/bus_manager.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ class Bus {
133133
virtual uint16_t getUsedCurrent() const { return 0; }
134134
virtual uint16_t getMaxCurrent() const { return 0; }
135135
virtual size_t getBusSize() const { return sizeof(Bus); }
136+
virtual const String getCustomText() const { return String(); }
136137

137138
inline bool hasRGB() const { return _hasRgb; }
138139
inline bool hasWhite() const { return _hasWhite; }
@@ -215,7 +216,7 @@ class Bus {
215216
uint8_t _autoWhiteMode;
216217
// global Auto White Calculation override
217218
static uint8_t _gAWM;
218-
// _cct has the following menaings (see calculateCCT() & BusManager::setSegmentCCT()):
219+
// _cct has the following meanings (see calculateCCT() & BusManager::setSegmentCCT()):
219220
// -1 means to extract approximate CCT value in K from RGB (in calcualteCCT())
220221
// [0,255] is the exact CCT value where 0 means warm and 255 cold
221222
// [1900,10060] only for color correction expressed in K (colorBalanceFromKelvin())
@@ -342,6 +343,10 @@ class BusNetwork : public Bus {
342343
size_t getBusSize() const override { return sizeof(BusNetwork) + (isOk() ? _len * _UDPchannels : 0); }
343344
void show() override;
344345
void cleanup();
346+
#ifdef ARDUINO_ARCH_ESP32
347+
void resolveHostname();
348+
const String getCustomText() const override { return _hostname; }
349+
#endif
345350

346351
static std::vector<LEDType> getLEDTypes();
347352

@@ -351,6 +356,9 @@ class BusNetwork : public Bus {
351356
uint8_t _UDPchannels;
352357
bool _broadcastLock;
353358
uint8_t *_data;
359+
#ifdef ARDUINO_ARCH_ESP32
360+
String _hostname;
361+
#endif
354362
};
355363

356364

@@ -368,8 +376,9 @@ struct BusConfig {
368376
uint16_t frequency;
369377
uint8_t milliAmpsPerLed;
370378
uint16_t milliAmpsMax;
379+
String text;
371380

372-
BusConfig(uint8_t busType, uint8_t* ppins, uint16_t pstart, uint16_t len = 1, uint8_t pcolorOrder = COL_ORDER_GRB, bool rev = false, uint8_t skip = 0, byte aw=RGBW_MODE_MANUAL_ONLY, uint16_t clock_kHz=0U, uint8_t maPerLed=LED_MILLIAMPS_DEFAULT, uint16_t maMax=ABL_MILLIAMPS_DEFAULT)
381+
BusConfig(uint8_t busType, uint8_t* ppins, uint16_t pstart, uint16_t len = 1, uint8_t pcolorOrder = COL_ORDER_GRB, bool rev = false, uint8_t skip = 0, byte aw=RGBW_MODE_MANUAL_ONLY, uint16_t clock_kHz=0U, uint8_t maPerLed=LED_MILLIAMPS_DEFAULT, uint16_t maMax=ABL_MILLIAMPS_DEFAULT, String sometext = "")
373382
: count(std::max(len,(uint16_t)1))
374383
, start(pstart)
375384
, colorOrder(pcolorOrder)
@@ -379,6 +388,7 @@ struct BusConfig {
379388
, frequency(clock_kHz)
380389
, milliAmpsPerLed(maPerLed)
381390
, milliAmpsMax(maMax)
391+
, text(sometext)
382392
{
383393
refreshReq = (bool) GET_BIT(busType,7);
384394
type = busType & 0x7F; // bit 7 may be/is hacked to include refresh info (1=refresh in off state, 0=no refresh)

wled00/cfg.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,8 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
235235
}
236236
ledType |= refresh << 7; // hack bit 7 to indicate strip requires off refresh
237237

238-
busConfigs.emplace_back(ledType, pins, start, length, colorOrder, reversed, skipFirst, AWmode, freqkHz, maPerLed, maMax);
238+
String host = elm[F("text")] | String();
239+
busConfigs.emplace_back(ledType, pins, start, length, colorOrder, reversed, skipFirst, AWmode, freqkHz, maPerLed, maMax, host);
239240
doInitBusses = true; // finalization done in beginStrip()
240241
if (!Bus::isVirtual(ledType)) s++; // have as many virtual buses as you want
241242
}
@@ -379,7 +380,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
379380
DEBUG_PRINTF_P(PSTR("PIN ALLOC error: GPIO%d for touch button #%d is not a touch pin!\n"), btnPin[s], s);
380381
btnPin[s] = -1;
381382
PinManager::deallocatePin(pin,PinOwner::Button);
382-
}
383+
}
383384
//if touch pin, enable the touch interrupt on ESP32 S2 & S3
384385
#ifdef SOC_TOUCH_VERSION_2 // ESP32 S2 and S3 have a function to check touch state but need to attach an interrupt to do so
385386
else
@@ -976,6 +977,7 @@ void serializeConfig(JsonObject root) {
976977
ins[F("freq")] = bus->getFrequency();
977978
ins[F("maxpwr")] = bus->getMaxCurrent();
978979
ins[F("ledma")] = bus->getLEDCurrent();
980+
ins[F("text")] = bus->getCustomText();
979981
}
980982

981983
JsonArray hw_com = hw.createNestedArray(F("com"));
@@ -1340,4 +1342,4 @@ void serializeConfigSec() {
13401342
if (f) serializeJson(root, f);
13411343
f.close();
13421344
releaseJSONBufferLock();
1343-
}
1345+
}

wled00/data/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function isN(n) { return !isNaN(parseFloat(n)) && isFinite(n); } // isNumber
1313
// https://stackoverflow.com/questions/3885817/how-do-i-check-that-a-number-is-float-or-integer
1414
function isF(n) { return n === +n && n !== (n|0); } // isFloat
1515
function isI(n) { return n === +n && n === (n|0); } // isInteger
16-
function toggle(el) { gId(el).classList.toggle("hide"); gId('No'+el).classList.toggle("hide"); }
16+
function toggle(el) { gId(el).classList.toggle("hide"); let n = gId('No'+el); if (n) n.classList.toggle("hide"); }
1717
function tooltip(cont=null) {
1818
d.querySelectorAll((cont?cont+" ":"")+"[title]").forEach((element)=>{
1919
element.addEventListener("pointerover", ()=>{

wled00/data/index.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@
329329
<div>
330330
<button class="btn ibtn" onclick="requestJson()">Refresh</button>
331331
<button class="btn ibtn" onclick="toggleNodes()">Instance List</button>
332-
<button class="btn ibtn" onclick="window.open(getURL('/update'),'_self');">Update WLED</button>
332+
<button class="btn ibtn" onclick="window.open(getURL('/update'),'_self');" id="updBt">Update WLED</button>
333333
<button class="btn ibtn" id="resetbtn" onclick="cnfReset()">Reboot WLED</button>
334334
</div>
335335
<br>

wled00/data/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ function parseInfo(i) {
685685
gId("filter2D").classList.remove('hide');
686686
gId('bs').querySelectorAll('option[data-type="2D"]').forEach((o,i)=>{o.style.display='';});
687687
}
688+
gId("updBt").style.display = (i.opt & 1) ? '':'none';
688689
// if (i.noaudio) {
689690
// gId("filterVol").classList.add("hide");
690691
// gId("filterFreq").classList.add("hide");

wled00/data/settings_leds.htm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@
284284
gId("dig"+n+"l").style.display = (isD2P(t) || isPWM(t)) ? "inline":"none"; // bus clock speed / PWM speed (relative) (not On/Off)
285285
gId("rev"+n).innerHTML = isAna(t) ? "Inverted output":"Reversed"; // change reverse text for analog else (rotated 180°)
286286
//gId("psd"+n).innerHTML = isAna(t) ? "Index:":"Start:"; // change analog start description
287+
gId("net"+n+"h").style.display = isNet(t) && !is8266() ? "block" : "none"; // show host field for network types except on ESP8266
288+
if (!isNet(t) || is8266()) d.Sf["HS"+n].value = ""; // cleart host field if not network type or ESP8266
287289
});
288290
// display global white channel overrides
289291
gId("wc").style.display = (gRGBW) ? 'inline':'none';
@@ -466,6 +468,7 @@
466468
<span id="p2d${s}"></span><input type="number" name="L2${s}" class="s" onchange="UI();pinUpd(this);"/>
467469
<span id="p3d${s}"></span><input type="number" name="L3${s}" class="s" onchange="UI();pinUpd(this);"/>
468470
<span id="p4d${s}"></span><input type="number" name="L4${s}" class="s" onchange="UI();pinUpd(this);"/>
471+
<div id="net${s}h" class="hide">Host: <input type="text" name="HS${s}" maxlength="32" pattern="[a-zA-Z0-9_\\-]*" onchange="UI()"/>.local</div>
469472
<div id="dig${s}r" style="display:inline"><br><span id="rev${s}">Reversed</span>: <input type="checkbox" name="CV${s}"></div>
470473
<div id="dig${s}s" style="display:inline"><br>Skip first LEDs: <input type="number" name="SL${s}" min="0" max="255" value="0" oninput="UI()"></div>
471474
<div id="dig${s}f" style="display:inline"><br><span id="off${s}">Off Refresh</span>: <input id="rf${s}" type="checkbox" name="RF${s}"></div>

wled00/data/settings_sec.htm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ <h2>Security & Update setup</h2>
5353
Factory reset: <input type="checkbox" name="RS"><br>
5454
All settings and presets will be erased.<br><br>
5555
<div class="warn">&#9888; Unencrypted transmission. An attacker on the same network can intercept form data!</div>
56-
<hr>
56+
<span id="OTA"><hr>
5757
<h3>Software Update</h3>
5858
<button type="button" onclick="U()">Manual OTA Update</button><br>
5959
<div id="aOTA">Enable ArduinoOTA: <input type="checkbox" name="AO"></div>
6060
Only allow update from same network/WiFi: <input type="checkbox" name="SU"><br>
6161
<i class="warn">&#9888; If you are using multiple VLANs (i.e. IoT or guest network) either set PIN or disable this option.<br>
62-
Disabling this option will make your device less secure.</i><br>
62+
Disabling this option will make your device less secure.</i><br></span>
6363
<hr id="backup">
6464
<h3>Backup & Restore</h3>
6565
<div class="warn">&#9888; Restoring presets/configuration will OVERWRITE your current presets/configuration.<br>

wled00/data/style.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ input {
7979
input:disabled {
8080
color: #888;
8181
}
82+
input:invalid {
83+
color: #f00;
84+
}
8285
input[type="text"],
8386
input[type="number"],
8487
input[type="password"],
@@ -202,4 +205,4 @@ td {
202205
#btns select {
203206
width: 144px;
204207
}
205-
}
208+
}

0 commit comments

Comments
 (0)