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.
This commit is contained in:
committed by
Drashna Jael're
parent
9d4cbcd81e
commit
28947d5f54
@@ -18,14 +18,20 @@
|
|||||||
#include "led_tables.h"
|
#include "led_tables.h"
|
||||||
#include "progmem.h"
|
#include "progmem.h"
|
||||||
|
|
||||||
RGB hsv_to_rgb(HSV hsv) {
|
RGB hsv_to_rgb_impl(HSV hsv, bool use_cie) {
|
||||||
RGB rgb;
|
RGB rgb;
|
||||||
uint8_t region, remainder, p, q, t;
|
uint8_t region, remainder, p, q, t;
|
||||||
uint16_t h, s, v;
|
uint16_t h, s, v;
|
||||||
|
|
||||||
if (hsv.s == 0) {
|
if (hsv.s == 0) {
|
||||||
#ifdef USE_CIE1931_CURVE
|
#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
|
#else
|
||||||
rgb.r = hsv.v;
|
rgb.r = hsv.v;
|
||||||
rgb.g = hsv.v;
|
rgb.g = hsv.v;
|
||||||
@@ -37,7 +43,11 @@ RGB hsv_to_rgb(HSV hsv) {
|
|||||||
h = hsv.h;
|
h = hsv.h;
|
||||||
s = hsv.s;
|
s = hsv.s;
|
||||||
#ifdef USE_CIE1931_CURVE
|
#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
|
#else
|
||||||
v = hsv.v;
|
v = hsv.v;
|
||||||
#endif
|
#endif
|
||||||
@@ -87,6 +97,16 @@ RGB hsv_to_rgb(HSV hsv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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
|
#ifdef RGBW
|
||||||
# ifndef MIN
|
# ifndef MIN
|
||||||
# define MIN(a, b) ((a) < (b) ? (a) : (b))
|
# define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ typedef struct PACKED {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
RGB hsv_to_rgb(HSV hsv);
|
RGB hsv_to_rgb(HSV hsv);
|
||||||
|
RGB hsv_to_rgb_nocie(HSV hsv);
|
||||||
#ifdef RGBW
|
#ifdef RGBW
|
||||||
void convert_rgb_to_rgbw(LED_TYPE *led);
|
void convert_rgb_to_rgbw(LED_TYPE *led);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user