From 23b57b34b5b0fdea4ed2f84292b1b479f4cd1f5d Mon Sep 17 00:00:00 2001 From: tiijay Date: Tue, 4 Nov 2025 14:18:33 +0100 Subject: [PATCH] v.0.0.5 short description for __builtin_clz --- lib/LedMatrix/src/LedMatrix.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/LedMatrix/src/LedMatrix.cpp b/lib/LedMatrix/src/LedMatrix.cpp index ec3ef09..7d21ed8 100644 --- a/lib/LedMatrix/src/LedMatrix.cpp +++ b/lib/LedMatrix/src/LedMatrix.cpp @@ -19,6 +19,16 @@ uint8_t LedMatrix::charWidth(const uint8_t *charMatrix) if (charMatrix[i] > max_val) max_val = charMatrix[i]; } + // __builtin_clz liefert Anzahl der führenden Nullen (int Bereich (32 Bit)) + // Beispiele: für max_val + // 0 --> 32 + // 1 --> 31 + // 2 --> 30 + // 4 --> 29 + // 8 --> 28 ... etc. + // Deshalb 32 - Wert + // bei 8 -> 32-28 = 4.Bit + // bei 2 -> 32-20 = 2.Bit return (max_val == 0) ? 0 : (32 - __builtin_clz(max_val)); }