Skip to content

Commit d66e915

Browse files
authored
Store a list of arrays at each location so duplicates aren't lost (#1844)
* Store a list of arrays at each location so duplicates aren't lost * Update changelog --------- Co-authored-by: Anonymous <>
1 parent 33b5c6f commit d66e915

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ To run Hyperion with root privileges (e.g. for WS281x) execute <br> `sudo update
388388
- Fixed: Nanoleaf does not turn on
389389
- Fixed LED layout - Additional parameters for classic layout were not saved (#1314)
390390
- Fixed Network LED-Device UI: Trigger getProperties for the configured host, when no hosts were discovered
391+
- Fixed Nanoleaf error if LEDs in strip overlap
391392

392393
### Removed:
393394

libsrc/leddevice/dev_net/LedDeviceNanoleaf.cpp

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ bool LedDeviceNanoleaf::initLedsConfiguration()
272272
int panelNum = jsonLayout[PANEL_NUM].toInt();
273273
const QJsonArray positionData = jsonLayout[PANEL_POSITIONDATA].toArray();
274274

275-
std::map<int, std::map<int, int>> panelMap;
275+
std::map<int, std::map<int, std::vector<int>>> panelMap;
276276

277277
// Loop over all children.
278278
for (const QJsonValue& value : positionData)
@@ -299,8 +299,14 @@ bool LedDeviceNanoleaf::initLedsConfiguration()
299299

300300
if (hasLEDs(static_cast<SHAPETYPES>(panelshapeType)))
301301
{
302-
panelMap[panelY][panelX] = panelId;
303-
DebugIf(verbose, _log, "Use Panel [%d] (%d,%d) - Type: [%d]", panelId, panelX, panelY, panelshapeType);
302+
panelMap[panelY][panelX];
303+
panelMap[panelY][panelX].push_back(panelId);
304+
if (panelMap[panelY][panelX].size() > 1) {
305+
DebugIf(verbose, _log, "Use Panel [%d] (%d,%d) - Type: [%d] (Ovarlapping %d other Panels)", panelId, panelX, panelY, panelshapeType, panelMap[panelY][panelX].size() - 1);
306+
} else {
307+
DebugIf(verbose, _log, "Use Panel [%d] (%d,%d) - Type: [%d]", panelId, panelX, panelY, panelshapeType);
308+
}
309+
304310
}
305311
else
306312
{
@@ -317,15 +323,18 @@ bool LedDeviceNanoleaf::initLedsConfiguration()
317323
{
318324
for (auto posX = posY->second.cbegin(); posX != posY->second.cend(); ++posX)
319325
{
320-
DebugIf(verbose, _log, "panelMap[%d][%d]=%d", posY->first, posX->first, posX->second);
321-
322-
if (_topDown)
323-
{
324-
_panelIds.push_back(posX->second);
325-
}
326-
else
326+
for (auto ledId = posX->second.cbegin(); ledId != posX->second.cend(); ++ledId)
327327
{
328-
_panelIds.push_front(posX->second);
328+
DebugIf(verbose, _log, "panelMap[%d][%d]=%d", posY->first, posX->first, ledId);
329+
330+
if (_topDown)
331+
{
332+
_panelIds.push_back(*ledId);
333+
}
334+
else
335+
{
336+
_panelIds.push_front(*ledId);
337+
}
329338
}
330339
}
331340
}
@@ -334,15 +343,18 @@ bool LedDeviceNanoleaf::initLedsConfiguration()
334343
// Sort panels right to left
335344
for (auto posX = posY->second.crbegin(); posX != posY->second.crend(); ++posX)
336345
{
337-
DebugIf(verbose, _log, "panelMap[%d][%d]=%d", posY->first, posX->first, posX->second);
338-
339-
if (_topDown)
340-
{
341-
_panelIds.push_back(posX->second);
342-
}
343-
else
346+
for (auto ledId = posX->second.cbegin(); ledId != posX->second.cend(); ++ledId)
344347
{
345-
_panelIds.push_front(posX->second);
348+
DebugIf(verbose, _log, "panelMap[%d][%d]=%d", posY->first, posX->first, ledId);
349+
350+
if (_topDown)
351+
{
352+
_panelIds.push_back(*ledId);
353+
}
354+
else
355+
{
356+
_panelIds.push_front(*ledId);
357+
}
346358
}
347359
}
348360
}

0 commit comments

Comments
 (0)