Skip to content

Commit

Permalink
Code cleanup; remove a use of min/max which does not belong in the co…
Browse files Browse the repository at this point in the history
…re due to arduino and c++ playing badly together
  • Loading branch information
obra committed Dec 9, 2024
1 parent 04104c0 commit 2004037
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,16 @@ Haunt::Haunt(const cRGB highlight_color) {
}

cRGB Haunt::compute(uint8_t *step) {
cRGB color = CRGB((uint8_t)min(*step * highlight_color_.r / 255, 255),
(uint8_t)min(*step * highlight_color_.g / 255, 255),
(uint8_t)min(*step * highlight_color_.b / 255, 255));
// Calculate scaled RGB values, capped at 255
uint16_t r = (*step * highlight_color_.r) / 255;
uint16_t g = (*step * highlight_color_.g) / 255;
uint16_t b = (*step * highlight_color_.b) / 255;

cRGB color = CRGB(
(uint8_t)(r < 255 ? r : 255),
(uint8_t)(g < 255 ? g : 255),
(uint8_t)(b < 255 ? b : 255)
);

if (*step >= 0xf0)
*step -= 1;
Expand Down

0 comments on commit 2004037

Please sign in to comment.