diff --git a/src/screen.cpp b/src/screen.cpp index 3201d73..b19ce6d 100644 --- a/src/screen.cpp +++ b/src/screen.cpp @@ -111,7 +111,7 @@ void Screen_::setPixelAtIndex(uint8_t index, uint8_t value, uint8_t brightness) { if (index >= 0 && index < COLS * ROWS) { - this->renderBuffer_[index] = value * brightness; + this->renderBuffer_[index] = value <= 0 || brightness <= 0 ? 0 : (brightness > 255 ? 255 : brightness); } } @@ -119,7 +119,7 @@ void Screen_::setPixel(uint8_t x, uint8_t y, uint8_t value, uint8_t brightness) { if (x >= 0 && y >= 0 && x < 16 && y < 16) { - this->renderBuffer_[y * 16 + x] = value * brightness; + this->renderBuffer_[y * 16 + x] = value <= 0 || brightness <= 0 ? 0 : (brightness > 255 ? 255 : brightness); } }