From 9bed2034e2c45868ed423e45da0948fbaa34bb2b Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 9 Dec 2024 14:53:09 -0800 Subject: [PATCH] Code cleanup; remove a use of min/max which does not belong in the core due to arduino and c++ playing badly together --- .../src/kaleidoscope/plugin/LED-Stalker.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/Kaleidoscope-LED-Stalker/src/kaleidoscope/plugin/LED-Stalker.cpp b/plugins/Kaleidoscope-LED-Stalker/src/kaleidoscope/plugin/LED-Stalker.cpp index 1470b5f8cc..a7db3a63d9 100644 --- a/plugins/Kaleidoscope-LED-Stalker/src/kaleidoscope/plugin/LED-Stalker.cpp +++ b/plugins/Kaleidoscope-LED-Stalker/src/kaleidoscope/plugin/LED-Stalker.cpp @@ -83,9 +83,15 @@ 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;