Switching rgb_config_t to use HSV struct
This commit is contained in:
parent
e717dcaa09
commit
cf215487ba
42 changed files with 126 additions and 118 deletions
|
|
@ -146,7 +146,7 @@ void rgb_matrix_indicators_user(void)
|
|||
break;
|
||||
|
||||
case _RGB: {
|
||||
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
HSV hsv = { rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v };
|
||||
HSV hui = hsv;
|
||||
HSV hud = hsv;
|
||||
HSV sai = hsv;
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ void rgb_matrix_indicators_user(void)
|
|||
break;
|
||||
|
||||
case _FNC: {
|
||||
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
HSV hsv = { rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v };
|
||||
HSV hui = hsv;
|
||||
HSV hud = hsv;
|
||||
HSV sai = hsv;
|
||||
|
|
|
|||
|
|
@ -128,9 +128,7 @@ void eeconfig_update_rgb_matrix_default(void) {
|
|||
dprintf("eeconfig_update_rgb_matrix_default\n");
|
||||
rgb_matrix_config.enable = 1;
|
||||
rgb_matrix_config.mode = RGB_MATRIX_STARTUP_MODE;
|
||||
rgb_matrix_config.hue = 0;
|
||||
rgb_matrix_config.sat = UINT8_MAX;
|
||||
rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
|
||||
rgb_matrix_config.hsv = (HSV){ 0, UINT8_MAX, RGB_MATRIX_MAXIMUM_BRIGHTNESS };
|
||||
rgb_matrix_config.speed = UINT8_MAX / 2;
|
||||
eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
|
||||
}
|
||||
|
|
@ -139,9 +137,9 @@ void eeconfig_debug_rgb_matrix(void) {
|
|||
dprintf("rgb_matrix_config eprom\n");
|
||||
dprintf("rgb_matrix_config.enable = %d\n", rgb_matrix_config.enable);
|
||||
dprintf("rgb_matrix_config.mode = %d\n", rgb_matrix_config.mode);
|
||||
dprintf("rgb_matrix_config.hue = %d\n", rgb_matrix_config.hue);
|
||||
dprintf("rgb_matrix_config.sat = %d\n", rgb_matrix_config.sat);
|
||||
dprintf("rgb_matrix_config.val = %d\n", rgb_matrix_config.val);
|
||||
dprintf("rgb_matrix_config.hsv.h = %d\n", rgb_matrix_config.hsv.h);
|
||||
dprintf("rgb_matrix_config.hsv.s = %d\n", rgb_matrix_config.hsv.s);
|
||||
dprintf("rgb_matrix_config.hsv.v = %d\n", rgb_matrix_config.hsv.v);
|
||||
dprintf("rgb_matrix_config.speed = %d\n", rgb_matrix_config.speed);
|
||||
}
|
||||
|
||||
|
|
@ -492,34 +490,34 @@ void rgb_matrix_step_reverse(void) {
|
|||
}
|
||||
|
||||
void rgb_matrix_increase_hue(void) {
|
||||
rgb_matrix_config.hue += RGB_MATRIX_HUE_STEP;
|
||||
rgb_matrix_config.hsv.h += RGB_MATRIX_HUE_STEP;
|
||||
eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
|
||||
}
|
||||
|
||||
void rgb_matrix_decrease_hue(void) {
|
||||
rgb_matrix_config.hue -= RGB_MATRIX_HUE_STEP;
|
||||
rgb_matrix_config.hsv.h -= RGB_MATRIX_HUE_STEP;
|
||||
eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
|
||||
}
|
||||
|
||||
void rgb_matrix_increase_sat(void) {
|
||||
rgb_matrix_config.sat = qadd8(rgb_matrix_config.sat, RGB_MATRIX_SAT_STEP);
|
||||
rgb_matrix_config.hsv.s = qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP);
|
||||
eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
|
||||
}
|
||||
|
||||
void rgb_matrix_decrease_sat(void) {
|
||||
rgb_matrix_config.sat = qsub8(rgb_matrix_config.sat, RGB_MATRIX_SAT_STEP);
|
||||
rgb_matrix_config.hsv.s = qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP);
|
||||
eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
|
||||
}
|
||||
|
||||
void rgb_matrix_increase_val(void) {
|
||||
rgb_matrix_config.val = qadd8(rgb_matrix_config.val, RGB_MATRIX_VAL_STEP);
|
||||
if (rgb_matrix_config.val > RGB_MATRIX_MAXIMUM_BRIGHTNESS)
|
||||
rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
|
||||
rgb_matrix_config.hsv.v = qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP);
|
||||
if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS)
|
||||
rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
|
||||
eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
|
||||
}
|
||||
|
||||
void rgb_matrix_decrease_val(void) {
|
||||
rgb_matrix_config.val = qsub8(rgb_matrix_config.val, RGB_MATRIX_VAL_STEP);
|
||||
rgb_matrix_config.hsv.v = qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP);
|
||||
eeconfig_update_rgb_matrix(rgb_matrix_config.raw);
|
||||
}
|
||||
|
||||
|
|
@ -561,9 +559,9 @@ void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) {
|
|||
}
|
||||
|
||||
void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) {
|
||||
rgb_matrix_config.hue = hue;
|
||||
rgb_matrix_config.sat = sat;
|
||||
rgb_matrix_config.val = val;
|
||||
if (rgb_matrix_config.val > RGB_MATRIX_MAXIMUM_BRIGHTNESS)
|
||||
rgb_matrix_config.val = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
|
||||
rgb_matrix_config.hsv.h = hue;
|
||||
rgb_matrix_config.hsv.s = sat;
|
||||
rgb_matrix_config.hsv.v = val;
|
||||
if (rgb_matrix_config.hsv.v > RGB_MATRIX_MAXIMUM_BRIGHTNESS)
|
||||
rgb_matrix_config.hsv.v = RGB_MATRIX_MAXIMUM_BRIGHTNESS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ RGB_MATRIX_EFFECT(ALPHAS_MODS)
|
|||
bool ALPHAS_MODS(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
HSV hsv = rgb_matrix_config.hsv;
|
||||
RGB rgb1 = hsv_to_rgb(hsv);
|
||||
hsv.h += rgb_matrix_config.speed;
|
||||
RGB rgb2 = hsv_to_rgb(hsv);
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@ RGB_MATRIX_EFFECT(BREATHING)
|
|||
bool BREATHING(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = rgb_matrix_config.hsv;
|
||||
uint16_t time = scale16by8(g_rgb_counters.tick, rgb_matrix_config.speed / 8);
|
||||
uint8_t val = scale8(abs8(sin8(time) - 128) * 2, rgb_matrix_config.val);
|
||||
HSV hsv = { rgb_matrix_config.hue, rgb_matrix_config.sat, val };
|
||||
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
RGB_MATRIX_TEST_LED_FLAGS();
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
RGB_MATRIX_EFFECT(BAND_PINWHEEL_SAT)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void BAND_PINWHEEL_SAT_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t time) {
|
||||
hsv->s = scale8(rgb_matrix_config.sat - time - atan2_8(dy, dx) * 3, rgb_matrix_config.sat);
|
||||
static HSV BAND_PINWHEEL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
|
||||
hsv.s = scale8(hsv.s - time - atan2_8(dy, dx) * 3, hsv.s);
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool BAND_PINWHEEL_SAT(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
RGB_MATRIX_EFFECT(BAND_PINWHEEL_VAL)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void BAND_PINWHEEL_VAL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t time) {
|
||||
hsv->v = scale8(rgb_matrix_config.val - time - atan2_8(dy, dx) * 3, rgb_matrix_config.val);
|
||||
static HSV BAND_PINWHEEL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
|
||||
hsv.v = scale8(hsv.v - time - atan2_8(dy, dx) * 3, hsv.v);
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool BAND_PINWHEEL_VAL(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
RGB_MATRIX_EFFECT(BAND_SAT)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void BAND_SAT_math(HSV* hsv, uint8_t i, uint8_t time) {
|
||||
int16_t s = rgb_matrix_config.sat - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8;
|
||||
hsv->s = scale8(s < 0 ? 0 : s, rgb_matrix_config.sat);
|
||||
static HSV BAND_SAT_math(HSV hsv, uint8_t i, uint8_t time) {
|
||||
int16_t s = hsv.s - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8;
|
||||
hsv.s = scale8(s < 0 ? 0 : s, hsv.s);
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool BAND_SAT(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
RGB_MATRIX_EFFECT(BAND_SPIRAL_SAT)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void BAND_SPIRAL_SAT_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
|
||||
hsv->s = scale8(rgb_matrix_config.sat + dist - time - atan2_8(dy, dx), rgb_matrix_config.sat);
|
||||
static HSV BAND_SPIRAL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
|
||||
hsv.s = scale8(hsv.s + dist - time - atan2_8(dy, dx), hsv.s);
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool BAND_SPIRAL_SAT(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
RGB_MATRIX_EFFECT(BAND_SPIRAL_VAL)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void BAND_SPIRAL_VAL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
|
||||
hsv->v = scale8(rgb_matrix_config.val + dist - time - atan2_8(dy, dx), rgb_matrix_config.val);
|
||||
static HSV BAND_SPIRAL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
|
||||
hsv.v = scale8(hsv.v + dist - time - atan2_8(dy, dx), hsv.v);
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool BAND_SPIRAL_VAL(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
RGB_MATRIX_EFFECT(BAND_VAL)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void BAND_VAL_math(HSV* hsv, uint8_t i, uint8_t time) {
|
||||
int16_t v = rgb_matrix_config.val - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8;
|
||||
hsv->v = scale8(v < 0 ? 0 : v, rgb_matrix_config.val);
|
||||
static HSV BAND_VAL_math(HSV hsv, uint8_t i, uint8_t time) {
|
||||
int16_t v = hsv.v - abs(scale8(g_led_config.point[i].x, 228) + 28 - time) * 8;
|
||||
hsv.v = scale8(v < 0 ? 0 : v, hsv.v);
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool BAND_VAL(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@
|
|||
RGB_MATRIX_EFFECT(CYCLE_ALL)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void CYCLE_ALL_math(HSV* hsv, uint8_t i, uint8_t time)
|
||||
{
|
||||
hsv->h = time;
|
||||
static HSV CYCLE_ALL_math(HSV hsv, uint8_t i, uint8_t time){
|
||||
hsv.h = time;
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool CYCLE_ALL(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
RGB_MATRIX_EFFECT(CYCLE_LEFT_RIGHT)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void CYCLE_LEFT_RIGHT_math(HSV* hsv, uint8_t i, uint8_t time) {
|
||||
hsv->h = g_led_config.point[i].x - time;
|
||||
static HSV CYCLE_LEFT_RIGHT_math(HSV hsv, uint8_t i, uint8_t time) {
|
||||
hsv.h = g_led_config.point[i].x - time;
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool CYCLE_LEFT_RIGHT(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
RGB_MATRIX_EFFECT(CYCLE_OUT_IN)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void CYCLE_OUT_IN_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
|
||||
hsv->h = 3 * dist / 2 + time;
|
||||
static HSV CYCLE_OUT_IN_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
|
||||
hsv.h = 3 * dist / 2 + time;
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool CYCLE_OUT_IN(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -2,10 +2,11 @@
|
|||
RGB_MATRIX_EFFECT(CYCLE_OUT_IN_DUAL)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void CYCLE_OUT_IN_DUAL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t time) {
|
||||
static HSV CYCLE_OUT_IN_DUAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
|
||||
dx = (k_rgb_matrix_center.x / 2) - abs8(dx);
|
||||
uint8_t dist = sqrt16(dx * dx + dy * dy);
|
||||
hsv->h = 3 * dist + time;
|
||||
hsv.h = 3 * dist + time;
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool CYCLE_OUT_IN_DUAL(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
RGB_MATRIX_EFFECT(CYCLE_PINWHEEL)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void CYCLE_PINWHEEL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t time) {
|
||||
hsv->h = atan2_8(dy, dx) + time;
|
||||
static HSV CYCLE_PINWHEEL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
|
||||
hsv.h = atan2_8(dy, dx) + time;
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool CYCLE_PINWHEEL(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
RGB_MATRIX_EFFECT(CYCLE_SPIRAL)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void CYCLE_SPIRAL_math(HSV* hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
|
||||
hsv->h = dist - time - atan2_8(dy, dx);
|
||||
static HSV CYCLE_SPIRAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
|
||||
hsv.h = dist - time - atan2_8(dy, dx);
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool CYCLE_SPIRAL(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
RGB_MATRIX_EFFECT(CYCLE_UP_DOWN)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void CYCLE_UP_DOWN_math(HSV* hsv, uint8_t i, uint8_t time) {
|
||||
hsv->h = g_led_config.point[i].y - time;
|
||||
static HSV CYCLE_UP_DOWN_math(HSV hsv, uint8_t i, uint8_t time) {
|
||||
hsv.h = g_led_config.point[i].y - time;
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool CYCLE_UP_DOWN(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
RGB_MATRIX_EFFECT(DUAL_BEACON)
|
||||
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
||||
|
||||
static void DUAL_BEACON_math(HSV* hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
|
||||
hsv->h = ((g_led_config.point[i].y - k_rgb_matrix_center.y) * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * sin) / 128 + rgb_matrix_config.hue;
|
||||
static HSV DUAL_BEACON_math(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time) {
|
||||
hsv.h += ((g_led_config.point[i].y - k_rgb_matrix_center.y) * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * sin) / 128;
|
||||
return hsv;
|
||||
}
|
||||
|
||||
bool DUAL_BEACON(effect_params_t* params) {
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ RGB_MATRIX_EFFECT(GRADIENT_UP_DOWN)
|
|||
bool GRADIENT_UP_DOWN(effect_params_t* params) {
|
||||
RGB_MATRIX_USE_LIMITS(led_min, led_max);
|
||||
|
||||
HSV hsv = { 0, rgb_matrix_config.sat, rgb_matrix_config.val };
|
||||
HSV hsv = rgb_matrix_config.hsv;
|
||||
uint8_t scale = scale8(64, rgb_matrix_config.speed);
|
||||
for (uint8_t i = led_min; i < led_max; i++) {
|
||||
RGB_MATRIX_TEST_LED_FLAGS();
|
||||
// The y range will be 0..64, map this to 0..4
|
||||
// Relies on hue being 8-bit and wrapping
|
||||
hsv.h = rgb_matrix_config.hue + scale * (g_led_config.point[i].y >> 4);
|
||||
hsv.h = rgb_matrix_config.hsv.h + scale * (g_led_config.point[i].y >> 4);
|
||||
RGB rgb = hsv_to_rgb(hsv);
|
||||
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue