Rename RGB and HSV structs (#24471)

This commit is contained in:
Ryan 2024-10-12 10:10:02 +11:00 • committed by GitHub
commit 6129af93f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
59 changed files with 122 additions and 117 deletions

View file

@ -53,8 +53,8 @@
io_wait; \
} while (0)
rgb_led_t apa102_leds[APA102_LED_COUNT];
uint8_t apa102_led_brightness = APA102_DEFAULT_BRIGHTNESS;
rgb_t apa102_leds[APA102_LED_COUNT];
uint8_t apa102_led_brightness = APA102_DEFAULT_BRIGHTNESS;
static void apa102_send_byte(uint8_t byte) {
APA102_SEND_BIT(byte, 7);

View file

@ -52,7 +52,7 @@ static bool qp_surface_pixdata_rgb565(painter_device_t device, const void *pixel
// Pixel colour conversion
static bool qp_surface_palette_convert_rgb565_swapped(painter_device_t device, int16_t palette_size, qp_pixel_t *palette) {
for (int16_t i = 0; i < palette_size; ++i) {
RGB rgb = hsv_to_rgb_nocie((HSV){palette[i].hsv888.h, palette[i].hsv888.s, palette[i].hsv888.v});
rgb_t rgb = hsv_to_rgb_nocie((hsv_t){palette[i].hsv888.h, palette[i].hsv888.s, palette[i].hsv888.v});
uint16_t rgb565 = (((uint16_t)rgb.r) >> 3) << 11 | (((uint16_t)rgb.g) >> 2) << 5 | (((uint16_t)rgb.b) >> 3);
palette[i].rgb565 = __builtin_bswap16(rgb565);
}

View file

@ -90,7 +90,7 @@ bool qp_tft_panel_pixdata(painter_device_t device, const void *pixel_data, uint3
bool qp_tft_panel_palette_convert_rgb565_swapped(painter_device_t device, int16_t palette_size, qp_pixel_t *palette) {
for (int16_t i = 0; i < palette_size; ++i) {
RGB rgb = hsv_to_rgb_nocie((HSV){palette[i].hsv888.h, palette[i].hsv888.s, palette[i].hsv888.v});
rgb_t rgb = hsv_to_rgb_nocie((hsv_t){palette[i].hsv888.h, palette[i].hsv888.s, palette[i].hsv888.v});
uint16_t rgb565 = (((uint16_t)rgb.r) >> 3) << 11 | (((uint16_t)rgb.g) >> 2) << 5 | (((uint16_t)rgb.b) >> 3);
palette[i].rgb565 = __builtin_bswap16(rgb565);
}
@ -99,7 +99,7 @@ bool qp_tft_panel_palette_convert_rgb565_swapped(painter_device_t device, int16_
bool qp_tft_panel_palette_convert_rgb888(painter_device_t device, int16_t palette_size, qp_pixel_t *palette) {
for (int16_t i = 0; i < palette_size; ++i) {
RGB rgb = hsv_to_rgb_nocie((HSV){palette[i].hsv888.h, palette[i].hsv888.s, palette[i].hsv888.v});
rgb_t rgb = hsv_to_rgb_nocie((hsv_t){palette[i].hsv888.h, palette[i].hsv888.s, palette[i].hsv888.v});
palette[i].rgb888.r = rgb.r;
palette[i].rgb888.g = rgb.g;
palette[i].rgb888.b = rgb.b;

View file

@ -19,8 +19,8 @@
#include "progmem.h"
#include "util.h"
RGB hsv_to_rgb_impl(HSV hsv, bool use_cie) {
RGB rgb;
rgb_t hsv_to_rgb_impl(hsv_t hsv, bool use_cie) {
rgb_t rgb;
uint8_t region, remainder, p, q, t;
uint16_t h, s, v;
@ -97,7 +97,7 @@ RGB hsv_to_rgb_impl(HSV hsv, bool use_cie) {
return rgb;
}
RGB hsv_to_rgb(HSV hsv) {
rgb_t hsv_to_rgb(hsv_t hsv) {
#ifdef USE_CIE1931_CURVE
return hsv_to_rgb_impl(hsv, true);
#else
@ -105,6 +105,6 @@ RGB hsv_to_rgb(HSV hsv) {
#endif
}
RGB hsv_to_rgb_nocie(HSV hsv) {
rgb_t hsv_to_rgb_nocie(hsv_t hsv) {
return hsv_to_rgb_impl(hsv, false);
}

View file

@ -74,19 +74,24 @@
// clang-format on
typedef struct PACKED rgb_led_t {
typedef struct PACKED rgb_t {
uint8_t r;
uint8_t g;
uint8_t b;
} rgb_led_t;
} rgb_t;
typedef rgb_led_t RGB;
// DEPRECATED
typedef rgb_t RGB;
typedef rgb_t rgb_led_t;
typedef struct PACKED HSV {
typedef struct PACKED hsv_t {
uint8_t h;
uint8_t s;
uint8_t v;
} HSV;
} hsv_t;
RGB hsv_to_rgb(HSV hsv);
RGB hsv_to_rgb_nocie(HSV hsv);
// DEPRECATED
typedef hsv_t HSV;
rgb_t hsv_to_rgb(hsv_t hsv);
rgb_t hsv_to_rgb_nocie(hsv_t hsv);

View file

@ -6,10 +6,10 @@ 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.hsv;
RGB rgb1 = rgb_matrix_hsv_to_rgb(hsv);
hsv_t hsv = rgb_matrix_config.hsv;
rgb_t rgb1 = rgb_matrix_hsv_to_rgb(hsv);
hsv.h += rgb_matrix_config.speed;
RGB rgb2 = rgb_matrix_hsv_to_rgb(hsv);
rgb_t rgb2 = rgb_matrix_hsv_to_rgb(hsv);
for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS();

View file

@ -5,10 +5,10 @@ RGB_MATRIX_EFFECT(BREATHING)
bool BREATHING(effect_params_t* params) {
RGB_MATRIX_USE_LIMITS(led_min, led_max);
HSV hsv = rgb_matrix_config.hsv;
hsv_t hsv = rgb_matrix_config.hsv;
uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8);
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);
for (uint8_t i = led_min; i < led_max; i++) {
RGB_MATRIX_TEST_LED_FLAGS();
rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);

View file

@ -2,7 +2,7 @@
RGB_MATRIX_EFFECT(BAND_PINWHEEL_SAT)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV BAND_PINWHEEL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
static hsv_t BAND_PINWHEEL_SAT_math(hsv_t 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;
}

View file

@ -2,7 +2,7 @@
RGB_MATRIX_EFFECT(BAND_PINWHEEL_VAL)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV BAND_PINWHEEL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
static hsv_t BAND_PINWHEEL_VAL_math(hsv_t 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;
}

View file

@ -2,7 +2,7 @@
RGB_MATRIX_EFFECT(BAND_SAT)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV BAND_SAT_math(HSV hsv, uint8_t i, uint8_t time) {
static hsv_t BAND_SAT_math(hsv_t 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;

View file

@ -2,7 +2,7 @@
RGB_MATRIX_EFFECT(BAND_SPIRAL_SAT)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV BAND_SPIRAL_SAT_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
static hsv_t BAND_SPIRAL_SAT_math(hsv_t 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;
}

View file

@ -2,7 +2,7 @@
RGB_MATRIX_EFFECT(BAND_SPIRAL_VAL)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV BAND_SPIRAL_VAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
static hsv_t BAND_SPIRAL_VAL_math(hsv_t 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;
}

View file

@ -2,7 +2,7 @@
RGB_MATRIX_EFFECT(BAND_VAL)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV BAND_VAL_math(HSV hsv, uint8_t i, uint8_t time) {
static hsv_t BAND_VAL_math(hsv_t 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;

View file

@ -2,7 +2,7 @@
RGB_MATRIX_EFFECT(CYCLE_ALL)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV CYCLE_ALL_math(HSV hsv, uint8_t i, uint8_t time) {
static hsv_t CYCLE_ALL_math(hsv_t hsv, uint8_t i, uint8_t time) {
hsv.h = time;
return hsv;
}

View file

@ -2,7 +2,7 @@
RGB_MATRIX_EFFECT(CYCLE_LEFT_RIGHT)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV CYCLE_LEFT_RIGHT_math(HSV hsv, uint8_t i, uint8_t time) {
static hsv_t CYCLE_LEFT_RIGHT_math(hsv_t hsv, uint8_t i, uint8_t time) {
hsv.h = g_led_config.point[i].x - time;
return hsv;
}

View file

@ -2,7 +2,7 @@
RGB_MATRIX_EFFECT(CYCLE_OUT_IN)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV CYCLE_OUT_IN_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
static hsv_t CYCLE_OUT_IN_math(hsv_t hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
hsv.h = 3 * dist / 2 + time;
return hsv;
}

View file

@ -2,7 +2,7 @@
RGB_MATRIX_EFFECT(CYCLE_OUT_IN_DUAL)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV CYCLE_OUT_IN_DUAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
static hsv_t CYCLE_OUT_IN_DUAL_math(hsv_t 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;

View file

@ -2,7 +2,7 @@
RGB_MATRIX_EFFECT(CYCLE_PINWHEEL)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV CYCLE_PINWHEEL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t time) {
static hsv_t CYCLE_PINWHEEL_math(hsv_t hsv, int16_t dx, int16_t dy, uint8_t time) {
hsv.h = atan2_8(dy, dx) + time;
return hsv;
}

View file

@ -2,7 +2,7 @@
RGB_MATRIX_EFFECT(CYCLE_SPIRAL)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV CYCLE_SPIRAL_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
static hsv_t CYCLE_SPIRAL_math(hsv_t hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time) {
hsv.h = dist - time - atan2_8(dy, dx);
return hsv;
}

View file

@ -2,7 +2,7 @@
RGB_MATRIX_EFFECT(CYCLE_UP_DOWN)
# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
static HSV CYCLE_UP_DOWN_math(HSV hsv, uint8_t i, uint8_t time) {
static hsv_t CYCLE_UP_DOWN_math(hsv_t hsv, uint8_t i, uint8_t time) {
hsv.h = g_led_config.point[i].y - time;
return hsv;
}

Some files were not shown because too many files have changed in this diff Show more