Rename RGB/HSV structs: keyboard-level code (#24476)

This commit is contained in:
Ryan
2024-10-13 05:00:56 +11:00
committed by GitHub
parent 5478051d74
commit 9884e4982b
43 changed files with 215 additions and 215 deletions

View File

@@ -124,10 +124,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
bool rgb_matrix_indicators_user(void) {
HSV hsv = rgb_matrix_config.hsv;
hsv_t hsv = rgb_matrix_config.hsv;
uint8_t time = scale16by8(g_rgb_timer, qadd8(32, 1));
hsv.h = time;
RGB rgb = hsv_to_rgb(hsv);
rgb_t rgb = hsv_to_rgb(hsv);
if ((rgb_matrix_get_flags() & LED_FLAG_KEYLIGHT)) {
if (host_keyboard_led_state().caps_lock) {

View File

@@ -33,14 +33,14 @@ enum layer_names {
};
// For CUSTOM_GRADIENT
HSV gradient_0 = {205, 250, 255};
HSV gradient_100 = {140, 215, 125};
hsv_t gradient_0 = {205, 250, 255};
hsv_t gradient_100 = {140, 215, 125};
bool reflected_gradient = false;
uint8_t gp_i = 0;
typedef struct {
HSV gradient_0;
HSV gradient_1;
hsv_t gradient_0;
hsv_t gradient_1;
bool reflected;
} CUSTOM_PRESETS;
@@ -203,7 +203,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return false;
case G_FLIP:
if (record->event.pressed) {
HSV temp_color = gradient_0;
hsv_t temp_color = gradient_0;
gradient_0 = gradient_100;
gradient_100 = temp_color;
}
@@ -255,10 +255,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
bool rgb_matrix_indicators_user(void) {
uint8_t side_leds_left[3] = {17, 18, 19};
uint8_t side_leds_right[3] = { 4, 5, 6};
HSV hsv = rgb_matrix_config.hsv;
hsv_t hsv = rgb_matrix_config.hsv;
uint8_t time = scale16by8(g_rgb_timer, qadd8(32, 1));
hsv.h = time;
RGB rgb = hsv_to_rgb(hsv);
rgb_t rgb = hsv_to_rgb(hsv);
if ((rgb_matrix_get_flags() & LED_FLAG_ALL)) {
if (host_keyboard_led_state().caps_lock) {

View File

@@ -14,7 +14,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
static HSV COOL_DIAGONAL_math(HSV hsv, uint8_t i, uint8_t time) {
static hsv_t COOL_DIAGONAL_math(hsv_t hsv, uint8_t i, uint8_t time) {
hsv.h = (g_led_config.point[i].x / 4) - g_led_config.point[i].y - time;
return hsv;
}

View File

@@ -14,13 +14,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
extern HSV gradient_0;
extern HSV gradient_100;
extern hsv_t gradient_0;
extern hsv_t gradient_100;
extern bool reflected_gradient;
static HSV INTERPOLATE_HSV(float step, HSV gradient_0, HSV gradient_100) {
static hsv_t INTERPOLATE_HSV(float step, hsv_t gradient_0, hsv_t gradient_100) {
uint8_t cw, ccw;
HSV color;
hsv_t color;
cw = (gradient_0.h >= gradient_100.h) ? 255 + gradient_100.h - gradient_0.h : gradient_100.h - gradient_0.h; // Hue range is 0 to 255.
ccw = (gradient_0.h >= gradient_100.h) ? gradient_0.h - gradient_100.h : 255 + gradient_0.h - gradient_100.h;
@@ -39,7 +39,7 @@ static HSV INTERPOLATE_HSV(float step, HSV gradient_0, HSV gradient_100) {
return color;
}
static HSV CUSTOM_GRADIENT_math(uint8_t led_x, uint8_t min_x, uint8_t max_x) {
static hsv_t CUSTOM_GRADIENT_math(uint8_t led_x, uint8_t min_x, uint8_t max_x) {
float step = (float)led_x / (max_x - min_x);
float mid_gradient_pos = 0.5;
@@ -64,8 +64,8 @@ static bool CUSTOM_GRADIENT(effect_params_t* params) {
for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS();
HSV hsv_orig = CUSTOM_GRADIENT_math(g_led_config.point[i].x, min_x, max_x);
RGB rgb = hsv_to_rgb(hsv_orig);
hsv_t hsv_orig = CUSTOM_GRADIENT_math(g_led_config.point[i].x, min_x, max_x);
rgb_t rgb = hsv_to_rgb(hsv_orig);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}

View File

@@ -16,7 +16,7 @@
#include "led/flower_blooming/flower_blooming.h"
static HSV FLOWER_BLOOMING_math(HSV hsv, uint8_t i, uint8_t time) {
static hsv_t FLOWER_BLOOMING_math(hsv_t hsv, uint8_t i, uint8_t time) {
if (g_led_config.point[i].y > k_rgb_matrix_center.y)
hsv.h = g_led_config.point[i].x * 3 - g_led_config.point[i].y * 3 + time;
else

View File

@@ -1,6 +1,6 @@
#pragma once
typedef HSV (*flower_blooming_f)(HSV hsv, uint8_t i, uint8_t time);
typedef hsv_t (*flower_blooming_f)(hsv_t hsv, uint8_t i, uint8_t time);
bool effect_runner_bloom(effect_params_t* params, flower_blooming_f effect_func) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
@@ -9,10 +9,10 @@ bool effect_runner_bloom(effect_params_t* params, flower_blooming_f effect_func)
for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS();
if (g_led_config.point[i].y > k_rgb_matrix_center.y) {
RGB bgr = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
rgb_t bgr = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
rgb_matrix_set_color(i, bgr.b, bgr.g, bgr.r);
} else {
RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
rgb_t rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, i, time));
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}
}

View File

@@ -35,7 +35,7 @@ static uint8_t time_to_led(uint8_t time, uint8_t led_behind) {
return led;
}
static HSV KITT_math(HSV hsv, uint8_t i, uint8_t time) {
static hsv_t KITT_math(hsv_t hsv, uint8_t i, uint8_t time) {
// reset base effect startup
if (i == 0) {

View File

@@ -30,10 +30,10 @@ static void doRandom_breath_rainbow(int i, effect_params_t* params) {
}
//float val = (((float)sin8(time + offset[i]) / 256)/2.1) + .05;
HSV hsv = {0, 255, 255};
hsv_t hsv = {0, 255, 255};
hsv.h = scale16by8(g_rgb_timer + offset[i], rgb_matrix_config.speed / 4) + (offset[i]*2);
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
RGB rgb = rgb_matrix_hsv_to_rgb(hsv);
rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv);
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
}

View File

@@ -82,7 +82,7 @@ static void traverse_matrix(void) {
}
}
static void swirl_set_color(HSV hsv) {
static void swirl_set_color(hsv_t hsv) {
uint8_t index = g_led_config.matrix_co[j][i];
if(index != NO_LED){
@@ -97,8 +97,8 @@ static void swirl_set_color(HSV hsv) {
else
v_values[v] = 0;
}
hsv.v = v_values[v];
RGB rgb = hsv_to_rgb(hsv);
hsv.v = v_values[v];
hsv_t rgb = hsv_to_rgb(hsv);
rgb_matrix_set_color(v, rgb.r, rgb.g, rgb.b);
}
@@ -112,10 +112,10 @@ static void swirl_set_color(HSV hsv) {
}
static bool STARTUP_SWIRL_ANIM(effect_params_t* params) {
HSV hsv = rgb_matrix_config.hsv;
hsv_t hsv = rgb_matrix_config.hsv;
uint8_t time = scale16by8(g_rgb_timer, qadd8(24, 1));
hsv.h = time;
RGB rgb = hsv_to_rgb(hsv);
rgb_t rgb = hsv_to_rgb(hsv);
if (traverse) {
swirl_set_color(hsv);