Skip to content

Commit

Permalink
Merge pull request #64 from ph1p/bugfix/brightness
Browse files Browse the repository at this point in the history
fix(brightness): add brightness boundaries
  • Loading branch information
ph1p authored Nov 20, 2023
2 parents 2abb613 + ff99325 commit 0f163bd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ 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);
}
}

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);
}
}

Expand Down

0 comments on commit 0f163bd

Please sign in to comment.