aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2020-08-05 15:11:06 +1000
committerJames Young <18669334+noroadsleft@users.noreply.github.com>2020-08-29 14:30:02 -0700
commitc990dc1e6cdcabbfe280d60e981f9e7cc733d5db (patch)
tree59941e361683e69d0c443115277d7a0488a1f83b
parent200444f8d2c12ac04fd081745c74020c92d5da16 (diff)
downloadqmk_firmware-c990dc1e6cdcabbfe280d60e981f9e7cc733d5db.tar.gz
qmk_firmware-c990dc1e6cdcabbfe280d60e981f9e7cc733d5db.zip
Add support for hsv->rgb conversion without using CIE curve. (#9856)
* Add support for hsv->rgb conversion without using CIE curve. * Modify anavi/macropad8 to disable unicode (was unused), otherwise firmware size is too large.
-rw-r--r--keyboards/anavi/macropad8/rules.mk1
-rw-r--r--quantum/color.c26
-rw-r--r--quantum/color.h1
3 files changed, 24 insertions, 4 deletions
diff --git a/keyboards/anavi/macropad8/rules.mk b/keyboards/anavi/macropad8/rules.mk
index 498c27a20..d4443e3fe 100644
--- a/keyboards/anavi/macropad8/rules.mk
+++ b/keyboards/anavi/macropad8/rules.mk
@@ -23,7 +23,6 @@ NKRO_ENABLE = yes # Nkey Rollover - if this doesn't work, see here: ht
23BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality 23BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality
24MIDI_ENABLE = no # MIDI controls 24MIDI_ENABLE = no # MIDI controls
25AUDIO_ENABLE = no # Audio output on port C6 25AUDIO_ENABLE = no # Audio output on port C6
26UNICODE_ENABLE = yes # Unicode
27BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID 26BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
28RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. 27RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight.
29OLED_DRIVER_ENABLE = yes # Enable Support for SSD1306 or SH1106 OLED Displays; Communicating over I2C 28OLED_DRIVER_ENABLE = yes # Enable Support for SSD1306 or SH1106 OLED Displays; Communicating over I2C
diff --git a/quantum/color.c b/quantum/color.c
index c05030062..1c5128e4a 100644
--- a/quantum/color.c
+++ b/quantum/color.c
@@ -18,14 +18,20 @@
18#include "led_tables.h" 18#include "led_tables.h"
19#include "progmem.h" 19#include "progmem.h"
20 20
21RGB hsv_to_rgb(HSV hsv) { 21RGB hsv_to_rgb_impl(HSV hsv, bool use_cie) {
22 RGB rgb; 22 RGB rgb;
23 uint8_t region, remainder, p, q, t; 23 uint8_t region, remainder, p, q, t;
24 uint16_t h, s, v; 24 uint16_t h, s, v;
25 25
26 if (hsv.s == 0) { 26 if (hsv.s == 0) {
27#ifdef USE_CIE1931_CURVE 27#ifdef USE_CIE1931_CURVE
28 rgb.r = rgb.g = rgb.b = pgm_read_byte(&CIE1931_CURVE[hsv.v]); 28 if (use_cie) {
29 rgb.r = rgb.g = rgb.b = pgm_read_byte(&CIE1931_CURVE[hsv.v]);
30 } else {
31 rgb.r = hsv.v;
32 rgb.g = hsv.v;
33 rgb.b = hsv.v;
34 }
29#else 35#else
30 rgb.r = hsv.v; 36 rgb.r = hsv.v;
31 rgb.g = hsv.v; 37 rgb.g = hsv.v;
@@ -37,7 +43,11 @@ RGB hsv_to_rgb(HSV hsv) {
37 h = hsv.h; 43 h = hsv.h;
38 s = hsv.s; 44 s = hsv.s;
39#ifdef USE_CIE1931_CURVE 45#ifdef USE_CIE1931_CURVE
40 v = pgm_read_byte(&CIE1931_CURVE[hsv.v]); 46 if (use_cie) {
47 v = pgm_read_byte(&CIE1931_CURVE[hsv.v]);
48 } else {
49 v = hsv.v;
50 }
41#else 51#else
42 v = hsv.v; 52 v = hsv.v;
43#endif 53#endif
@@ -86,6 +96,16 @@ RGB hsv_to_rgb(HSV hsv) {
86 return rgb; 96 return rgb;
87} 97}
88 98
99RGB hsv_to_rgb(HSV hsv) {
100#ifdef USE_CIE1931_CURVE
101 return hsv_to_rgb_impl(hsv, true);
102#else
103 return hsv_to_rgb_impl(hsv, false);
104#endif
105}
106
107RGB hsv_to_rgb_nocie(HSV hsv) { return hsv_to_rgb_impl(hsv, false); }
108
89#ifdef RGBW 109#ifdef RGBW
90# ifndef MIN 110# ifndef MIN
91# define MIN(a, b) ((a) < (b) ? (a) : (b)) 111# define MIN(a, b) ((a) < (b) ? (a) : (b))
diff --git a/quantum/color.h b/quantum/color.h
index 58d4f0407..5c5a0f0eb 100644
--- a/quantum/color.h
+++ b/quantum/color.h
@@ -64,6 +64,7 @@ typedef struct PACKED {
64#endif 64#endif
65 65
66RGB hsv_to_rgb(HSV hsv); 66RGB hsv_to_rgb(HSV hsv);
67RGB hsv_to_rgb_nocie(HSV hsv);
67#ifdef RGBW 68#ifdef RGBW
68void convert_rgb_to_rgbw(LED_TYPE *led); 69void convert_rgb_to_rgbw(LED_TYPE *led);
69#endif 70#endif