diff options
author | Xyverz <xyverz@gmail.com> | 2017-02-11 21:57:54 -0800 |
---|---|---|
committer | Xyverz <xyverz@gmail.com> | 2017-02-11 21:57:54 -0800 |
commit | 719f6f02934951c84add9dfe74378f7f9070a1e2 (patch) | |
tree | 5044e50ec4d6c50990e80a421cce195dff63fb11 /keyboards/handwired/promethium/rgbsps.c | |
parent | 489415009491847ac1855ef5586e2fdcf303aa19 (diff) | |
parent | a0c2305bd1153d9d578d73effd33896c2dbc26c8 (diff) | |
download | qmk_firmware-719f6f02934951c84add9dfe74378f7f9070a1e2.tar.gz |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'keyboards/handwired/promethium/rgbsps.c')
-rw-r--r-- | keyboards/handwired/promethium/rgbsps.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/keyboards/handwired/promethium/rgbsps.c b/keyboards/handwired/promethium/rgbsps.c index ea922ec3f..f30badd35 100644 --- a/keyboards/handwired/promethium/rgbsps.c +++ b/keyboards/handwired/promethium/rgbsps.c @@ -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); +} + |