diff --git a/src/Display.h b/src/Display.h index 7e8d7c1..4c2b712 100644 --- a/src/Display.h +++ b/src/Display.h @@ -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 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]) {