v.0.0.5 short description for __builtin_clz
This commit is contained in:
@@ -19,6 +19,16 @@ uint8_t LedMatrix::charWidth(const uint8_t *charMatrix)
|
|||||||
if (charMatrix[i] > max_val)
|
if (charMatrix[i] > max_val)
|
||||||
max_val = charMatrix[i];
|
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));
|
return (max_val == 0) ? 0 : (32 - __builtin_clz(max_val));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user