From ac73febc9c66217e03649bd471c5fc054b5937a9 Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 21 May 2026 17:21:44 +0800 Subject: [PATCH] Enhance DALI command handling: add support for repeated forward commands and introduce delay for specific commands Signed-off-by: Tony --- src/addr.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/addr.cpp b/src/addr.cpp index 787fe6b..ed49c44 100644 --- a/src/addr.cpp +++ b/src/addr.cpp @@ -229,14 +229,30 @@ DaliCompareAddrResult DaliAddr::compareAddr(int ad, std::optional /*minH*/, int DaliAddr::compareMulti(int h, int m, int l, int ad) { int addr = ad + 1; int retL = l; + int retM = m; + int retH = h; for (int i = 0; i < 64; i++) { if (!base_.isAllocAddr) return addr - 1; - retL++; - if (retL > 255) break; + if (addr > 63) { + return addr - 1; + } - const auto ok = base_.compare(h, m, retL); + retL++; + if (retL > 255) { + retL = 0; + retM++; + if (retM > 255) { + retM = 0; + retH++; + if (retH > 255) { + break; + } + } + } + + const auto ok = base_.compare(retH, retM, retL); if (!ok.has_value() || !ok.value()) { addr--; break; @@ -246,6 +262,9 @@ int DaliAddr::compareMulti(int h, int m, int l, int ad) { const auto status = base_.getOnlineStatus(addr); if (!status.has_value() || !status.value()) break; addr++; + if (addr > 63) { + return addr - 1; + } } if (!base_.programShortAddr(addr)) continue;