From e34f179a8248eeb38c4d7911211a27eedeca3556 Mon Sep 17 00:00:00 2001 From: PaoloTK Date: Sat, 14 Sep 2024 22:35:50 +0200 Subject: [PATCH] fix pin conflict check logic --- wled00/FX_fcn.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index fe47ee5297..7c4f62a5b6 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1266,12 +1266,23 @@ void WS2812FX::finalizeInit() { bool clash; do { clash = false; - for (const auto &pin : defDataPins) { - if (pin == defPin[j]) { - defPin[j]++; - if (defPin[j] < WLED_NUM_PINS) clash = true; + // check for conflicts on current bus + for (const auto &pin : defPin) { + if (&pin != &defPin[j] && pin == defPin[j]) { + clash = true; + break; } } + // We already have a clash on current bus, no point checking next buses + if (!clash) { + // check for conflicts on next buses + for (unsigned k = pinsIndex + busPins; k < defNumPins; k++) { + if (defDataPins[k] == defPin[j]) { + clash = true; + break; + } + } + if (clash) defPin[j]++; } while (clash); } }