X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=keyboards%2Fhandwired%2Fpromethium%2Frgbsps.c;h=84fac1ae1fd20c6e57508795d4cfc0e0f6203504;hb=fca03e15b9f111e614738d9dcce09e03c49e9409;hp=ea922ec3fde71af55635a962f0f62b9ac81081d7;hpb=df50bee5a88cacbd1f5fab98b26c2068646b61c0;p=qmk_firmware.git diff --git a/keyboards/handwired/promethium/rgbsps.c b/keyboards/handwired/promethium/rgbsps.c index ea922ec3f..84fac1ae1 100644 --- a/keyboards/handwired/promethium/rgbsps.c +++ b/keyboards/handwired/promethium/rgbsps.c @@ -1,4 +1,4 @@ -#include "light_ws2812.h" +#include "ws2812.h" #include "rgbsps.h" struct cRGB led[RGBSPS_NUM]; @@ -21,4 +21,53 @@ void rgbsps_turnoff(void) { void rgbsps_send(void) { ws2812_setleds(led, RGBSPS_NUM); -} \ No newline at end of file +} + +void rgbsps_sethsv(uint8_t index, uint16_t hue, uint8_t sat, uint8_t val) { + uint8_t r = 0, g = 0, b = 0, base, color; + + if (sat == 0) { // Acromatic color (gray). Hue doesn't mind. + r = val; + g = val; + b = val; + } else { + base = ((255 - sat) * val) >> 8; + color = (val - base) * (hue % 60) / 60; + + switch (hue / 60) { + case 0: + r = val; + g = base + color; + b = base; + break; + case 1: + r = val - color; + g = val; + b = base; + break; + case 2: + r = base; + g = val; + b = base + color; + break; + case 3: + r = base; + g = val - color; + b = val; + break; + case 4: + r = base + color; + g = base; + b = val; + break; + case 5: + r = val; + g = base; + b = val - color; + break; + } + } + + rgbsps_set(index, r, g, b); +} +