FIX pixels outside Display check

This commit is contained in:
Patrick Haßel 2025-08-26 19:05:24 +02:00
parent 87509eb5f1
commit 2613a099a7

View File

@ -54,7 +54,6 @@ class Display {
}
public:
explicit Display(): leds(8 * 32, GPIO_NUM_13,NEO_GRB + NEO_KHZ800) {
//
}
@ -86,11 +85,11 @@ public:
}
void setPixel(const int x, const int y, const Color &color) {
const auto index = mapPixel(x, y);
if (index >= 8 * 32) {
Serial.printf("[ERROR] No pixel at (%d, %d) = %d >= %d\n", x, y, index, 8 * 32);
if (x >= 32 || y >= 8) {
Serial.printf("[ERROR] No pixel at (%d, %d) >= %d\n", x, y, 8 * 32);
return;
}
const auto index = mapPixel(x, y);
#if LEDS_ENABLED
leds.setPixelColor(index, color.r, color.g, color.b);
#endif
@ -155,7 +154,8 @@ public:
}
template<int symbolHeight, int symbolWidth>
int printSymbol(const int x, const int y, const int index, const Color &color, const bool symbols[][symbolHeight][symbolWidth]) {
int printSymbol(const int x, const int y, const int index, const Color &color,
const bool symbols[][symbolHeight][symbolWidth]) {
for (int innerY = 0; innerY < symbolHeight; innerY++) {
for (int innerX = 0; innerX < symbolWidth; innerX++) {
if (symbols[index][innerY][innerX]) {