Skip to content

Commit 02c9d94

Browse files
committed
Editorial updates
1 parent dce1288 commit 02c9d94

File tree

3 files changed

+48
-56
lines changed

3 files changed

+48
-56
lines changed

assets/webconfig/js/content_leds.js

Lines changed: 43 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,6 +1412,7 @@ $(document).ready(function () {
14121412
break;
14131413

14141414
case "homeassistant":
1415+
{
14151416
const port = conf_editor.getEditor("root.specificOptions.port").getValue();
14161417
const useSsl = conf_editor.getEditor("root.specificOptions.useSsl").getValue();
14171418
const token = conf_editor.getEditor("root.specificOptions.token").getValue();
@@ -1421,17 +1422,20 @@ $(document).ready(function () {
14211422

14221423
params = { host, port, useSsl, token, filter: "states" };
14231424
getProperties_device(ledType, host, params);
1425+
}
14241426
break;
14251427

14261428
case "nanoleaf":
1427-
$('#btn_wiz_holder').show();
1429+
{
1430+
$('#btn_wiz_holder').show();
14281431

1429-
token = conf_editor.getEditor("root.specificOptions.token").getValue();
1430-
if (token === "") {
1431-
return;
1432+
const token = conf_editor.getEditor("root.specificOptions.token").getValue();
1433+
if (token === "") {
1434+
return;
1435+
}
1436+
params = { host, token };
1437+
getProperties_device(ledType, host, params);
14321438
}
1433-
params = { host, token };
1434-
getProperties_device(ledType, host, params);
14351439
break;
14361440

14371441
case "wled":
@@ -1591,21 +1595,25 @@ $(document).ready(function () {
15911595
let host = "";
15921596
switch (ledType) {
15931597
case "homeassistant":
1594-
host = conf_editor.getEditor("root.specificOptions.host").getValue();
1595-
if (host === "") {
1596-
return
1598+
{
1599+
host = conf_editor.getEditor("root.specificOptions.host").getValue();
1600+
if (host === "") {
1601+
return
1602+
}
1603+
const port = conf_editor.getEditor("root.specificOptions.port").getValue();
1604+
const useSsl = conf_editor.getEditor("root.specificOptions.useSsl").getValue();
1605+
params = { host, port, useSsl, token, filter: "states" };
15971606
}
1598-
const port = conf_editor.getEditor("root.specificOptions.port").getValue();
1599-
const useSsl = conf_editor.getEditor("root.specificOptions.useSsl").getValue();
1600-
params = { host, port, useSsl, token, filter: "states" };
16011607
break;
16021608

16031609
case "nanoleaf":
1604-
host = conf_editor.getEditor("root.specificOptions.host").getValue();
1605-
if (host === "") {
1606-
return
1610+
{
1611+
host = conf_editor.getEditor("root.specificOptions.host").getValue();
1612+
if (host === "") {
1613+
return
1614+
}
1615+
params = { host, token };
16071616
}
1608-
params = { host, token };
16091617
break;
16101618
default:
16111619
}
@@ -1617,48 +1625,38 @@ $(document).ready(function () {
16171625
conf_editor.watch('root.specificOptions.port', () => {
16181626

16191627
const port = conf_editor.getEditor("root.specificOptions.port").getValue();
1620-
16211628
if (port !== "") {
16221629
let params = {};
1630+
if (ledType === "homeassistant") {
1631+
const host = conf_editor.getEditor("root.specificOptions.host").getValue();
1632+
const token = conf_editor.getEditor("root.specificOptions.token").getValue();
16231633

1624-
switch (ledType) {
1625-
case "homeassistant":
1626-
const host = conf_editor.getEditor("root.specificOptions.host").getValue();
1627-
const token = conf_editor.getEditor("root.specificOptions.token").getValue();
1628-
1629-
if (host === "" || token == "") {
1630-
return
1631-
}
1632-
const useSsl = conf_editor.getEditor("root.specificOptions.useSsl").getValue();
1633-
params = { host, port, useSsl, token, filter: "states" };
1634-
1635-
getProperties_device(ledType, host, params);
1634+
if (host === "" || token == "") {
1635+
return
1636+
}
1637+
const useSsl = conf_editor.getEditor("root.specificOptions.useSsl").getValue();
1638+
params = { host, port, useSsl, token, filter: "states" };
16361639

1637-
break;
1640+
getProperties_device(ledType, host, params);
16381641
}
16391642
}
16401643
});
16411644

16421645
conf_editor.watch('root.specificOptions.useSsl', () => {
16431646

1644-
const useSsl = conf_editor.getEditor("root.specificOptions.useSsl").getValue();
1645-
16461647
let params = {};
1648+
if (ledType === "homeassistant") {
1649+
const host = conf_editor.getEditor("root.specificOptions.host").getValue();
1650+
const token = conf_editor.getEditor("root.specificOptions.token").getValue();
16471651

1648-
switch (ledType) {
1649-
case "homeassistant":
1650-
const host = conf_editor.getEditor("root.specificOptions.host").getValue();
1651-
const token = conf_editor.getEditor("root.specificOptions.token").getValue();
1652-
1653-
if (host === "" || token == "") {
1654-
return
1655-
}
1656-
const port = conf_editor.getEditor("root.specificOptions.port").getValue();
1657-
params = { host, port, useSsl, token, filter: "states" };
1658-
1659-
getProperties_device(ledType, host, params);
1652+
if (host === "" || token == "") {
1653+
return
1654+
}
1655+
const port = conf_editor.getEditor("root.specificOptions.port").getValue();
1656+
const useSsl = conf_editor.getEditor("root.specificOptions.useSsl").getValue();
1657+
params = { host, port, useSsl, token, filter: "states" };
16601658

1661-
break;
1659+
getProperties_device(ledType, host, params);
16621660
}
16631661
});
16641662

@@ -2876,5 +2874,3 @@ function nanoleafGeneratelayout(panelLayout, panelOrderTopDown, panelOrderLeftRi
28762874
});
28772875
return layoutObjects;
28782876
}
2879-
2880-

include/leddevice/LedDevice.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public slots:
209209
///
210210
/// @brief Update the color values of the device's LEDs.
211211
///
212-
/// Updates are skipped while another update is in progress to avoid queueing.
212+
/// Updates received while another updates is in progress are skipped to avoid queueing.
213213
///
214214
/// @param[in] ledValues The color per LED
215215
/// @return Zero on success else negative
@@ -511,8 +511,6 @@ private slots:
511511
///
512512
/// @brief Process LED updates requested.
513513
///
514-
/// @return Zero on success else negative
515-
///
516514
void processLedUpdate();
517515

518516
///
@@ -560,9 +558,7 @@ private slots:
560558
/// Last LED values written
561559
std::vector<ColorRgb> _lastLedValues;
562560

563-
// Member variables for the new logic
564-
// Use std::atomic for the flag. No mutex needed for it!
565-
std::atomic<bool> _isUpdatePending{ false };
561+
std::atomic<bool> _isLedUpdatePending{ false };
566562

567563
// The mutex now ONLY protects the data buffer.
568564
QMutex _ledBufferMutex;

libsrc/leddevice/LedDevice.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ int LedDevice::updateLeds(std::vector<ColorRgb> ledValues)
317317
}
318318

319319
// If a frame processing is NOT already scheduled, schedule one.
320-
if (!_isUpdatePending.exchange(true))
320+
if (!_isLedUpdatePending.exchange(true))
321321
{
322322
QTimer::singleShot(0, this, &LedDevice::processLedUpdate);
323323
}
@@ -335,7 +335,7 @@ void LedDevice::processLedUpdate()
335335

336336
writeLedUpdate(valuesToProcess);
337337

338-
_isUpdatePending.store(false);
338+
_isLedUpdatePending.store(false);
339339
}
340340

341341
int LedDevice::writeLedUpdate(const std::vector<ColorRgb>& ledValues)
@@ -377,7 +377,7 @@ int LedDevice::writeLedUpdate(const std::vector<ColorRgb>& ledValues)
377377
int LedDevice::rewriteLEDs()
378378
{
379379
bool expected = false;
380-
if (!_isUpdatePending.compare_exchange_strong(expected, true))
380+
if (!_isLedUpdatePending.compare_exchange_strong(expected, true))
381381
{
382382
// The flag was already true, meaning a write from updateLeds/processFrame is currently in progress or scheduled.
383383
// We can safely skip this refresh, as the other write will restart the timer.

0 commit comments

Comments
 (0)