aboutsummaryrefslogtreecommitdiffstats
path: root/quantum
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 /quantum
parent200444f8d2c12ac04fd081745c74020c92d5da16 (diff)
downloadfirmware-c990dc1e6cdcabbfe280d60e981f9e7cc733d5db.tar.gz
firmware-c990dc1e6cdcabbfe280d60e981f9e7cc733d5db.tar.bz2
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.
Diffstat (limited to 'quantum')
-rw-r--r--quantum/color.c26
-rw-r--r--quantum/color.h1
2 files changed, 24 insertions, 3 deletions
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 @@
#include "led_tables.h"
#include "progmem.h"
-RGB hsv_to_rgb(HSV hsv) {
+RGB hsv_to_rgb_impl(HSV hsv, bool use_cie) {
RGB rgb;
uint8_t region, remainder, p, q, t;
uint16_t h, s, v;
if (hsv.s == 0) {
#ifdef USE_CIE1931_CURVE
- rgb.r = rgb.g = rgb.b = pgm_read_byte(&CIE1931_CURVE[hsv.v]);
+ if (use_cie) {
+ rgb.r = rgb.g = rgb.b = pgm_read_byte(&CIE1931_CURVE[hsv.v]);
+ } else {
+ rgb.r = hsv.v;
+ rgb.g = hsv.v;
+ rgb.b = hsv.v;
+ }
#else
rgb.r = hsv.v;
rgb.g = hsv.v;
@@ -37,7 +43,11 @@ RGB hsv_to_rgb(HSV hsv) {
h = hsv.h;
s = hsv.s;
#ifdef USE_CIE1931_CURVE
- v = pgm_read_byte(&CIE1931_CURVE[hsv.v]);
+ if (use_cie) {
+ v = pgm_read_byte(&CIE1931_CURVE[hsv.v]);
+ } else {
+ v = hsv.v;
+ }
#else
v = hsv.v;
#endif
@@ -86,6 +96,16 @@ RGB hsv_to_rgb(HSV hsv) {
return rgb;
}
+RGB hsv_to_rgb(HSV hsv) {
+#ifdef USE_CIE1931_CURVE
+ return hsv_to_rgb_impl(hsv, true);
+#else
+ return hsv_to_rgb_impl(hsv, false);
+#endif
+}
+
+RGB hsv_to_rgb_nocie(HSV hsv) { return hsv_to_rgb_impl(hsv, false); }
+
#ifdef RGBW
# ifndef MIN
# 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 {
#endif
RGB hsv_to_rgb(HSV hsv);
+RGB hsv_to_rgb_nocie(HSV hsv);
#ifdef RGBW
void convert_rgb_to_rgbw(LED_TYPE *led);
#endif