diff options
| author | Nick Brassel <nick@tzarc.org> | 2020-08-05 15:11:06 +1000 |
|---|---|---|
| committer | James Young <18669334+noroadsleft@users.noreply.github.com> | 2020-08-29 14:30:02 -0700 |
| commit | c990dc1e6cdcabbfe280d60e981f9e7cc733d5db (patch) | |
| tree | 59941e361683e69d0c443115277d7a0488a1f83b /quantum | |
| parent | 200444f8d2c12ac04fd081745c74020c92d5da16 (diff) | |
| download | qmk_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.
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/color.c | 26 | ||||
| -rw-r--r-- | quantum/color.h | 1 |
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 @@ | |||
| 18 | #include "led_tables.h" | 18 | #include "led_tables.h" |
| 19 | #include "progmem.h" | 19 | #include "progmem.h" |
| 20 | 20 | ||
| 21 | RGB hsv_to_rgb(HSV hsv) { | 21 | RGB 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 | ||
| 99 | RGB 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 | |||
| 107 | RGB 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 | ||
| 66 | RGB hsv_to_rgb(HSV hsv); | 66 | RGB hsv_to_rgb(HSV hsv); |
| 67 | RGB hsv_to_rgb_nocie(HSV hsv); | ||
| 67 | #ifdef RGBW | 68 | #ifdef RGBW |
| 68 | void convert_rgb_to_rgbw(LED_TYPE *led); | 69 | void convert_rgb_to_rgbw(LED_TYPE *led); |
| 69 | #endif | 70 | #endif |
