diff options
author | vin <git@vineetk.net> | 2024-01-15 19:40:26 -0500 |
---|---|---|
committer | vin <git@vineetk.net> | 2024-01-15 19:41:32 -0500 |
commit | a2c86b4053386fbc9a70674802c1157375b10066 (patch) | |
tree | cda5faee0c8c2298a0be47b8c1961bf16df595c9 /quantum | |
parent | e33ae91091e425699f0cdfd4483023b07ec3ed5e (diff) |
remove rgb support
Diffstat (limited to 'quantum')
57 files changed, 0 insertions, 5049 deletions
diff --git a/quantum/rgb_matrix/animations/alpha_mods_anim.h b/quantum/rgb_matrix/animations/alpha_mods_anim.h deleted file mode 100644 index 59b8381d69..0000000000 --- a/quantum/rgb_matrix/animations/alpha_mods_anim.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_ALPHAS_MODS -RGB_MATRIX_EFFECT(ALPHAS_MODS) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -// alphas = color1, mods = color2 -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.h += rgb_matrix_config.speed; - RGB rgb2 = rgb_matrix_hsv_to_rgb(hsv); - - for (uint8_t i = led_min; i < led_max; i++) { - RGB_MATRIX_TEST_LED_FLAGS(); - if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) { - rgb_matrix_set_color(i, rgb2.r, rgb2.g, rgb2.b); - } else { - rgb_matrix_set_color(i, rgb1.r, rgb1.g, rgb1.b); - } - } - return rgb_matrix_check_finished_leds(led_max); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_ALPHAS_MODS diff --git a/quantum/rgb_matrix/animations/breathing_anim.h b/quantum/rgb_matrix/animations/breathing_anim.h deleted file mode 100644 index e9a3c96e1b..0000000000 --- a/quantum/rgb_matrix/animations/breathing_anim.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_BREATHING -RGB_MATRIX_EFFECT(BREATHING) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -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_timer, rgb_matrix_config.speed / 8); - hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); - RGB 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); - } - return rgb_matrix_check_finished_leds(led_max); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_BREATHING diff --git a/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h b/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h deleted file mode 100644 index 06aa8b5ed5..0000000000 --- a/quantum/rgb_matrix/animations/colorband_pinwheel_sat_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT -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) { - hsv.s = scale8(hsv.s - time - atan2_8(dy, dx) * 3, hsv.s); - return hsv; -} - -bool BAND_PINWHEEL_SAT(effect_params_t* params) { - return effect_runner_dx_dy(params, &BAND_PINWHEEL_SAT_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_BAND_PINWHEEL_SAT diff --git a/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h b/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h deleted file mode 100644 index bcbc319498..0000000000 --- a/quantum/rgb_matrix/animations/colorband_pinwheel_val_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL -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) { - hsv.v = scale8(hsv.v - time - atan2_8(dy, dx) * 3, hsv.v); - return hsv; -} - -bool BAND_PINWHEEL_VAL(effect_params_t* params) { - return effect_runner_dx_dy(params, &BAND_PINWHEEL_VAL_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_BAND_PINWHEEL_VAL diff --git a/quantum/rgb_matrix/animations/colorband_sat_anim.h b/quantum/rgb_matrix/animations/colorband_sat_anim.h deleted file mode 100644 index cb0897ad3e..0000000000 --- a/quantum/rgb_matrix/animations/colorband_sat_anim.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_BAND_SAT -RGB_MATRIX_EFFECT(BAND_SAT) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -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) { - return effect_runner_i(params, &BAND_SAT_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_BAND_SAT diff --git a/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h b/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h deleted file mode 100644 index d26eb37855..0000000000 --- a/quantum/rgb_matrix/animations/colorband_spiral_sat_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT -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) { - hsv.s = scale8(hsv.s + dist - time - atan2_8(dy, dx), hsv.s); - return hsv; -} - -bool BAND_SPIRAL_SAT(effect_params_t* params) { - return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_SAT_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_BAND_SPIRAL_SAT diff --git a/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h b/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h deleted file mode 100644 index 3ae34bb6f0..0000000000 --- a/quantum/rgb_matrix/animations/colorband_spiral_val_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL -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) { - hsv.v = scale8(hsv.v + dist - time - atan2_8(dy, dx), hsv.v); - return hsv; -} - -bool BAND_SPIRAL_VAL(effect_params_t* params) { - return effect_runner_dx_dy_dist(params, &BAND_SPIRAL_VAL_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_BAND_SPIRAL_VAL diff --git a/quantum/rgb_matrix/animations/colorband_val_anim.h b/quantum/rgb_matrix/animations/colorband_val_anim.h deleted file mode 100644 index 69c29f53a3..0000000000 --- a/quantum/rgb_matrix/animations/colorband_val_anim.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_BAND_VAL -RGB_MATRIX_EFFECT(BAND_VAL) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -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) { - return effect_runner_i(params, &BAND_VAL_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_BAND_VAL diff --git a/quantum/rgb_matrix/animations/cycle_all_anim.h b/quantum/rgb_matrix/animations/cycle_all_anim.h deleted file mode 100644 index d8c7220d95..0000000000 --- a/quantum/rgb_matrix/animations/cycle_all_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_CYCLE_ALL -RGB_MATRIX_EFFECT(CYCLE_ALL) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -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) { - return effect_runner_i(params, &CYCLE_ALL_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_CYCLE_ALL diff --git a/quantum/rgb_matrix/animations/cycle_left_right_anim.h b/quantum/rgb_matrix/animations/cycle_left_right_anim.h deleted file mode 100644 index 84c2127aff..0000000000 --- a/quantum/rgb_matrix/animations/cycle_left_right_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT -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) { - hsv.h = g_led_config.point[i].x - time; - return hsv; -} - -bool CYCLE_LEFT_RIGHT(effect_params_t* params) { - return effect_runner_i(params, &CYCLE_LEFT_RIGHT_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT diff --git a/quantum/rgb_matrix/animations/cycle_out_in_anim.h b/quantum/rgb_matrix/animations/cycle_out_in_anim.h deleted file mode 100644 index 9513fe9593..0000000000 --- a/quantum/rgb_matrix/animations/cycle_out_in_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_CYCLE_OUT_IN -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) { - hsv.h = 3 * dist / 2 + time; - return hsv; -} - -bool CYCLE_OUT_IN(effect_params_t* params) { - return effect_runner_dx_dy_dist(params, &CYCLE_OUT_IN_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_CYCLE_OUT_IN diff --git a/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h b/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h deleted file mode 100644 index 3cca45f27a..0000000000 --- a/quantum/rgb_matrix/animations/cycle_out_in_dual_anim.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL -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) { - dx = (k_rgb_matrix_center.x / 2) - abs8(dx); - uint8_t dist = sqrt16(dx * dx + dy * dy); - hsv.h = 3 * dist + time; - return hsv; -} - -bool CYCLE_OUT_IN_DUAL(effect_params_t* params) { - return effect_runner_dx_dy(params, &CYCLE_OUT_IN_DUAL_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL diff --git a/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h b/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h deleted file mode 100644 index de5993992c..0000000000 --- a/quantum/rgb_matrix/animations/cycle_pinwheel_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_CYCLE_PINWHEEL -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) { - hsv.h = atan2_8(dy, dx) + time; - return hsv; -} - -bool CYCLE_PINWHEEL(effect_params_t* params) { - return effect_runner_dx_dy(params, &CYCLE_PINWHEEL_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_CYCLE_PINWHEEL diff --git a/quantum/rgb_matrix/animations/cycle_spiral_anim.h b/quantum/rgb_matrix/animations/cycle_spiral_anim.h deleted file mode 100644 index 904450179e..0000000000 --- a/quantum/rgb_matrix/animations/cycle_spiral_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_CYCLE_SPIRAL -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) { - hsv.h = dist - time - atan2_8(dy, dx); - return hsv; -} - -bool CYCLE_SPIRAL(effect_params_t* params) { - return effect_runner_dx_dy_dist(params, &CYCLE_SPIRAL_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_CYCLE_SPIRAL diff --git a/quantum/rgb_matrix/animations/cycle_up_down_anim.h b/quantum/rgb_matrix/animations/cycle_up_down_anim.h deleted file mode 100644 index dce05fecff..0000000000 --- a/quantum/rgb_matrix/animations/cycle_up_down_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_CYCLE_UP_DOWN -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) { - hsv.h = g_led_config.point[i].y - time; - return hsv; -} - -bool CYCLE_UP_DOWN(effect_params_t* params) { - return effect_runner_i(params, &CYCLE_UP_DOWN_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_CYCLE_UP_DOWN diff --git a/quantum/rgb_matrix/animations/digital_rain_anim.h b/quantum/rgb_matrix/animations/digital_rain_anim.h deleted file mode 100644 index 7d3b22f697..0000000000 --- a/quantum/rgb_matrix/animations/digital_rain_anim.h +++ /dev/null @@ -1,83 +0,0 @@ -#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_DIGITAL_RAIN) -RGB_MATRIX_EFFECT(DIGITAL_RAIN) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -# ifndef RGB_DIGITAL_RAIN_DROPS -// lower the number for denser effect/wider keyboard -# define RGB_DIGITAL_RAIN_DROPS 24 -# endif - -bool DIGITAL_RAIN(effect_params_t* params) { - // algorithm ported from https://github.com/tremby/Kaleidoscope-LEDEffect-DigitalRain - const uint8_t drop_ticks = 28; - const uint8_t pure_green_intensity = (((uint16_t)rgb_matrix_config.hsv.v) * 3) >> 2; - const uint8_t max_brightness_boost = (((uint16_t)rgb_matrix_config.hsv.v) * 3) >> 2; - const uint8_t max_intensity = rgb_matrix_config.hsv.v; - const uint8_t decay_ticks = 0xff / max_intensity; - - static uint8_t drop = 0; - static uint8_t decay = 0; - - if (params->init) { - rgb_matrix_set_color_all(0, 0, 0); - memset(g_rgb_frame_buffer, 0, sizeof(g_rgb_frame_buffer)); - drop = 0; - } - - decay++; - for (uint8_t col = 0; col < MATRIX_COLS; col++) { - for (uint8_t row = 0; row < MATRIX_ROWS; row++) { - if (row == 0 && drop == 0 && rand() < RAND_MAX / RGB_DIGITAL_RAIN_DROPS) { - // top row, pixels have just fallen and we're - // making a new rain drop in this column - g_rgb_frame_buffer[row][col] = max_intensity; - } else if (g_rgb_frame_buffer[row][col] > 0 && g_rgb_frame_buffer[row][col] < max_intensity) { - // neither fully bright nor dark, decay it - if (decay == decay_ticks) { - g_rgb_frame_buffer[row][col]--; - } - } - // set the pixel colour - uint8_t led[LED_HITS_TO_REMEMBER]; - uint8_t led_count = rgb_matrix_map_row_column_to_led(row, col, led); - - // TODO: multiple leds are supported mapped to the same row/column - if (led_count > 0) { - if (g_rgb_frame_buffer[row][col] > pure_green_intensity) { - const uint8_t boost = (uint8_t)((uint16_t)max_brightness_boost * (g_rgb_frame_buffer[row][col] - pure_green_intensity) / (max_intensity - pure_green_intensity)); - rgb_matrix_set_color(led[0], boost, max_intensity, boost); - } else { - const uint8_t green = (uint8_t)((uint16_t)max_intensity * g_rgb_frame_buffer[row][col] / pure_green_intensity); - rgb_matrix_set_color(led[0], 0, green, 0); - } - } - } - } - if (decay == decay_ticks) { - decay = 0; - } - - if (++drop > drop_ticks) { - // reset drop timer - drop = 0; - for (uint8_t row = MATRIX_ROWS - 1; row > 0; row--) { - for (uint8_t col = 0; col < MATRIX_COLS; col++) { - // if ths is on the bottom row and bright allow decay - if (row == MATRIX_ROWS - 1 && g_rgb_frame_buffer[row][col] == max_intensity) { - g_rgb_frame_buffer[row][col]--; - } - // check if the pixel above is bright - if (g_rgb_frame_buffer[row - 1][col] >= max_intensity) { // Note: can be larger than max_intensity if val was recently decreased - // allow old bright pixel to decay - g_rgb_frame_buffer[row - 1][col] = max_intensity - 1; - // make this pixel bright - g_rgb_frame_buffer[row][col] = max_intensity; - } - } - } - } - return false; -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && !defined(ENABLE_RGB_MATRIX_DIGITAL_RAIN) diff --git a/quantum/rgb_matrix/animations/dual_beacon_anim.h b/quantum/rgb_matrix/animations/dual_beacon_anim.h deleted file mode 100644 index 5585015b86..0000000000 --- a/quantum/rgb_matrix/animations/dual_beacon_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_DUAL_BEACON -RGB_MATRIX_EFFECT(DUAL_BEACON) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -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) { - return effect_runner_sin_cos_i(params, &DUAL_BEACON_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_DUAL_BEACON diff --git a/quantum/rgb_matrix/animations/gradient_left_right_anim.h b/quantum/rgb_matrix/animations/gradient_left_right_anim.h deleted file mode 100644 index ebb06f59f2..0000000000 --- a/quantum/rgb_matrix/animations/gradient_left_right_anim.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT -RGB_MATRIX_EFFECT(GRADIENT_LEFT_RIGHT) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -bool GRADIENT_LEFT_RIGHT(effect_params_t* params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - - 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 x range will be 0..224, map this to 0..7 - // Relies on hue being 8-bit and wrapping - hsv.h = rgb_matrix_config.hsv.h + (scale * g_led_config.point[i].x >> 5); - RGB rgb = rgb_matrix_hsv_to_rgb(hsv); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); - } - return rgb_matrix_check_finished_leds(led_max); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_GRADIENT_LEFT_RIGHT diff --git a/quantum/rgb_matrix/animations/gradient_up_down_anim.h b/quantum/rgb_matrix/animations/gradient_up_down_anim.h deleted file mode 100644 index febc3919a8..0000000000 --- a/quantum/rgb_matrix/animations/gradient_up_down_anim.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN -RGB_MATRIX_EFFECT(GRADIENT_UP_DOWN) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -bool GRADIENT_UP_DOWN(effect_params_t* params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - - 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.hsv.h + scale * (g_led_config.point[i].y >> 4); - RGB rgb = rgb_matrix_hsv_to_rgb(hsv); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); - } - return rgb_matrix_check_finished_leds(led_max); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_GRADIENT_UP_DOWN diff --git a/quantum/rgb_matrix/animations/hue_breathing_anim.h b/quantum/rgb_matrix/animations/hue_breathing_anim.h deleted file mode 100644 index 8537762832..0000000000 --- a/quantum/rgb_matrix/animations/hue_breathing_anim.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_HUE_BREATHING -RGB_MATRIX_EFFECT(HUE_BREATHING) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -// Change huedelta to adjust range of hue change. 0-255. -// Hue Breathing - All LED's light up -bool HUE_BREATHING(effect_params_t* params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - uint8_t huedelta = 12; - HSV hsv = rgb_matrix_config.hsv; - uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 8); - hsv.h = hsv.h + scale8(abs8(sin8(time) - 128) * 2, huedelta); - RGB rgb = 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); - } - return rgb_matrix_check_finished_leds(led_max); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_HUE_BREATHING diff --git a/quantum/rgb_matrix/animations/hue_pendulum_anim.h b/quantum/rgb_matrix/animations/hue_pendulum_anim.h deleted file mode 100644 index 7d8cbcdfb2..0000000000 --- a/quantum/rgb_matrix/animations/hue_pendulum_anim.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_HUE_PENDULUM -RGB_MATRIX_EFFECT(HUE_PENDULUM) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -// Change huedelta to adjust range of hue change. 0-255. -// Looks better with a low value and slow speed for subtle change. -// Hue Pendulum - color changes in a wave to the right before reversing direction -static HSV HUE_PENDULUM_math(HSV hsv, uint8_t i, uint8_t time) { - uint8_t huedelta = 12; - hsv.h = hsv.h + scale8(abs8(sin8(time) + (g_led_config.point[i].x) - 128) * 2, huedelta); - return hsv; -} - -bool HUE_PENDULUM(effect_params_t* params) { - return effect_runner_i(params, &HUE_PENDULUM_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_HUE_PENDULUM diff --git a/quantum/rgb_matrix/animations/hue_wave_anim.h b/quantum/rgb_matrix/animations/hue_wave_anim.h deleted file mode 100644 index 81aa7e139e..0000000000 --- a/quantum/rgb_matrix/animations/hue_wave_anim.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_HUE_WAVE -RGB_MATRIX_EFFECT(HUE_WAVE) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -// Change huedelta to adjust range of hue change. 0-255. -// Looks better with a low value and slow speed for subtle change. -// Hue Wave - color changes in a wave to the right -static HSV HUE_WAVE_math(HSV hsv, uint8_t i, uint8_t time) { - uint8_t huedelta = 24; - hsv.h = hsv.h + scale8(abs8(g_led_config.point[i].x - time), huedelta); - return hsv; -} - -bool HUE_WAVE(effect_params_t* params) { - return effect_runner_i(params, &HUE_WAVE_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // DISABLE_RGB_HUE_WAVE diff --git a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h b/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h deleted file mode 100644 index 5d3df1059e..0000000000 --- a/quantum/rgb_matrix/animations/jellybean_raindrops_anim.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS -RGB_MATRIX_EFFECT(JELLYBEAN_RAINDROPS) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static void jellybean_raindrops_set_color(int i, effect_params_t* params) { - if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; - HSV hsv = {random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}; - RGB rgb = rgb_matrix_hsv_to_rgb(hsv); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); -} - -bool JELLYBEAN_RAINDROPS(effect_params_t* params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - if (!params->init) { - // Change one LED every tick, make sure speed is not 0 - if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 5 == 0) { - jellybean_raindrops_set_color(random8_max(RGB_MATRIX_LED_COUNT), params); - } - } else { - for (int i = led_min; i < led_max; i++) { - jellybean_raindrops_set_color(i, params); - } - } - return rgb_matrix_check_finished_leds(led_max); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS diff --git a/quantum/rgb_matrix/animations/pixel_flow_anim.h b/quantum/rgb_matrix/animations/pixel_flow_anim.h deleted file mode 100644 index 27567b4f3a..0000000000 --- a/quantum/rgb_matrix/animations/pixel_flow_anim.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2022 @filterpaper -// SPDX-License-Identifier: GPL-2.0+ - -#ifdef ENABLE_RGB_MATRIX_PIXEL_FLOW -RGB_MATRIX_EFFECT(PIXEL_FLOW) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static bool PIXEL_FLOW(effect_params_t* params) { - // LED state array - static RGB led[RGB_MATRIX_LED_COUNT]; - - static uint32_t wait_timer = 0; - if (wait_timer > g_rgb_timer) { - return false; - } - - inline uint32_t interval(void) { - return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); - } - - if (params->init) { - // Clear LEDs and fill the state array - rgb_matrix_set_color_all(0, 0, 0); - for (uint8_t j = 0; j < RGB_MATRIX_LED_COUNT; ++j) { - led[j] = (random8() & 2) ? (RGB){0, 0, 0} : hsv_to_rgb((HSV){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}); - } - } - - RGB_MATRIX_USE_LIMITS(led_min, led_max); - // Light LEDs based on state array - for (uint8_t i = led_min; i < led_max; ++i) { - RGB_MATRIX_TEST_LED_FLAGS(); - rgb_matrix_set_color(i, led[i].r, led[i].g, led[i].b); - } - - if (!rgb_matrix_check_finished_leds(led_max)) { - // Shift LED state forward - for (uint8_t j = 0; j < led_max - 1; ++j) { - led[j] = led[j + 1]; - } - // Fill last LED - led[led_max - 1] = (random8() & 2) ? (RGB){0, 0, 0} : hsv_to_rgb((HSV){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}); - // Set pulse timer - wait_timer = g_rgb_timer + interval(); - } - - return rgb_matrix_check_finished_leds(led_max); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_PIXEL_FLOW diff --git a/quantum/rgb_matrix/animations/pixel_fractal_anim.h b/quantum/rgb_matrix/animations/pixel_fractal_anim.h deleted file mode 100644 index 4cd1d9b861..0000000000 --- a/quantum/rgb_matrix/animations/pixel_fractal_anim.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2022 @filterpaper -// SPDX-License-Identifier: GPL-2.0-or-later -// Inspired by 4x12 fractal from @GEIGEIGEIST - -#ifdef ENABLE_RGB_MATRIX_PIXEL_FRACTAL -RGB_MATRIX_EFFECT(PIXEL_FRACTAL) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static bool PIXEL_FRACTAL(effect_params_t* params) { -# if MATRIX_COLS < 2 -# define MID_COL 1 -# else -# define MID_COL MATRIX_COLS / 2 -# endif - static bool led[MATRIX_ROWS][MID_COL]; - static uint32_t wait_timer = 0; - - inline uint32_t interval(void) { - return 3000 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); - } - - if (params->init) { - rgb_matrix_set_color_all(0, 0, 0); - } - - RGB_MATRIX_USE_LIMITS(led_min, led_max); - - if (g_rgb_timer > wait_timer) { - RGB rgb = rgb_matrix_hsv_to_rgb(rgb_matrix_config.hsv); - for (uint8_t h = 0; h < MATRIX_ROWS; ++h) { - // Light and copy columns outward - for (uint8_t l = 0; l < MID_COL - 1; ++l) { - if (led[h][l]) { - rgb_matrix_set_color(g_led_config.matrix_co[h][l], rgb.r, rgb.g, rgb.b); - rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - 1 - l], rgb.r, rgb.g, rgb.b); - } else { - rgb_matrix_set_color(g_led_config.matrix_co[h][l], 0, 0, 0); - rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - 1 - l], 0, 0, 0); - } - led[h][l] = led[h][l + 1]; - } - - // Light both middle columns - if (led[h][MID_COL - 1]) { - rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL - 1], rgb.r, rgb.g, rgb.b); - rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - MID_COL], rgb.r, rgb.g, rgb.b); - } else { - rgb_matrix_set_color(g_led_config.matrix_co[h][MID_COL - 1], 0, 0, 0); - rgb_matrix_set_color(g_led_config.matrix_co[h][MATRIX_COLS - MID_COL], 0, 0, 0); - } - - // Generate new random fractal column - led[h][MID_COL - 1] = (random8() & 3) ? false : true; - } - - wait_timer = g_rgb_timer + interval(); - } - - return rgb_matrix_check_finished_leds(led_max); -} -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_PIXEL_FRACTAL diff --git a/quantum/rgb_matrix/animations/pixel_rain_anim.h b/quantum/rgb_matrix/animations/pixel_rain_anim.h deleted file mode 100644 index 26cd73b578..0000000000 --- a/quantum/rgb_matrix/animations/pixel_rain_anim.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2022 @filterpaper -// SPDX-License-Identifier: GPL-2.0+ - -#ifdef ENABLE_RGB_MATRIX_PIXEL_RAIN -RGB_MATRIX_EFFECT(PIXEL_RAIN) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static bool PIXEL_RAIN(effect_params_t* params) { - static uint32_t wait_timer = 0; - - inline uint32_t interval(void) { - return 500 / scale16by8(qadd8(rgb_matrix_config.speed, 16), 16); - } - - inline void rain_pixel(uint8_t led_index) { - if (!HAS_ANY_FLAGS(g_led_config.flags[led_index], params->flags)) { - return; - } - HSV hsv = (random8() & 2) ? (HSV){0, 0, 0} : (HSV){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}; - RGB rgb = rgb_matrix_hsv_to_rgb(hsv); - rgb_matrix_set_color(led_index, rgb.r, rgb.g, rgb.b); - wait_timer = g_rgb_timer + interval(); - } - - RGB_MATRIX_USE_LIMITS(led_min, led_max); - if (g_rgb_timer > wait_timer) { - rain_pixel(random8_max(RGB_MATRIX_LED_COUNT)); - } - return rgb_matrix_check_finished_leds(led_max); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_PIXEL_RAIN diff --git a/quantum/rgb_matrix/animations/rainbow_beacon_anim.h b/quantum/rgb_matrix/animations/rainbow_beacon_anim.h deleted file mode 100644 index bdcca5530f..0000000000 --- a/quantum/rgb_matrix/animations/rainbow_beacon_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_RAINBOW_BEACON -RGB_MATRIX_EFFECT(RAINBOW_BEACON) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static HSV RAINBOW_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) * 2 * cos + (g_led_config.point[i].x - k_rgb_matrix_center.x) * 2 * sin) / 128; - return hsv; -} - -bool RAINBOW_BEACON(effect_params_t* params) { - return effect_runner_sin_cos_i(params, &RAINBOW_BEACON_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_RAINBOW_BEACON diff --git a/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h b/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h deleted file mode 100644 index f7b8f6c2f3..0000000000 --- a/quantum/rgb_matrix/animations/rainbow_moving_chevron_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON -RGB_MATRIX_EFFECT(RAINBOW_MOVING_CHEVRON) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static HSV RAINBOW_MOVING_CHEVRON_math(HSV hsv, uint8_t i, uint8_t time) { - hsv.h += abs8(g_led_config.point[i].y - k_rgb_matrix_center.y) + (g_led_config.point[i].x - time); - return hsv; -} - -bool RAINBOW_MOVING_CHEVRON(effect_params_t* params) { - return effect_runner_i(params, &RAINBOW_MOVING_CHEVRON_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON diff --git a/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h b/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h deleted file mode 100644 index 91e31ea8cc..0000000000 --- a/quantum/rgb_matrix/animations/rainbow_pinwheels_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS -RGB_MATRIX_EFFECT(RAINBOW_PINWHEELS) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static HSV RAINBOW_PINWHEELS_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) * 3 * cos + (56 - abs8(g_led_config.point[i].x - k_rgb_matrix_center.x)) * 3 * sin) / 128; - return hsv; -} - -bool RAINBOW_PINWHEELS(effect_params_t* params) { - return effect_runner_sin_cos_i(params, &RAINBOW_PINWHEELS_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_RAINBOW_PINWHEELS diff --git a/quantum/rgb_matrix/animations/raindrops_anim.h b/quantum/rgb_matrix/animations/raindrops_anim.h deleted file mode 100644 index e8e1f6de04..0000000000 --- a/quantum/rgb_matrix/animations/raindrops_anim.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifdef ENABLE_RGB_MATRIX_RAINDROPS -RGB_MATRIX_EFFECT(RAINDROPS) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static void raindrops_set_color(int i, effect_params_t* params) { - if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) return; - HSV hsv = {0, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v}; - - // Take the shortest path between hues - int16_t deltaH = ((rgb_matrix_config.hsv.h + 180) % 360 - rgb_matrix_config.hsv.h) / 4; - if (deltaH > 127) { - deltaH -= 256; - } else if (deltaH < -127) { - deltaH += 256; - } - - hsv.h = rgb_matrix_config.hsv.h + (deltaH * (random8() & 0x03)); - RGB rgb = rgb_matrix_hsv_to_rgb(hsv); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); -} - -bool RAINDROPS(effect_params_t* params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - if (!params->init) { - // Change one LED every tick, make sure speed is not 0 - if (scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 16)) % 10 == 0) { - raindrops_set_color(random8_max(RGB_MATRIX_LED_COUNT), params); - } - } else { - for (int i = led_min; i < led_max; i++) { - raindrops_set_color(i, params); - } - } - return rgb_matrix_check_finished_leds(led_max); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // ENABLE_RGB_MATRIX_RAINDROPS diff --git a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc deleted file mode 100644 index ac7bac428d..0000000000 --- a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc +++ /dev/null @@ -1,40 +0,0 @@ -// Add your new core rgb matrix effect here, order determines enum order -#include "solid_color_anim.h" -#include "alpha_mods_anim.h" -#include "gradient_up_down_anim.h" -#include "gradient_left_right_anim.h" -#include "breathing_anim.h" -#include "colorband_sat_anim.h" -#include "colorband_val_anim.h" -#include "colorband_pinwheel_sat_anim.h" -#include "colorband_pinwheel_val_anim.h" -#include "colorband_spiral_sat_anim.h" -#include "colorband_spiral_val_anim.h" -#include "cycle_all_anim.h" -#include "cycle_left_right_anim.h" -#include "cycle_up_down_anim.h" -#include "rainbow_moving_chevron_anim.h" -#include "cycle_out_in_anim.h" -#include "cycle_out_in_dual_anim.h" -#include "cycle_pinwheel_anim.h" -#include "cycle_spiral_anim.h" -#include "dual_beacon_anim.h" -#include "rainbow_beacon_anim.h" -#include "rainbow_pinwheels_anim.h" -#include "raindrops_anim.h" -#include "jellybean_raindrops_anim.h" -#include "hue_breathing_anim.h" -#include "hue_pendulum_anim.h" -#include "hue_wave_anim.h" -#include "pixel_rain_anim.h" -#include "pixel_flow_anim.h" -#include "pixel_fractal_anim.h" -#include "typing_heatmap_anim.h" -#include "digital_rain_anim.h" -#include "solid_reactive_simple_anim.h" -#include "solid_reactive_anim.h" -#include "solid_reactive_wide.h" -#include "solid_reactive_cross.h" -#include "solid_reactive_nexus.h" -#include "splash_anim.h" -#include "solid_splash_anim.h" diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy.h b/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy.h deleted file mode 100644 index 2ad0f22c28..0000000000 --- a/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -typedef HSV (*dx_dy_f)(HSV hsv, int16_t dx, int16_t dy, uint8_t time); - -bool effect_runner_dx_dy(effect_params_t* params, dx_dy_f effect_func) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - - uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 2); - for (uint8_t i = led_min; i < led_max; i++) { - RGB_MATRIX_TEST_LED_FLAGS(); - int16_t dx = g_led_config.point[i].x - k_rgb_matrix_center.x; - int16_t dy = g_led_config.point[i].y - k_rgb_matrix_center.y; - RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, time)); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); - } - return rgb_matrix_check_finished_leds(led_max); -} diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy_dist.h b/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy_dist.h deleted file mode 100644 index bcae7c79b6..0000000000 --- a/quantum/rgb_matrix/animations/runners/effect_runner_dx_dy_dist.h +++ /dev/null @@ -1,18 +0,0 @@ -#pragma once - -typedef HSV (*dx_dy_dist_f)(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint8_t time); - -bool effect_runner_dx_dy_dist(effect_params_t* params, dx_dy_dist_f effect_func) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - - uint8_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 2); - for (uint8_t i = led_min; i < led_max; i++) { - RGB_MATRIX_TEST_LED_FLAGS(); - int16_t dx = g_led_config.point[i].x - k_rgb_matrix_center.x; - int16_t dy = g_led_config.point[i].y - k_rgb_matrix_center.y; - uint8_t dist = sqrt16(dx * dx + dy * dy); - RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, dx, dy, dist, time)); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); - } - return rgb_matrix_check_finished_leds(led_max); -} diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_i.h b/quantum/rgb_matrix/animations/runners/effect_runner_i.h deleted file mode 100644 index b4de2992b6..0000000000 --- a/quantum/rgb_matrix/animations/runners/effect_runner_i.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -typedef HSV (*i_f)(HSV hsv, uint8_t i, uint8_t time); - -bool effect_runner_i(effect_params_t* params, i_f effect_func) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - - uint8_t time = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed / 4, 1)); - for (uint8_t i = led_min; i < led_max; i++) { - RGB_MATRIX_TEST_LED_FLAGS(); - RGB 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); - } - return rgb_matrix_check_finished_leds(led_max); -} diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h b/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h deleted file mode 100644 index f9584d7071..0000000000 --- a/quantum/rgb_matrix/animations/runners/effect_runner_reactive.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED - -typedef HSV (*reactive_f)(HSV hsv, uint16_t offset); - -bool effect_runner_reactive(effect_params_t* params, reactive_f effect_func) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - - uint16_t max_tick = 65535 / qadd8(rgb_matrix_config.speed, 1); - for (uint8_t i = led_min; i < led_max; i++) { - RGB_MATRIX_TEST_LED_FLAGS(); - uint16_t tick = max_tick; - // Reverse search to find most recent key hit - for (int8_t j = g_last_hit_tracker.count - 1; j >= 0; j--) { - if (g_last_hit_tracker.index[j] == i && g_last_hit_tracker.tick[j] < tick) { - tick = g_last_hit_tracker.tick[j]; - break; - } - } - - uint16_t offset = scale16by8(tick, qadd8(rgb_matrix_config.speed, 1)); - RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, offset)); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); - } - return rgb_matrix_check_finished_leds(led_max); -} - -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h b/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h deleted file mode 100644 index 41020eb47f..0000000000 --- a/quantum/rgb_matrix/animations/runners/effect_runner_reactive_splash.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED - -typedef HSV (*reactive_splash_f)(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick); - -bool effect_runner_reactive_splash(uint8_t start, effect_params_t* params, reactive_splash_f effect_func) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - - uint8_t count = g_last_hit_tracker.count; - for (uint8_t i = led_min; i < led_max; i++) { - RGB_MATRIX_TEST_LED_FLAGS(); - HSV hsv = rgb_matrix_config.hsv; - hsv.v = 0; - for (uint8_t j = start; j < count; j++) { - int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j]; - int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j]; - uint8_t dist = sqrt16(dx * dx + dy * dy); - uint16_t tick = scale16by8(g_last_hit_tracker.tick[j], qadd8(rgb_matrix_config.speed, 1)); - hsv = effect_func(hsv, dx, dy, dist, tick); - } - hsv.v = scale8(hsv.v, rgb_matrix_config.hsv.v); - RGB rgb = rgb_matrix_hsv_to_rgb(hsv); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); - } - return rgb_matrix_check_finished_leds(led_max); -} - -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix/animations/runners/effect_runner_sin_cos_i.h b/quantum/rgb_matrix/animations/runners/effect_runner_sin_cos_i.h deleted file mode 100644 index 7776491d51..0000000000 --- a/quantum/rgb_matrix/animations/runners/effect_runner_sin_cos_i.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - -typedef HSV (*sin_cos_i_f)(HSV hsv, int8_t sin, int8_t cos, uint8_t i, uint8_t time); - -bool effect_runner_sin_cos_i(effect_params_t* params, sin_cos_i_f effect_func) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - - uint16_t time = scale16by8(g_rgb_timer, rgb_matrix_config.speed / 4); - int8_t cos_value = cos8(time) - 128; - int8_t sin_value = sin8(time) - 128; - for (uint8_t i = led_min; i < led_max; i++) { - RGB_MATRIX_TEST_LED_FLAGS(); - RGB rgb = rgb_matrix_hsv_to_rgb(effect_func(rgb_matrix_config.hsv, cos_value, sin_value, i, time)); - rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); - } - return rgb_matrix_check_finished_leds(led_max); -} diff --git a/quantum/rgb_matrix/animations/runners/rgb_matrix_runners.inc b/quantum/rgb_matrix/animations/runners/rgb_matrix_runners.inc deleted file mode 100644 index c09022bb0f..0000000000 --- a/quantum/rgb_matrix/animations/runners/rgb_matrix_runners.inc +++ /dev/null @@ -1,6 +0,0 @@ -#include "effect_runner_dx_dy_dist.h" -#include "effect_runner_dx_dy.h" -#include "effect_runner_i.h" -#include "effect_runner_sin_cos_i.h" -#include "effect_runner_reactive.h" -#include "effect_runner_reactive_splash.h" diff --git a/quantum/rgb_matrix/animations/solid_color_anim.h b/quantum/rgb_matrix/animations/solid_color_anim.h deleted file mode 100644 index c8762dcbc2..0000000000 --- a/quantum/rgb_matrix/animations/solid_color_anim.h +++ /dev/null @@ -1,15 +0,0 @@ -RGB_MATRIX_EFFECT(SOLID_COLOR) -#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -bool SOLID_COLOR(effect_params_t* params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - - RGB rgb = rgb_matrix_hsv_to_rgb(rgb_matrix_config.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); - } - return rgb_matrix_check_finished_leds(led_max); -} - -#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS diff --git a/quantum/rgb_matrix/animations/solid_reactive_anim.h b/quantum/rgb_matrix/animations/solid_reactive_anim.h deleted file mode 100644 index edf6041350..0000000000 --- a/quantum/rgb_matrix/animations/solid_reactive_anim.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE -RGB_MATRIX_EFFECT(SOLID_REACTIVE) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static HSV SOLID_REACTIVE_math(HSV hsv, uint16_t offset) { -# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE - hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4); -# endif - hsv.h += qsub8(130, offset); - return hsv; -} - -bool SOLID_REACTIVE(effect_params_t* params) { - return effect_runner_reactive(params, &SOLID_REACTIVE_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -# endif // ENABLE_RGB_MATRIX_SOLID_REACTIVE -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix/animations/solid_reactive_cross.h b/quantum/rgb_matrix/animations/solid_reactive_cross.h deleted file mode 100644 index a18d6b03dd..0000000000 --- a/quantum/rgb_matrix/animations/solid_reactive_cross.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -# if defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) - -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS -RGB_MATRIX_EFFECT(SOLID_REACTIVE_CROSS) -# endif - -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS -RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTICROSS) -# endif - -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static HSV SOLID_REACTIVE_CROSS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { - uint16_t effect = tick + dist; - dx = dx < 0 ? dx * -1 : dx; - dy = dy < 0 ? dy * -1 : dy; - dx = dx * 16 > 255 ? 255 : dx * 16; - dy = dy * 16 > 255 ? 255 : dy * 16; - effect += dx > dy ? dy : dx; - if (effect > 255) effect = 255; -# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE - hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4); -# endif - hsv.v = qadd8(hsv.v, 255 - effect); - return hsv; -} - -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS -bool SOLID_REACTIVE_CROSS(effect_params_t* params) { - return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_CROSS_math); -} -# endif - -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS -bool SOLID_REACTIVE_MULTICROSS(effect_params_t* params) { - return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_CROSS_math); -} -# endif - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -# endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix/animations/solid_reactive_nexus.h b/quantum/rgb_matrix/animations/solid_reactive_nexus.h deleted file mode 100644 index 53cc008616..0000000000 --- a/quantum/rgb_matrix/animations/solid_reactive_nexus.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -# if defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) - -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS -RGB_MATRIX_EFFECT(SOLID_REACTIVE_NEXUS) -# endif - -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS -RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTINEXUS) -# endif - -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static HSV SOLID_REACTIVE_NEXUS_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { - uint16_t effect = tick - dist; - if (effect > 255) effect = 255; - if (dist > 72) effect = 255; - if ((dx > 8 || dx < -8) && (dy > 8 || dy < -8)) effect = 255; -# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE - hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4) + dy / 4; -# else - hsv.h = rgb_matrix_config.hsv.h + dy / 4; -# endif - hsv.v = qadd8(hsv.v, 255 - effect); - return hsv; -} - -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS -bool SOLID_REACTIVE_NEXUS(effect_params_t* params) { - return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_NEXUS_math); -} -# endif - -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS -bool SOLID_REACTIVE_MULTINEXUS(effect_params_t* params) { - return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_NEXUS_math); -} -# endif - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -# endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h b/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h deleted file mode 100644 index 7f4e48747a..0000000000 --- a/quantum/rgb_matrix/animations/solid_reactive_simple_anim.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE -RGB_MATRIX_EFFECT(SOLID_REACTIVE_SIMPLE) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static HSV SOLID_REACTIVE_SIMPLE_math(HSV hsv, uint16_t offset) { -# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE - hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4); -# endif - hsv.v = scale8(255 - offset, hsv.v); - return hsv; -} - -bool SOLID_REACTIVE_SIMPLE(effect_params_t* params) { - return effect_runner_reactive(params, &SOLID_REACTIVE_SIMPLE_math); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -# endif // ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix/animations/solid_reactive_wide.h b/quantum/rgb_matrix/animations/solid_reactive_wide.h deleted file mode 100644 index feca126648..0000000000 --- a/quantum/rgb_matrix/animations/solid_reactive_wide.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -# if defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) - -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE -RGB_MATRIX_EFFECT(SOLID_REACTIVE_WIDE) -# endif - -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE -RGB_MATRIX_EFFECT(SOLID_REACTIVE_MULTIWIDE) -# endif - -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -static HSV SOLID_REACTIVE_WIDE_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { - uint16_t effect = tick + dist * 5; - if (effect > 255) effect = 255; -# ifdef RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE - hsv.h = scale16by8(g_rgb_timer, qadd8(rgb_matrix_config.speed, 8) >> 4); -# endif - hsv.v = qadd8(hsv.v, 255 - effect); - return hsv; -} - -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE -bool SOLID_REACTIVE_WIDE(effect_params_t* params) { - return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_REACTIVE_WIDE_math); -} -# endif - -# ifdef ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE -bool SOLID_REACTIVE_MULTIWIDE(effect_params_t* params) { - return effect_runner_reactive_splash(0, params, &SOLID_REACTIVE_WIDE_math); -} -# endif - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -# endif // !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || !defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix/animations/solid_splash_anim.h b/quantum/rgb_matrix/animations/solid_splash_anim.h deleted file mode 100644 index 77d6f8c5eb..0000000000 --- a/quantum/rgb_matrix/animations/solid_splash_anim.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -# if defined(ENABLE_RGB_MATRIX_SOLID_SPLASH) || defined(ENABLE_RGB_MATRIX_SOLID_MULTISPLASH) - -# ifdef ENABLE_RGB_MATRIX_SOLID_SPLASH -RGB_MATRIX_EFFECT(SOLID_SPLASH) -# endif - -# ifdef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH -RGB_MATRIX_EFFECT(SOLID_MULTISPLASH) -# endif - -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -HSV SOLID_SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { - uint16_t effect = tick - dist; - if (effect > 255) effect = 255; - hsv.v = qadd8(hsv.v, 255 - effect); - return hsv; -} - -# ifdef ENABLE_RGB_MATRIX_SOLID_SPLASH -bool SOLID_SPLASH(effect_params_t* params) { - return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SOLID_SPLASH_math); -} -# endif - -# ifdef ENABLE_RGB_MATRIX_SOLID_MULTISPLASH -bool SOLID_MULTISPLASH(effect_params_t* params) { - return effect_runner_reactive_splash(0, params, &SOLID_SPLASH_math); -} -# endif - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -# endif // !defined(ENABLE_RGB_MATRIX_SPLASH) && !defined(ENABLE_RGB_MATRIX_MULTISPLASH) -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix/animations/splash_anim.h b/quantum/rgb_matrix/animations/splash_anim.h deleted file mode 100644 index 06459e1b0a..0000000000 --- a/quantum/rgb_matrix/animations/splash_anim.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -# if defined(ENABLE_RGB_MATRIX_SPLASH) || defined(ENABLE_RGB_MATRIX_MULTISPLASH) - -# ifdef ENABLE_RGB_MATRIX_SPLASH -RGB_MATRIX_EFFECT(SPLASH) -# endif - -# ifdef ENABLE_RGB_MATRIX_MULTISPLASH -RGB_MATRIX_EFFECT(MULTISPLASH) -# endif - -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -HSV SPLASH_math(HSV hsv, int16_t dx, int16_t dy, uint8_t dist, uint16_t tick) { - uint16_t effect = tick - dist; - if (effect > 255) effect = 255; - hsv.h += effect; - hsv.v = qadd8(hsv.v, 255 - effect); - return hsv; -} - -# ifdef ENABLE_RGB_MATRIX_SPLASH -bool SPLASH(effect_params_t* params) { - return effect_runner_reactive_splash(qsub8(g_last_hit_tracker.count, 1), params, &SPLASH_math); -} -# endif - -# ifdef ENABLE_RGB_MATRIX_MULTISPLASH -bool MULTISPLASH(effect_params_t* params) { - return effect_runner_reactive_splash(0, params, &SPLASH_math); -} -# endif - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -# endif // !defined(ENABLE_RGB_MATRIX_SPLASH) || !defined(ENABLE_RGB_MATRIX_MULTISPLASH) -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED diff --git a/quantum/rgb_matrix/animations/typing_heatmap_anim.h b/quantum/rgb_matrix/animations/typing_heatmap_anim.h deleted file mode 100644 index d09bdc4631..0000000000 --- a/quantum/rgb_matrix/animations/typing_heatmap_anim.h +++ /dev/null @@ -1,100 +0,0 @@ -#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) -RGB_MATRIX_EFFECT(TYPING_HEATMAP) -# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -# ifndef RGB_MATRIX_TYPING_HEATMAP_INCREASE_STEP -# define RGB_MATRIX_TYPING_HEATMAP_INCREASE_STEP 32 -# endif - -# ifndef RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS -# define RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS 25 -# endif - -# ifndef RGB_MATRIX_TYPING_HEATMAP_SPREAD -# define RGB_MATRIX_TYPING_HEATMAP_SPREAD 40 -# endif - -# ifndef RGB_MATRIX_TYPING_HEATMAP_AREA_LIMIT -# define RGB_MATRIX_TYPING_HEATMAP_AREA_LIMIT 16 -# endif -void process_rgb_matrix_typing_heatmap(uint8_t row, uint8_t col) { -# ifdef RGB_MATRIX_TYPING_HEATMAP_SLIM - // Limit effect to pressed keys - g_rgb_frame_buffer[row][col] = qadd8(g_rgb_frame_buffer[row][col], RGB_MATRIX_TYPING_HEATMAP_INCREASE_STEP); -# else - if (g_led_config.matrix_co[row][col] == NO_LED) { // skip as pressed key doesn't have an led position - return; - } - for (uint8_t i_row = 0; i_row < MATRIX_ROWS; i_row++) { - for (uint8_t i_col = 0; i_col < MATRIX_COLS; i_col++) { - if (g_led_config.matrix_co[i_row][i_col] == NO_LED) { // skip as target key doesn't have an led position - continue; - } - if (i_row == row && i_col == col) { - g_rgb_frame_buffer[row][col] = qadd8(g_rgb_frame_buffer[row][col], RGB_MATRIX_TYPING_HEATMAP_INCREASE_STEP); - } else { -# define LED_DISTANCE(led_a, led_b) sqrt16(((int16_t)(led_a.x - led_b.x) * (int16_t)(led_a.x - led_b.x)) + ((int16_t)(led_a.y - led_b.y) * (int16_t)(led_a.y - led_b.y))) - uint8_t distance = LED_DISTANCE(g_led_config.point[g_led_config.matrix_co[row][col]], g_led_config.point[g_led_config.matrix_co[i_row][i_col]]); -# undef LED_DISTANCE - if (distance <= RGB_MATRIX_TYPING_HEATMAP_SPREAD) { - uint8_t amount = qsub8(RGB_MATRIX_TYPING_HEATMAP_SPREAD, distance); - if (amount > RGB_MATRIX_TYPING_HEATMAP_AREA_LIMIT) { - amount = RGB_MATRIX_TYPING_HEATMAP_AREA_LIMIT; - } - g_rgb_frame_buffer[i_row][i_col] = qadd8(g_rgb_frame_buffer[i_row][i_col], amount); - } - } - } - } -# endif -} - -// A timer to track the last time we decremented all heatmap values. -static uint16_t heatmap_decrease_timer; -// Whether we should decrement the heatmap values during the next update. -static bool decrease_heatmap_values; - -bool TYPING_HEATMAP(effect_params_t* params) { - RGB_MATRIX_USE_LIMITS(led_min, led_max); - - if (params->init) { - rgb_matrix_set_color_all(0, 0, 0); - memset(g_rgb_frame_buffer, 0, sizeof g_rgb_frame_buffer); - } - - // The heatmap animation might run in several iterations depending on - // `RGB_MATRIX_LED_PROCESS_LIMIT`, therefore we only want to update the - // timer when the animation starts. - if (params->iter == 0) { - decrease_heatmap_values = timer_elapsed(heatmap_decrease_timer) >= RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY_MS; - - // Restart the timer if we are going to decrease the heatmap this frame. - if (decrease_heatmap_values) { - heatmap_decrease_timer = timer_read(); - } - } - - // Render heatmap & decrease - uint8_t count = 0; - for (uint8_t row = 0; row < MATRIX_ROWS && count < RGB_MATRIX_LED_PROCESS_LIMIT; row++) { - for (uint8_t col = 0; col < MATRIX_COLS && RGB_MATRIX_LED_PROCESS_LIMIT; col++) { - if (g_led_config.matrix_co[row][col] >= led_min && g_led_config.matrix_co[row][col] < led_max) { - count++; - uint8_t val = g_rgb_frame_buffer[row][col]; - if (!HAS_ANY_FLAGS(g_led_config.flags[g_led_config.matrix_co[row][col]], params->flags)) continue; - - HSV hsv = {170 - qsub8(val, 85), rgb_matrix_config.hsv.s, scale8((qadd8(170, val) - 170) * 3, rgb_matrix_config.hsv.v)}; - RGB rgb = rgb_matrix_hsv_to_rgb(hsv); - rgb_matrix_set_color(g_led_config.matrix_co[row][col], rgb.r, rgb.g, rgb.b); - - if (decrease_heatmap_values) { - g_rgb_frame_buffer[row][col] = qsub8(val, 1); - } - } - } - } - - return rgb_matrix_check_finished_leds(led_max); -} - -# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) diff --git a/quantum/rgb_matrix/post_config.h b/quantum/rgb_matrix/post_config.h deleted file mode 100644 index 7162c8679b..0000000000 --- a/quantum/rgb_matrix/post_config.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2023 QMK -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -// clang-format off - -// framebuffer -#if defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) || \ - defined(ENABLE_RGB_MATRIX_DIGITAL_RAIN) -# define RGB_MATRIX_FRAMEBUFFER_EFFECTS -#endif - -// reactive -#if defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE) || \ - defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE) || \ - defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE) || \ - defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE) || \ - defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS) || \ - defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS) || \ - defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || \ - defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS) || \ - defined(ENABLE_RGB_MATRIX_SPLASH) || \ - defined(ENABLE_RGB_MATRIX_MULTISPLASH) || \ - defined(ENABLE_RGB_MATRIX_SOLID_SPLASH) || \ - defined(ENABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS) || \ - defined(ENABLE_RGB_MATRIX_SOLID_MULTISPLASH) -# define RGB_MATRIX_KEYPRESSES -#endif diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c deleted file mode 100644 index 96be615162..0000000000 --- a/quantum/rgb_matrix/rgb_matrix.c +++ /dev/null @@ -1,752 +0,0 @@ -/* Copyright 2017 Jason Williams - * Copyright 2017 Jack Humbert - * Copyright 2018 Yiancar - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "rgb_matrix.h" -#include "progmem.h" -#include "eeprom.h" -#include "eeconfig.h" -#include "keyboard.h" -#include "sync_timer.h" -#include "debug.h" -#include <string.h> -#include <math.h> -#include <stdlib.h> - -#include <lib/lib8tion/lib8tion.h> - -#ifndef RGB_MATRIX_CENTER -const led_point_t k_rgb_matrix_center = {112, 32}; -#else -const led_point_t k_rgb_matrix_center = RGB_MATRIX_CENTER; -#endif - -__attribute__((weak)) RGB rgb_matrix_hsv_to_rgb(HSV hsv) { - return hsv_to_rgb(hsv); -} - -// Generic effect runners -#include "rgb_matrix_runners.inc" - -// ------------------------------------------ -// -----Begin rgb effect includes macros----- -#define RGB_MATRIX_EFFECT(name) -#define RGB_MATRIX_CUSTOM_EFFECT_IMPLS - -#include "rgb_matrix_effects.inc" -#ifdef RGB_MATRIX_CUSTOM_KB -# include "rgb_matrix_kb.inc" -#endif -#ifdef RGB_MATRIX_CUSTOM_USER -# include "rgb_matrix_user.inc" -#endif - -#undef RGB_MATRIX_CUSTOM_EFFECT_IMPLS -#undef RGB_MATRIX_EFFECT -// -----End rgb effect includes macros------- -// ------------------------------------------ - -#ifndef RGB_MATRIX_TIMEOUT -# define RGB_MATRIX_TIMEOUT 0 -#endif - -#if !defined(RGB_MATRIX_MAXIMUM_BRIGHTNESS) || RGB_MATRIX_MAXIMUM_BRIGHTNESS > UINT8_MAX -# undef RGB_MATRIX_MAXIMUM_BRIGHTNESS -# define RGB_MATRIX_MAXIMUM_BRIGHTNESS UINT8_MAX -#endif - -#if !defined(RGB_MATRIX_HUE_STEP) -# define RGB_MATRIX_HUE_STEP 8 -#endif - -#if !defined(RGB_MATRIX_SAT_STEP) -# define RGB_MATRIX_SAT_STEP 16 -#endif - -#if !defined(RGB_MATRIX_VAL_STEP) -# define RGB_MATRIX_VAL_STEP 16 -#endif - -#if !defined(RGB_MATRIX_SPD_STEP) -# define RGB_MATRIX_SPD_STEP 16 -#endif - -#if !defined(RGB_MATRIX_DEFAULT_MODE) -# ifdef ENABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT -# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_CYCLE_LEFT_RIGHT -# else -// fallback to solid colors if RGB_MATRIX_CYCLE_LEFT_RIGHT is disabled in userspace -# define RGB_MATRIX_DEFAULT_MODE RGB_MATRIX_SOLID_COLOR -# endif -#endif - -#if !defined(RGB_MATRIX_DEFAULT_HUE) -# define RGB_MATRIX_DEFAULT_HUE 0 -#endif - -#if !defined(RGB_MATRIX_DEFAULT_SAT) -# define RGB_MATRIX_DEFAULT_SAT UINT8_MAX -#endif - -#if !defined(RGB_MATRIX_DEFAULT_VAL) -# define RGB_MATRIX_DEFAULT_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS -#endif - -#if !defined(RGB_MATRIX_DEFAULT_SPD) -# define RGB_MATRIX_DEFAULT_SPD UINT8_MAX / 2 -#endif - -// globals -rgb_config_t rgb_matrix_config; // TODO: would like to prefix this with g_ for global consistancy, do this in another pr -uint32_t g_rgb_timer; -#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS -uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS] = {{0}}; -#endif // RGB_MATRIX_FRAMEBUFFER_EFFECTS -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -last_hit_t g_last_hit_tracker; -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED - -// internals -static bool suspend_state = false; -static uint8_t rgb_last_enable = UINT8_MAX; -static uint8_t rgb_last_effect = UINT8_MAX; -static effect_params_t rgb_effect_params = {0, LED_FLAG_ALL, false}; -static rgb_task_states rgb_task_state = SYNCING; -#if RGB_MATRIX_TIMEOUT > 0 -static uint32_t rgb_anykey_timer; -#endif // RGB_MATRIX_TIMEOUT > 0 - -// double buffers -static uint32_t rgb_timer_buffer; -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -static last_hit_t last_hit_buffer; -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED - -// split rgb matrix -#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) -const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; -#endif - -EECONFIG_DEBOUNCE_HELPER(rgb_matrix, EECONFIG_RGB_MATRIX, rgb_matrix_config); - -void eeconfig_update_rgb_matrix(void) { - eeconfig_flush_rgb_matrix(true); -} - -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_DEFAULT_MODE; - rgb_matrix_config.hsv = (HSV){RGB_MATRIX_DEFAULT_HUE, RGB_MATRIX_DEFAULT_SAT, RGB_MATRIX_DEFAULT_VAL}; - rgb_matrix_config.speed = RGB_MATRIX_DEFAULT_SPD; - rgb_matrix_config.flags = LED_FLAG_ALL; - eeconfig_flush_rgb_matrix(true); -} - -void eeconfig_debug_rgb_matrix(void) { - dprintf("rgb_matrix_config EEPROM\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.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); - dprintf("rgb_matrix_config.flags = %d\n", rgb_matrix_config.flags); -} - -void rgb_matrix_reload_from_eeprom(void) { - rgb_matrix_disable_noeeprom(); - /* Reset back to what we have in eeprom */ - eeconfig_init_rgb_matrix(); - eeconfig_debug_rgb_matrix(); // display current eeprom values - if (rgb_matrix_config.enable) { - rgb_matrix_mode_noeeprom(rgb_matrix_config.mode); - } -} - -__attribute__((weak)) uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i) { - return 0; -} - -uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i) { - uint8_t led_count = rgb_matrix_map_row_column_to_led_kb(row, column, led_i); - uint8_t led_index = g_led_config.matrix_co[row][column]; - if (led_index != NO_LED) { - led_i[led_count] = led_index; - led_count++; - } - return led_count; -} - -void rgb_matrix_update_pwm_buffers(void) { - rgb_matrix_driver.flush(); -} - -void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue) { - rgb_matrix_driver.set_color(index, red, green, blue); -} - -void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue) { -#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) - for (uint8_t i = 0; i < RGB_MATRIX_LED_COUNT; i++) - rgb_matrix_set_color(i, red, green, blue); -#else - rgb_matrix_driver.set_color_all(red, green, blue); -#endif -} - -void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed) { -#ifndef RGB_MATRIX_SPLIT - if (!is_keyboard_master()) return; -#endif -#if RGB_MATRIX_TIMEOUT > 0 - rgb_anykey_timer = 0; -#endif // RGB_MATRIX_TIMEOUT > 0 - -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED - uint8_t led[LED_HITS_TO_REMEMBER]; - uint8_t led_count = 0; - -# if defined(RGB_MATRIX_KEYRELEASES) - if (!pressed) -# elif defined(RGB_MATRIX_KEYPRESSES) - if (pressed) -# endif // defined(RGB_MATRIX_KEYRELEASES) - { - led_count = rgb_matrix_map_row_column_to_led(row, col, led); - } - - if (last_hit_buffer.count + led_count > LED_HITS_TO_REMEMBER) { - memcpy(&last_hit_buffer.x[0], &last_hit_buffer.x[led_count], LED_HITS_TO_REMEMBER - led_count); - memcpy(&last_hit_buffer.y[0], &last_hit_buffer.y[led_count], LED_HITS_TO_REMEMBER - led_count); - memcpy(&last_hit_buffer.tick[0], &last_hit_buffer.tick[led_count], (LED_HITS_TO_REMEMBER - led_count) * 2); // 16 bit - memcpy(&last_hit_buffer.index[0], &last_hit_buffer.index[led_count], LED_HITS_TO_REMEMBER - led_count); - last_hit_buffer.count = LED_HITS_TO_REMEMBER - led_count; - } - - for (uint8_t i = 0; i < led_count; i++) { - uint8_t index = last_hit_buffer.count; - last_hit_buffer.x[index] = g_led_config.point[led[i]].x; - last_hit_buffer.y[index] = g_led_config.point[led[i]].y; - last_hit_buffer.index[index] = led[i]; - last_hit_buffer.tick[index] = 0; - last_hit_buffer.count++; - } -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED - -#if defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) -# if defined(RGB_MATRIX_KEYRELEASES) - if (!pressed) -# else - if (pressed) -# endif // defined(RGB_MATRIX_KEYRELEASES) - { - if (rgb_matrix_config.mode == RGB_MATRIX_TYPING_HEATMAP) { - process_rgb_matrix_typing_heatmap(row, col); - } - } -#endif // defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) && defined(ENABLE_RGB_MATRIX_TYPING_HEATMAP) -} - -void rgb_matrix_test(void) { - // Mask out bits 4 and 5 - // Increase the factor to make the test animation slower (and reduce to make it faster) - uint8_t factor = 10; - switch ((g_rgb_timer & (0b11 << factor)) >> factor) { - case 0: { - rgb_matrix_set_color_all(20, 0, 0); - break; - } - case 1: { - rgb_matrix_set_color_all(0, 20, 0); - break; - } - case 2: { - rgb_matrix_set_color_all(0, 0, 20); - break; - } - case 3: { - rgb_matrix_set_color_all(20, 20, 20); - break; - } - } -} - -static bool rgb_matrix_none(effect_params_t *params) { - if (!params->init) { - return false; - } - - rgb_matrix_set_color_all(0, 0, 0); - return false; -} - -static void rgb_task_timers(void) { -#if defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0 - uint32_t deltaTime = sync_timer_elapsed32(rgb_timer_buffer); -#endif // defined(RGB_MATRIX_KEYREACTIVE_ENABLED) || RGB_MATRIX_TIMEOUT > 0 - rgb_timer_buffer = sync_timer_read32(); - - // Update double buffer timers -#if RGB_MATRIX_TIMEOUT > 0 - if (rgb_anykey_timer + deltaTime <= UINT32_MAX) { - rgb_anykey_timer += deltaTime; - } -#endif // RGB_MATRIX_TIMEOUT > 0 - - // Update double buffer last hit timers -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED - uint8_t count = last_hit_buffer.count; - for (uint8_t i = 0; i < count; ++i) { - if (UINT16_MAX - deltaTime < last_hit_buffer.tick[i]) { - last_hit_buffer.count--; - continue; - } - last_hit_buffer.tick[i] += deltaTime; - } -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED -} - -static void rgb_task_sync(void) { - eeconfig_flush_rgb_matrix(false); - // next task - if (sync_timer_elapsed32(g_rgb_timer) >= RGB_MATRIX_LED_FLUSH_LIMIT) rgb_task_state = STARTING; -} - -static void rgb_task_start(void) { - // reset iter - rgb_effect_params.iter = 0; - - // update double buffers - g_rgb_timer = rgb_timer_buffer; -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED - g_last_hit_tracker = last_hit_buffer; -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED - - // next task - rgb_task_state = RENDERING; -} - -static void rgb_task_render(uint8_t effect) { - bool rendering = false; - rgb_effect_params.init = (effect != rgb_last_effect) || (rgb_matrix_config.enable != rgb_last_enable); - if (rgb_effect_params.flags != rgb_matrix_config.flags) { - rgb_effect_params.flags = rgb_matrix_config.flags; - rgb_matrix_set_color_all(0, 0, 0); - } - - // each effect can opt to do calculations - // and/or request PWM buffer updates. - switch (effect) { - case RGB_MATRIX_NONE: - rendering = rgb_matrix_none(&rgb_effect_params); - break; - -// --------------------------------------------- -// -----Begin rgb effect switch case macros----- -#define RGB_MATRIX_EFFECT(name, ...) \ - case RGB_MATRIX_##name: \ - rendering = name(&rgb_effect_params); \ - break; -#include "rgb_matrix_effects.inc" -#undef RGB_MATRIX_EFFECT - -#if defined(RGB_MATRIX_CUSTOM_KB) || defined(RGB_MATRIX_CUSTOM_USER) -# define RGB_MATRIX_EFFECT(name, ...) \ - case RGB_MATRIX_CUSTOM_##name: \ - rendering = name(&rgb_effect_params); \ - break; -# ifdef RGB_MATRIX_CUSTOM_KB -# include "rgb_matrix_kb.inc" -# endif -# ifdef RGB_MATRIX_CUSTOM_USER -# include "rgb_matrix_user.inc" -# endif -# undef RGB_MATRIX_EFFECT -#endif - // -----End rgb effect switch case macros------- - // --------------------------------------------- - - // Factory default magic value - case UINT8_MAX: { - rgb_matrix_test(); - rgb_task_state = FLUSHING; - } - return; - } - - rgb_effect_params.iter++; - - // next task - if (!rendering) { - rgb_task_state = FLUSHING; - if (!rgb_effect_params.init && effect == RGB_MATRIX_NONE) { - // We only need to flush once if we are RGB_MATRIX_NONE - rgb_task_state = SYNCING; - } - } -} - -static void rgb_task_flush(uint8_t effect) { - // update last trackers after the first full render so we can init over several frames - rgb_last_effect = effect; - rgb_last_enable = rgb_matrix_config.enable; - - // update pwm buffers - rgb_matrix_update_pwm_buffers(); - - // next task - rgb_task_state = SYNCING; -} - -void rgb_matrix_task(void) { - rgb_task_timers(); - - // Ideally we would also stop sending zeros to the LED driver PWM buffers - // while suspended and just do a software shutdown. This is a cheap hack for now. - bool suspend_backlight = suspend_state || -#if RGB_MATRIX_TIMEOUT > 0 - (rgb_anykey_timer > (uint32_t)RGB_MATRIX_TIMEOUT) || -#endif // RGB_MATRIX_TIMEOUT > 0 - false; - - uint8_t effect = suspend_backlight || !rgb_matrix_config.enable ? 0 : rgb_matrix_config.mode; - - switch (rgb_task_state) { - case STARTING: - rgb_task_start(); - break; - case RENDERING: - rgb_task_render(effect); - if (effect) { - // Only run the basic indicators in the last render iteration (default there are 5 iterations) - if (rgb_effect_params.iter == RGB_MATRIX_LED_PROCESS_MAX_ITERATIONS) { - rgb_matrix_indicators(); - } - rgb_matrix_indicators_advanced(&rgb_effect_params); - } - break; - case FLUSHING: - rgb_task_flush(effect); - break; - case SYNCING: - rgb_task_sync(); - break; - } -} - -void rgb_matrix_indicators(void) { - rgb_matrix_indicators_kb(); -} - -__attribute__((weak)) bool rgb_matrix_indicators_kb(void) { - return rgb_matrix_indicators_user(); -} - -__attribute__((weak)) bool rgb_matrix_indicators_user(void) { - return true; -} - -void rgb_matrix_indicators_advanced(effect_params_t *params) { - /* special handling is needed for "params->iter", since it's already been incremented. - * Could move the invocations to rgb_task_render, but then it's missing a few checks - * and not sure which would be better. Otherwise, this should be called from - * rgb_task_render, right before the iter++ line. - */ - RGB_MATRIX_USE_LIMITS_ITER(min, max, params->iter - 1); - rgb_matrix_indicators_advanced_kb(min, max); -} - -__attribute__((weak)) bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) { - return rgb_matrix_indicators_advanced_user(led_min, led_max); -} - -__attribute__((weak)) bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { - return true; -} - -void rgb_matrix_init(void) { - rgb_matrix_driver.init(); - -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED - g_last_hit_tracker.count = 0; - for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) { - g_last_hit_tracker.tick[i] = UINT16_MAX; - } - - last_hit_buffer.count = 0; - for (uint8_t i = 0; i < LED_HITS_TO_REMEMBER; ++i) { - last_hit_buffer.tick[i] = UINT16_MAX; - } -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED - - if (!eeconfig_is_enabled()) { - dprintf("rgb_matrix_init_drivers eeconfig is not enabled.\n"); - eeconfig_init(); - eeconfig_update_rgb_matrix_default(); - } - - eeconfig_init_rgb_matrix(); - if (!rgb_matrix_config.mode) { - dprintf("rgb_matrix_init_drivers rgb_matrix_config.mode = 0. Write default values to EEPROM.\n"); - eeconfig_update_rgb_matrix_default(); - } - eeconfig_debug_rgb_matrix(); // display current eeprom values -} - -void rgb_matrix_set_suspend_state(bool state) { -#ifdef RGB_DISABLE_WHEN_USB_SUSPENDED - if (state && !suspend_state) { // only run if turning off, and only once - rgb_task_render(0); // turn off all LEDs when suspending - rgb_task_flush(0); // and actually flash led state to LEDs - } - suspend_state = state; -#endif -} - -bool rgb_matrix_get_suspend_state(void) { - return suspend_state; -} - -void rgb_matrix_toggle_eeprom_helper(bool write_to_eeprom) { - rgb_matrix_config.enable ^= 1; - rgb_task_state = STARTING; - eeconfig_flag_rgb_matrix(write_to_eeprom); - dprintf("rgb matrix toggle [%s]: rgb_matrix_config.enable = %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.enable); -} -void rgb_matrix_toggle_noeeprom(void) { - rgb_matrix_toggle_eeprom_helper(false); -} -void rgb_matrix_toggle(void) { - rgb_matrix_toggle_eeprom_helper(true); -} - -void rgb_matrix_enable(void) { - rgb_matrix_enable_noeeprom(); - eeconfig_flag_rgb_matrix(true); -} - -void rgb_matrix_enable_noeeprom(void) { - if (!rgb_matrix_config.enable) rgb_task_state = STARTING; - rgb_matrix_config.enable = 1; -} - -void rgb_matrix_disable(void) { - rgb_matrix_disable_noeeprom(); - eeconfig_flag_rgb_matrix(true); -} - -void rgb_matrix_disable_noeeprom(void) { - if (rgb_matrix_config.enable) rgb_task_state = STARTING; - rgb_matrix_config.enable = 0; -} - -uint8_t rgb_matrix_is_enabled(void) { - return rgb_matrix_config.enable; -} - -void rgb_matrix_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { - if (!rgb_matrix_config.enable) { - return; - } - if (mode < 1) { - rgb_matrix_config.mode = 1; - } else if (mode >= RGB_MATRIX_EFFECT_MAX) { - rgb_matrix_config.mode = RGB_MATRIX_EFFECT_MAX - 1; - } else { - rgb_matrix_config.mode = mode; - } - rgb_task_state = STARTING; - eeconfig_flag_rgb_matrix(write_to_eeprom); - dprintf("rgb matrix mode [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.mode); -} -void rgb_matrix_mode_noeeprom(uint8_t mode) { - rgb_matrix_mode_eeprom_helper(mode, false); -} -void rgb_matrix_mode(uint8_t mode) { - rgb_matrix_mode_eeprom_helper(mode, true); -} - -uint8_t rgb_matrix_get_mode(void) { - return rgb_matrix_config.mode; -} - -void rgb_matrix_step_helper(bool write_to_eeprom) { - uint8_t mode = rgb_matrix_config.mode + 1; - rgb_matrix_mode_eeprom_helper((mode < RGB_MATRIX_EFFECT_MAX) ? mode : 1, write_to_eeprom); -} -void rgb_matrix_step_noeeprom(void) { - rgb_matrix_step_helper(false); -} -void rgb_matrix_step(void) { - rgb_matrix_step_helper(true); -} - -void rgb_matrix_step_reverse_helper(bool write_to_eeprom) { - uint8_t mode = rgb_matrix_config.mode - 1; - rgb_matrix_mode_eeprom_helper((mode < 1) ? RGB_MATRIX_EFFECT_MAX - 1 : mode, write_to_eeprom); -} -void rgb_matrix_step_reverse_noeeprom(void) { - rgb_matrix_step_reverse_helper(false); -} -void rgb_matrix_step_reverse(void) { - rgb_matrix_step_reverse_helper(true); -} - -void rgb_matrix_sethsv_eeprom_helper(uint16_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { - if (!rgb_matrix_config.enable) { - return; - } - rgb_matrix_config.hsv.h = hue; - rgb_matrix_config.hsv.s = sat; - rgb_matrix_config.hsv.v = (val > RGB_MATRIX_MAXIMUM_BRIGHTNESS) ? RGB_MATRIX_MAXIMUM_BRIGHTNESS : val; - eeconfig_flag_rgb_matrix(write_to_eeprom); - dprintf("rgb matrix set hsv [%s]: %u,%u,%u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v); -} -void rgb_matrix_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val) { - rgb_matrix_sethsv_eeprom_helper(hue, sat, val, false); -} -void rgb_matrix_sethsv(uint16_t hue, uint8_t sat, uint8_t val) { - rgb_matrix_sethsv_eeprom_helper(hue, sat, val, true); -} - -HSV rgb_matrix_get_hsv(void) { - return rgb_matrix_config.hsv; -} -uint8_t rgb_matrix_get_hue(void) { - return rgb_matrix_config.hsv.h; -} -uint8_t rgb_matrix_get_sat(void) { - return rgb_matrix_config.hsv.s; -} -uint8_t rgb_matrix_get_val(void) { - return rgb_matrix_config.hsv.v; -} - -void rgb_matrix_increase_hue_helper(bool write_to_eeprom) { - rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h + RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); -} -void rgb_matrix_increase_hue_noeeprom(void) { - rgb_matrix_increase_hue_helper(false); -} -void rgb_matrix_increase_hue(void) { - rgb_matrix_increase_hue_helper(true); -} - -void rgb_matrix_decrease_hue_helper(bool write_to_eeprom) { - rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h - RGB_MATRIX_HUE_STEP, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v, write_to_eeprom); -} -void rgb_matrix_decrease_hue_noeeprom(void) { - rgb_matrix_decrease_hue_helper(false); -} -void rgb_matrix_decrease_hue(void) { - rgb_matrix_decrease_hue_helper(true); -} - -void rgb_matrix_increase_sat_helper(bool write_to_eeprom) { - rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qadd8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); -} -void rgb_matrix_increase_sat_noeeprom(void) { - rgb_matrix_increase_sat_helper(false); -} -void rgb_matrix_increase_sat(void) { - rgb_matrix_increase_sat_helper(true); -} - -void rgb_matrix_decrease_sat_helper(bool write_to_eeprom) { - rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, qsub8(rgb_matrix_config.hsv.s, RGB_MATRIX_SAT_STEP), rgb_matrix_config.hsv.v, write_to_eeprom); -} -void rgb_matrix_decrease_sat_noeeprom(void) { - rgb_matrix_decrease_sat_helper(false); -} -void rgb_matrix_decrease_sat(void) { - rgb_matrix_decrease_sat_helper(true); -} - -void rgb_matrix_increase_val_helper(bool write_to_eeprom) { - rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qadd8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); -} -void rgb_matrix_increase_val_noeeprom(void) { - rgb_matrix_increase_val_helper(false); -} -void rgb_matrix_increase_val(void) { - rgb_matrix_increase_val_helper(true); -} - -void rgb_matrix_decrease_val_helper(bool write_to_eeprom) { - rgb_matrix_sethsv_eeprom_helper(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, qsub8(rgb_matrix_config.hsv.v, RGB_MATRIX_VAL_STEP), write_to_eeprom); -} -void rgb_matrix_decrease_val_noeeprom(void) { - rgb_matrix_decrease_val_helper(false); -} -void rgb_matrix_decrease_val(void) { - rgb_matrix_decrease_val_helper(true); -} - -void rgb_matrix_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { - rgb_matrix_config.speed = speed; - eeconfig_flag_rgb_matrix(write_to_eeprom); - dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.speed); -} -void rgb_matrix_set_speed_noeeprom(uint8_t speed) { - rgb_matrix_set_speed_eeprom_helper(speed, false); -} -void rgb_matrix_set_speed(uint8_t speed) { - rgb_matrix_set_speed_eeprom_helper(speed, true); -} - -uint8_t rgb_matrix_get_speed(void) { - return rgb_matrix_config.speed; -} - -void rgb_matrix_increase_speed_helper(bool write_to_eeprom) { - rgb_matrix_set_speed_eeprom_helper(qadd8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); -} -void rgb_matrix_increase_speed_noeeprom(void) { - rgb_matrix_increase_speed_helper(false); -} -void rgb_matrix_increase_speed(void) { - rgb_matrix_increase_speed_helper(true); -} - -void rgb_matrix_decrease_speed_helper(bool write_to_eeprom) { - rgb_matrix_set_speed_eeprom_helper(qsub8(rgb_matrix_config.speed, RGB_MATRIX_SPD_STEP), write_to_eeprom); -} -void rgb_matrix_decrease_speed_noeeprom(void) { - rgb_matrix_decrease_speed_helper(false); -} -void rgb_matrix_decrease_speed(void) { - rgb_matrix_decrease_speed_helper(true); -} - -void rgb_matrix_set_flags_eeprom_helper(led_flags_t flags, bool write_to_eeprom) { - rgb_matrix_config.flags = flags; - eeconfig_flag_rgb_matrix(write_to_eeprom); - dprintf("rgb matrix set speed [%s]: %u\n", (write_to_eeprom) ? "EEPROM" : "NOEEPROM", rgb_matrix_config.flags); -} - -led_flags_t rgb_matrix_get_flags(void) { - return rgb_matrix_config.flags; -} - -void rgb_matrix_set_flags(led_flags_t flags) { - rgb_matrix_set_flags_eeprom_helper(flags, true); -} - -void rgb_matrix_set_flags_noeeprom(led_flags_t flags) { - rgb_matrix_set_flags_eeprom_helper(flags, false); -} diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h deleted file mode 100644 index 38040fb0cc..0000000000 --- a/quantum/rgb_matrix/rgb_matrix.h +++ /dev/null @@ -1,271 +0,0 @@ -/* Copyright 2017 Jason Williams - * Copyright 2017 Jack Humbert - * Copyright 2018 Yiancar - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include <stdint.h> -#include <stdbool.h> -#include "rgb_matrix_types.h" -#include "color.h" -#include "keyboard.h" - -#ifdef IS31FL3731 -# include "is31fl3731.h" -#elif defined(IS31FL3733) -# include "is31fl3733.h" -#elif defined(IS31FL3736) -# include "is31fl3736.h" -#elif defined(IS31FL3737) -# include "is31fl3737.h" -#elif defined(IS31FL3741) -# include "is31fl3741.h" -#elif defined(IS31FLCOMMON) -# include "is31flcommon.h" -#elif defined(CKLED2001) -# include "ckled2001.h" -#elif defined(AW20216) -# include "aw20216.h" -#elif defined(WS2812) -# include "ws2812.h" -#endif - -#ifndef RGB_MATRIX_LED_FLUSH_LIMIT -# define RGB_MATRIX_LED_FLUSH_LIMIT 16 -#endif - -#ifndef RGB_MATRIX_LED_PROCESS_LIMIT -# define RGB_MATRIX_LED_PROCESS_LIMIT ((RGB_MATRIX_LED_COUNT + 4) / 5) -#endif -#define RGB_MATRIX_LED_PROCESS_MAX_ITERATIONS ((RGB_MATRIX_LED_COUNT + RGB_MATRIX_LED_PROCESS_LIMIT - 1) / RGB_MATRIX_LED_PROCESS_LIMIT) - -#if defined(RGB_MATRIX_LED_PROCESS_LIMIT) && RGB_MATRIX_LED_PROCESS_LIMIT > 0 && RGB_MATRIX_LED_PROCESS_LIMIT < RGB_MATRIX_LED_COUNT -# if defined(RGB_MATRIX_SPLIT) -# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \ - uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (iter); \ - uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \ - if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT; \ - uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \ - if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \ - if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0]; -# else -# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \ - uint8_t min = RGB_MATRIX_LED_PROCESS_LIMIT * (iter); \ - uint8_t max = min + RGB_MATRIX_LED_PROCESS_LIMIT; \ - if (max > RGB_MATRIX_LED_COUNT) max = RGB_MATRIX_LED_COUNT; -# endif -#else -# if defined(RGB_MATRIX_SPLIT) -# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \ - uint8_t min = 0; \ - uint8_t max = RGB_MATRIX_LED_COUNT; \ - const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; \ - if (is_keyboard_left() && (max > k_rgb_matrix_split[0])) max = k_rgb_matrix_split[0]; \ - if (!(is_keyboard_left()) && (min < k_rgb_matrix_split[0])) min = k_rgb_matrix_split[0]; -# else -# define RGB_MATRIX_USE_LIMITS_ITER(min, max, iter) \ - uint8_t min = 0; \ - uint8_t max = RGB_MATRIX_LED_COUNT; -# endif -#endif - -#define RGB_MATRIX_USE_LIMITS(min, max) RGB_MATRIX_USE_LIMITS_ITER(min, max, params->iter) - -#define RGB_MATRIX_INDICATOR_SET_COLOR(i, r, g, b) \ - if (i >= led_min && i < led_max) { \ - rgb_matrix_set_color(i, r, g, b); \ - } - -#define RGB_MATRIX_TEST_LED_FLAGS() \ - if (!HAS_ANY_FLAGS(g_led_config.flags[i], params->flags)) continue - -enum rgb_matrix_effects { - RGB_MATRIX_NONE = 0, - -// -------------------------------------- -// -----Begin rgb effect enum macros----- -#define RGB_MATRIX_EFFECT(name, ...) RGB_MATRIX_##name, -#include "rgb_matrix_effects.inc" -#undef RGB_MATRIX_EFFECT - -#if defined(RGB_MATRIX_CUSTOM_KB) || defined(RGB_MATRIX_CUSTOM_USER) -# define RGB_MATRIX_EFFECT(name, ...) RGB_MATRIX_CUSTOM_##name, -# ifdef RGB_MATRIX_CUSTOM_KB -# include "rgb_matrix_kb.inc" -# endif -# ifdef RGB_MATRIX_CUSTOM_USER -# include "rgb_matrix_user.inc" -# endif -# undef RGB_MATRIX_EFFECT -#endif - // -------------------------------------- - // -----End rgb effect enum macros------- - - RGB_MATRIX_EFFECT_MAX -}; - -void eeconfig_update_rgb_matrix_default(void); -void eeconfig_update_rgb_matrix(void); - -uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i); -uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i); - -void rgb_matrix_set_color(int index, uint8_t red, uint8_t green, uint8_t blue); -void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue); - -void process_rgb_matrix(uint8_t row, uint8_t col, bool pressed); - -void rgb_matrix_task(void); - -// This runs after another backlight effect and replaces -// colors already set -void rgb_matrix_indicators(void); -bool rgb_matrix_indicators_kb(void); -bool rgb_matrix_indicators_user(void); - -void rgb_matrix_indicators_advanced(effect_params_t *params); -bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max); -bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max); - -void rgb_matrix_init(void); - -void rgb_matrix_reload_from_eeprom(void); - -void rgb_matrix_set_suspend_state(bool state); -bool rgb_matrix_get_suspend_state(void); -void rgb_matrix_toggle(void); -void rgb_matrix_toggle_noeeprom(void); -void rgb_matrix_enable(void); -void rgb_matrix_enable_noeeprom(void); -void rgb_matrix_disable(void); -void rgb_matrix_disable_noeeprom(void); -uint8_t rgb_matrix_is_enabled(void); -void rgb_matrix_mode(uint8_t mode); -void rgb_matrix_mode_noeeprom(uint8_t mode); -uint8_t rgb_matrix_get_mode(void); -void rgb_matrix_step(void); -void rgb_matrix_step_noeeprom(void); -void rgb_matrix_step_reverse(void); -void rgb_matrix_step_reverse_noeeprom(void); -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); -HSV rgb_matrix_get_hsv(void); -uint8_t rgb_matrix_get_hue(void); -uint8_t rgb_matrix_get_sat(void); -uint8_t rgb_matrix_get_val(void); -void rgb_matrix_increase_hue(void); -void rgb_matrix_increase_hue_noeeprom(void); -void rgb_matrix_decrease_hue(void); -void rgb_matrix_decrease_hue_noeeprom(void); -void rgb_matrix_increase_sat(void); -void rgb_matrix_increase_sat_noeeprom(void); -void rgb_matrix_decrease_sat(void); -void rgb_matrix_decrease_sat_noeeprom(void); -void rgb_matrix_increase_val(void); -void rgb_matrix_increase_val_noeeprom(void); -void rgb_matrix_decrease_val(void); -void rgb_matrix_decrease_val_noeeprom(void); -void rgb_matrix_set_speed(uint8_t speed); -void rgb_matrix_set_speed_noeeprom(uint8_t speed); -uint8_t rgb_matrix_get_speed(void); -void rgb_matrix_increase_speed(void); -void rgb_matrix_increase_speed_noeeprom(void); -void rgb_matrix_decrease_speed(void); -void rgb_matrix_decrease_speed_noeeprom(void); -led_flags_t rgb_matrix_get_flags(void); -void rgb_matrix_set_flags(led_flags_t flags); -void rgb_matrix_set_flags_noeeprom(led_flags_t flags); - -#ifndef RGBLIGHT_ENABLE -# define eeconfig_update_rgblight_current eeconfig_update_rgb_matrix -# define rgblight_reload_from_eeprom rgb_matrix_reload_from_eeprom -# define rgblight_toggle rgb_matrix_toggle -# define rgblight_toggle_noeeprom rgb_matrix_toggle_noeeprom -# define rgblight_enable rgb_matrix_enable -# define rgblight_enable_noeeprom rgb_matrix_enable_noeeprom -# define rgblight_disable rgb_matrix_disable -# define rgblight_disable_noeeprom rgb_matrix_disable_noeeprom -# define rgblight_is_enabled rgb_matrix_is_enabled -# define rgblight_mode rgb_matrix_mode -# define rgblight_mode_noeeprom rgb_matrix_mode_noeeprom -# define rgblight_get_mode rgb_matrix_get_mode -# define rgblight_get_hue rgb_matrix_get_hue -# define rgblight_get_sat rgb_matrix_get_sat -# define rgblight_get_val rgb_matrix_get_val -# define rgblight_get_hsv rgb_matrix_get_hsv -# define rgblight_step rgb_matrix_step -# define rgblight_step_noeeprom rgb_matrix_step_noeeprom -# define rgblight_step_reverse rgb_matrix_step_reverse -# define rgblight_step_reverse_noeeprom rgb_matrix_step_reverse_noeeprom -# define rgblight_sethsv rgb_matrix_sethsv -# define rgblight_sethsv_noeeprom rgb_matrix_sethsv_noeeprom -# define rgblight_increase_hue rgb_matrix_increase_hue -# define rgblight_increase_hue_noeeprom rgb_matrix_increase_hue_noeeprom -# define rgblight_decrease_hue rgb_matrix_decrease_hue -# define rgblight_decrease_hue_noeeprom rgb_matrix_decrease_hue_noeeprom -# define rgblight_increase_sat rgb_matrix_increase_sat -# define rgblight_increase_sat_noeeprom rgb_matrix_increase_sat_noeeprom -# define rgblight_decrease_sat rgb_matrix_decrease_sat -# define rgblight_decrease_sat_noeeprom rgb_matrix_decrease_sat_noeeprom -# define rgblight_increase_val rgb_matrix_increase_val -# define rgblight_increase_val_noeeprom rgb_matrix_increase_val_noeeprom -# define rgblight_decrease_val rgb_matrix_decrease_val -# define rgblight_decrease_val_noeeprom rgb_matrix_decrease_val_noeeprom -# define rgblight_set_speed rgb_matrix_set_speed -# define rgblight_set_speed_noeeprom rgb_matrix_set_speed_noeeprom -# define rgblight_get_speed rgb_matrix_get_speed -# define rgblight_increase_speed rgb_matrix_increase_speed -# define rgblight_increase_speed_noeeprom rgb_matrix_increase_speed_noeeprom -# define rgblight_decrease_speed rgb_matrix_decrease_speed -# define rgblight_decrease_speed_noeeprom rgb_matrix_decrease_speed_noeeprom -#endif - -typedef struct { - /* Perform any initialisation required for the other driver functions to work. */ - void (*init)(void); - /* Set the colour of a single LED in the buffer. */ - void (*set_color)(int index, uint8_t r, uint8_t g, uint8_t b); - /* Set the colour of all LEDS on the keyboard in the buffer. */ - void (*set_color_all)(uint8_t r, uint8_t g, uint8_t b); - /* Flush any buffered changes to the hardware. */ - void (*flush)(void); -} rgb_matrix_driver_t; - -static inline bool rgb_matrix_check_finished_leds(uint8_t led_idx) { -#if defined(RGB_MATRIX_SPLIT) - if (is_keyboard_left()) { - uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; - return led_idx < k_rgb_matrix_split[0]; - } else - return led_idx < RGB_MATRIX_LED_COUNT; -#else - return led_idx < RGB_MATRIX_LED_COUNT; -#endif -} - -extern const rgb_matrix_driver_t rgb_matrix_driver; - -extern rgb_config_t rgb_matrix_config; - -extern uint32_t g_rgb_timer; -extern led_config_t g_led_config; -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -extern last_hit_t g_last_hit_tracker; -#endif -#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS -extern uint8_t g_rgb_frame_buffer[MATRIX_ROWS][MATRIX_COLS]; -#endif diff --git a/quantum/rgb_matrix/rgb_matrix_drivers.c b/quantum/rgb_matrix/rgb_matrix_drivers.c deleted file mode 100644 index 695ecc78a4..0000000000 --- a/quantum/rgb_matrix/rgb_matrix_drivers.c +++ /dev/null @@ -1,483 +0,0 @@ -/* Copyright 2018 James Laird-Wah - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "rgb_matrix.h" -#include "util.h" - -/* Each driver needs to define the struct - * const rgb_matrix_driver_t rgb_matrix_driver; - * All members must be provided. - * Keyboard custom drivers can define this in their own files, it should only - * be here if shared between boards. - */ - -#if defined(IS31FL3731) || defined(IS31FL3733) || defined(IS31FL3736) || defined(IS31FL3737) || defined(IS31FL3741) || defined(IS31FLCOMMON) || defined(CKLED2001) -# include "i2c_master.h" - -// TODO: Remove this at some later date -# if defined(DRIVER_ADDR_1) && defined(DRIVER_ADDR_2) -# if DRIVER_ADDR_1 == DRIVER_ADDR_2 -# error "Setting DRIVER_ADDR_2 == DRIVER_ADDR_1 is obsolete. If you are only using one ISSI driver, set DRIVER_COUNT to 1 and remove DRIVER_ADDR_2" -# endif -# endif - -static void init(void) { - i2c_init(); - -# if defined(IS31FL3731) - is31fl3731_init(DRIVER_ADDR_1); -# if defined(DRIVER_ADDR_2) - is31fl3731_init(DRIVER_ADDR_2); -# if defined(DRIVER_ADDR_3) - is31fl3731_init(DRIVER_ADDR_3); -# if defined(DRIVER_ADDR_4) - is31fl3731_init(DRIVER_ADDR_4); -# endif -# endif -# endif - -# elif defined(IS31FL3733) -# if !defined(DRIVER_SYNC_1) -# define DRIVER_SYNC_1 0 -# endif - is31fl3733_init(DRIVER_ADDR_1, DRIVER_SYNC_1); -# if defined(DRIVER_ADDR_2) -# if !defined(DRIVER_SYNC_2) -# define DRIVER_SYNC_2 0 -# endif - is31fl3733_init(DRIVER_ADDR_2, DRIVER_SYNC_2); -# if defined(DRIVER_ADDR_3) -# if !defined(DRIVER_SYNC_3) -# define DRIVER_SYNC_3 0 -# endif - is31fl3733_init(DRIVER_ADDR_3, DRIVER_SYNC_3); -# if defined(DRIVER_ADDR_4) -# if !defined(DRIVER_SYNC_4) -# define DRIVER_SYNC_4 0 -# endif - is31fl3733_init(DRIVER_ADDR_4, DRIVER_SYNC_4); -# endif -# endif -# endif - -# elif defined(IS31FL3736) - is31fl3736_init(DRIVER_ADDR_1); -# if defined(DRIVER_ADDR_2) - is31fl3736_init(DRIVER_ADDR_2); -# if defined(DRIVER_ADDR_3) - is31fl3736_init(DRIVER_ADDR_3); -# if defined(DRIVER_ADDR_4) - is31fl3736_init(DRIVER_ADDR_4); -# endif -# endif -# endif - -# elif defined(IS31FL3737) - is31fl3737_init(DRIVER_ADDR_1); -# if defined(DRIVER_ADDR_2) - is31fl3737_init(DRIVER_ADDR_2); -# if defined(DRIVER_ADDR_3) - is31fl3737_init(DRIVER_ADDR_3); -# if defined(DRIVER_ADDR_4) - is31fl3737_init(DRIVER_ADDR_4); -# endif -# endif -# endif - -# elif defined(IS31FL3741) - is31fl3741_init(DRIVER_ADDR_1); -# if defined(DRIVER_ADDR_2) - is31fl3741_init(DRIVER_ADDR_2); -# if defined(DRIVER_ADDR_3) - is31fl3741_init(DRIVER_ADDR_3); -# if defined(DRIVER_ADDR_4) - is31fl3741_init(DRIVER_ADDR_4); -# endif -# endif -# endif - -# elif defined(IS31FLCOMMON) - IS31FL_common_init(DRIVER_ADDR_1, ISSI_SSR_1); -# if defined(DRIVER_ADDR_2) - IS31FL_common_init(DRIVER_ADDR_2, ISSI_SSR_2); -# if defined(DRIVER_ADDR_3) - IS31FL_common_init(DRIVER_ADDR_3, ISSI_SSR_3); -# if defined(DRIVER_ADDR_4) - IS31FL_common_init(DRIVER_ADDR_4, ISSI_SSR_4); -# endif -# endif -# endif - -# elif defined(CKLED2001) - ckled2001_init(DRIVER_ADDR_1); -# if defined(DRIVER_ADDR_2) - ckled2001_init(DRIVER_ADDR_2); -# if defined(DRIVER_ADDR_3) - ckled2001_init(DRIVER_ADDR_3); -# if defined(DRIVER_ADDR_4) - ckled2001_init(DRIVER_ADDR_4); -# endif -# endif -# endif -# endif - - for (int index = 0; index < RGB_MATRIX_LED_COUNT; index++) { - bool enabled = true; - - // This only caches it for later -# if defined(IS31FL3731) - is31fl3731_set_led_control_register(index, enabled, enabled, enabled); -# elif defined(IS31FL3733) - is31fl3733_set_led_control_register(index, enabled, enabled, enabled); -# elif defined(IS31FL3736) - is31fl3736_set_led_control_register(index, enabled, enabled, enabled); -# elif defined(IS31FL3737) - is31fl3737_set_led_control_register(index, enabled, enabled, enabled); -# elif defined(IS31FL3741) - is31fl3741_set_led_control_register(index, enabled, enabled, enabled); -# elif defined(IS31FLCOMMON) - IS31FL_RGB_set_scaling_buffer(index, enabled, enabled, enabled); -# elif defined(CKLED2001) - ckled2001_set_led_control_register(index, enabled, enabled, enabled); -# endif - } - - // This actually updates the LED drivers -# if defined(IS31FL3731) - is31fl3731_update_led_control_registers(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - is31fl3731_update_led_control_registers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - is31fl3731_update_led_control_registers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - is31fl3731_update_led_control_registers(DRIVER_ADDR_4, 3); -# endif -# endif -# endif - -# elif defined(IS31FL3733) - is31fl3733_update_led_control_registers(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - is31fl3733_update_led_control_registers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - is31fl3733_update_led_control_registers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - is31fl3733_update_led_control_registers(DRIVER_ADDR_4, 3); -# endif -# endif -# endif - -# elif defined(IS31FL3736) - is31fl3736_update_led_control_registers(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - is31fl3736_update_led_control_registers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - is31fl3736_update_led_control_registers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - is31fl3736_update_led_control_registers(DRIVER_ADDR_4, 3); -# endif -# endif -# endif - -# elif defined(IS31FL3737) - is31fl3737_update_led_control_registers(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - is31fl3737_update_led_control_registers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - is31fl3737_update_led_control_registers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - is31fl3737_update_led_control_registers(DRIVER_ADDR_4, 3); -# endif -# endif -# endif - -# elif defined(IS31FL3741) - is31fl3741_update_led_control_registers(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - is31fl3741_update_led_control_registers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - is31fl3741_update_led_control_registers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - is31fl3741_update_led_control_registers(DRIVER_ADDR_4, 3); -# endif -# endif -# endif - -# elif defined(IS31FLCOMMON) -# ifdef ISSI_MANUAL_SCALING - IS31FL_set_manual_scaling_buffer(); -# endif - IS31FL_common_update_scaling_register(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - IS31FL_common_update_scaling_register(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - IS31FL_common_update_scaling_register(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - IS31FL_common_update_scaling_register(DRIVER_ADDR_4, 3); -# endif -# endif -# endif - -# elif defined(CKLED2001) - ckled2001_update_led_control_registers(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - ckled2001_update_led_control_registers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - ckled2001_update_led_control_registers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - ckled2001_update_led_control_registers(DRIVER_ADDR_4, 3); -# endif -# endif -# endif -# endif -} - -# if defined(IS31FL3731) -static void flush(void) { - is31fl3731_update_pwm_buffers(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - is31fl3731_update_pwm_buffers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - is31fl3731_update_pwm_buffers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - is31fl3731_update_pwm_buffers(DRIVER_ADDR_4, 3); -# endif -# endif -# endif -} - -const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = flush, - .set_color = is31fl3731_set_color, - .set_color_all = is31fl3731_set_color_all, -}; - -# elif defined(IS31FL3733) -static void flush(void) { - is31fl3733_update_pwm_buffers(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - is31fl3733_update_pwm_buffers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - is31fl3733_update_pwm_buffers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - is31fl3733_update_pwm_buffers(DRIVER_ADDR_4, 3); -# endif -# endif -# endif -} - -const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = flush, - .set_color = is31fl3733_set_color, - .set_color_all = is31fl3733_set_color_all, -}; - -# elif defined(IS31FL3736) -static void flush(void) { - is31fl3736_update_pwm_buffers(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - is31fl3736_update_pwm_buffers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - is31fl3736_update_pwm_buffers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - is31fl3736_update_pwm_buffers(DRIVER_ADDR_4, 3); -# endif -# endif -# endif -} - -const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = flush, - .set_color = is31fl3736_set_color, - .set_color_all = is31fl3736_set_color_all, -}; - -# elif defined(IS31FL3737) -static void flush(void) { - is31fl3737_update_pwm_buffers(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - is31fl3737_update_pwm_buffers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - is31fl3737_update_pwm_buffers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - is31fl3737_update_pwm_buffers(DRIVER_ADDR_4, 3); -# endif -# endif -# endif -} - -const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = flush, - .set_color = is31fl3737_set_color, - .set_color_all = is31fl3737_set_color_all, -}; - -# elif defined(IS31FL3741) -static void flush(void) { - is31fl3741_update_pwm_buffers(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - is31fl3741_update_pwm_buffers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - is31fl3741_update_pwm_buffers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - is31fl3741_update_pwm_buffers(DRIVER_ADDR_4, 3); -# endif -# endif -# endif -} - -const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = flush, - .set_color = is31fl3741_set_color, - .set_color_all = is31fl3741_set_color_all, -}; - -# elif defined(IS31FLCOMMON) -static void flush(void) { - IS31FL_common_update_pwm_register(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - IS31FL_common_update_pwm_register(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - IS31FL_common_update_pwm_register(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - IS31FL_common_update_pwm_register(DRIVER_ADDR_4, 3); -# endif -# endif -# endif -} - -const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = flush, - .set_color = IS31FL_RGB_set_color, - .set_color_all = IS31FL_RGB_set_color_all, -}; - -# elif defined(CKLED2001) -static void flush(void) { - ckled2001_update_pwm_buffers(DRIVER_ADDR_1, 0); -# if defined(DRIVER_ADDR_2) - ckled2001_update_pwm_buffers(DRIVER_ADDR_2, 1); -# if defined(DRIVER_ADDR_3) - ckled2001_update_pwm_buffers(DRIVER_ADDR_3, 2); -# if defined(DRIVER_ADDR_4) - ckled2001_update_pwm_buffers(DRIVER_ADDR_4, 3); -# endif -# endif -# endif -} - -const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = flush, - .set_color = ckled2001_set_color, - .set_color_all = ckled2001_set_color_all, -}; -# endif - -#elif defined(AW20216) -# include "spi_master.h" - -static void init(void) { - spi_init(); - - aw20216_init(DRIVER_1_CS, DRIVER_1_EN); -# if defined(DRIVER_2_CS) - aw20216_init(DRIVER_2_CS, DRIVER_2_EN); -# endif -} - -static void flush(void) { - aw20216_update_pwm_buffers(DRIVER_1_CS, 0); -# if defined(DRIVER_2_CS) - aw20216_update_pwm_buffers(DRIVER_2_CS, 1); -# endif -} - -const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = flush, - .set_color = aw20216_set_color, - .set_color_all = aw20216_set_color_all, -}; - -#elif defined(WS2812) -# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_CUSTOM_DRIVER) -# pragma message "Cannot use RGBLIGHT and RGB Matrix using WS2812 at the same time." -# pragma message "You need to use a custom driver, or re-implement the WS2812 driver to use a different configuration." -# endif - -// LED color buffer -LED_TYPE rgb_matrix_ws2812_array[RGB_MATRIX_LED_COUNT]; -bool ws2812_dirty = false; - -static void init(void) { - ws2812_dirty = false; -} - -static void flush(void) { - if (ws2812_dirty) { - ws2812_setleds(rgb_matrix_ws2812_array, RGB_MATRIX_LED_COUNT); - ws2812_dirty = false; - } -} - -// Set an led in the buffer to a color -static inline void setled(int i, uint8_t r, uint8_t g, uint8_t b) { -# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_SPLIT) - const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; - if (!is_keyboard_left()) { - if (i >= k_rgb_matrix_split[0]) { - i -= k_rgb_matrix_split[0]; - } else { - return; - } - } else if (i >= k_rgb_matrix_split[0]) { - return; - } -# endif - - if (rgb_matrix_ws2812_array[i].r == r && rgb_matrix_ws2812_array[i].g == g && rgb_matrix_ws2812_array[i].b == b) { - return; - } - - ws2812_dirty = true; - rgb_matrix_ws2812_array[i].r = r; - rgb_matrix_ws2812_array[i].g = g; - rgb_matrix_ws2812_array[i].b = b; -# ifdef RGBW - convert_rgb_to_rgbw(&rgb_matrix_ws2812_array[i]); -# endif -} - -static void setled_all(uint8_t r, uint8_t g, uint8_t b) { - for (int i = 0; i < ARRAY_SIZE(rgb_matrix_ws2812_array); i++) { - setled(i, r, g, b); - } -} - -const rgb_matrix_driver_t rgb_matrix_driver = { - .init = init, - .flush = flush, - .set_color = setled, - .set_color_all = setled_all, -}; -#endif diff --git a/quantum/rgb_matrix/rgb_matrix_types.h b/quantum/rgb_matrix/rgb_matrix_types.h deleted file mode 100644 index 53ff7321b8..0000000000 --- a/quantum/rgb_matrix/rgb_matrix_types.h +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright 2021 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include <stdint.h> -#include <stdbool.h> -#include "color.h" - -#if defined(__GNUC__) -# define PACKED __attribute__((__packed__)) -#else -# define PACKED -#endif - -#if defined(_MSC_VER) -# pragma pack(push, 1) -#endif - -#if defined(RGB_MATRIX_KEYPRESSES) || defined(RGB_MATRIX_KEYRELEASES) -# define RGB_MATRIX_KEYREACTIVE_ENABLED -#endif - -// Last led hit -#ifndef LED_HITS_TO_REMEMBER -# define LED_HITS_TO_REMEMBER 8 -#endif // LED_HITS_TO_REMEMBER - -#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED -typedef struct PACKED { - uint8_t count; - uint8_t x[LED_HITS_TO_REMEMBER]; - uint8_t y[LED_HITS_TO_REMEMBER]; - uint8_t index[LED_HITS_TO_REMEMBER]; - uint16_t tick[LED_HITS_TO_REMEMBER]; -} last_hit_t; -#endif // RGB_MATRIX_KEYREACTIVE_ENABLED - -typedef enum rgb_task_states { STARTING, RENDERING, FLUSHING, SYNCING } rgb_task_states; - -typedef uint8_t led_flags_t; - -typedef struct PACKED { - uint8_t iter; - led_flags_t flags; - bool init; -} effect_params_t; - -typedef struct PACKED { - uint8_t x; - uint8_t y; -} led_point_t; - -#define HAS_FLAGS(bits, flags) ((bits & flags) == flags) -#define HAS_ANY_FLAGS(bits, flags) ((bits & flags) != 0x00) - -#define LED_FLAG_ALL 0xFF -#define LED_FLAG_NONE 0x00 -#define LED_FLAG_MODIFIER 0x01 -#define LED_FLAG_UNDERGLOW 0x02 -#define LED_FLAG_KEYLIGHT 0x04 -#define LED_FLAG_INDICATOR 0x08 - -#define NO_LED 255 - -typedef struct PACKED { - uint8_t matrix_co[MATRIX_ROWS][MATRIX_COLS]; - led_point_t point[RGB_MATRIX_LED_COUNT]; - uint8_t flags[RGB_MATRIX_LED_COUNT]; -} led_config_t; - -typedef union { - uint64_t raw; - struct PACKED { - uint8_t enable : 2; - uint8_t mode : 6; - HSV hsv; - uint8_t speed; - led_flags_t flags; - }; -} rgb_config_t; - -_Static_assert(sizeof(rgb_config_t) == sizeof(uint64_t), "RGB Matrix EECONFIG out of spec."); - -#if defined(_MSC_VER) -# pragma pack(pop) -#endif diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c deleted file mode 100644 index 158112f31d..0000000000 --- a/quantum/rgblight/rgblight.c +++ /dev/null @@ -1,1521 +0,0 @@ -/* Copyright 2016-2017 Yang Liu - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -#include <math.h> -#include <string.h> -#include <stdlib.h> -#include "progmem.h" -#include "sync_timer.h" -#include "rgblight.h" -#include "color.h" -#include "debug.h" -#include "util.h" -#include "led_tables.h" -#include <lib/lib8tion/lib8tion.h> -#ifdef EEPROM_ENABLE -# include "eeprom.h" -#endif -#ifdef VELOCIKEY_ENABLE -# include "velocikey.h" -#endif - -#ifdef RGBLIGHT_SPLIT -/* for split keyboard */ -# define RGBLIGHT_SPLIT_SET_CHANGE_MODE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_MODE -# define RGBLIGHT_SPLIT_SET_CHANGE_HSVS rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_HSVS -# define RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS rgblight_status.change_flags |= (RGBLIGHT_STATUS_CHANGE_MODE | RGBLIGHT_STATUS_CHANGE_HSVS) -# define RGBLIGHT_SPLIT_SET_CHANGE_LAYERS rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_LAYERS -# define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE rgblight_status.change_flags |= RGBLIGHT_STATUS_CHANGE_TIMER -# define RGBLIGHT_SPLIT_ANIMATION_TICK rgblight_status.change_flags |= RGBLIGHT_STATUS_ANIMATION_TICK -#else -# define RGBLIGHT_SPLIT_SET_CHANGE_MODE -# define RGBLIGHT_SPLIT_SET_CHANGE_HSVS -# define RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS -# define RGBLIGHT_SPLIT_SET_CHANGE_LAYERS -# define RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE -# define RGBLIGHT_SPLIT_ANIMATION_TICK -#endif - -#define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_##sym, -#define _RGBM_SINGLE_DYNAMIC(sym) -#define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_##sym, -#define _RGBM_MULTI_DYNAMIC(sym) -#define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_##sym, -#define _RGBM_TMP_DYNAMIC(sym, msym) -static uint8_t static_effect_table[] = { -#include "rgblight_modes.h" -}; - -#define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_##sym, -#define _RGBM_SINGLE_DYNAMIC(sym) RGBLIGHT_MODE_##sym, -#define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_##sym, -#define _RGBM_MULTI_DYNAMIC(sym) RGBLIGHT_MODE_##sym, -#define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_##msym, -#define _RGBM_TMP_DYNAMIC(sym, msym) RGBLIGHT_MODE_##msym, -static uint8_t mode_base_table[] = { - 0, // RGBLIGHT_MODE_zero -#include "rgblight_modes.h" -}; - -#if !defined(RGBLIGHT_DEFAULT_MODE) -# define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_LIGHT -#endif - -#if !defined(RGBLIGHT_DEFAULT_HUE) -# define RGBLIGHT_DEFAULT_HUE 0 -#endif - -#if !defined(RGBLIGHT_DEFAULT_SAT) -# define RGBLIGHT_DEFAULT_SAT UINT8_MAX -#endif - -#if !defined(RGBLIGHT_DEFAULT_VAL) -# define RGBLIGHT_DEFAULT_VAL RGBLIGHT_LIMIT_VAL -#endif - -#if !defined(RGBLIGHT_DEFAULT_SPD) -# define RGBLIGHT_DEFAULT_SPD 0 -#endif - -static inline int is_static_effect(uint8_t mode) { - return memchr(static_effect_table, mode, sizeof(static_effect_table)) != NULL; -} - -#ifdef RGBLIGHT_LED_MAP -const uint8_t led_map[] PROGMEM = RGBLIGHT_LED_MAP; -#endif - -#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT -__attribute__((weak)) const uint8_t RGBLED_GRADIENT_RANGES[] PROGMEM = {255, 170, 127, 85, 64}; -#endif - -rgblight_config_t rgblight_config; -rgblight_status_t rgblight_status = {.timer_enabled = false}; -bool is_rgblight_initialized = false; - -#ifdef RGBLIGHT_SLEEP -static bool is_suspended; -static bool pre_suspend_enabled; -#endif - -#ifdef RGBLIGHT_USE_TIMER -animation_status_t animation_status = {}; -#endif - -#ifndef LED_ARRAY -LED_TYPE led[RGBLED_NUM]; -# define LED_ARRAY led -#endif - -#ifdef RGBLIGHT_LAYERS -rgblight_segment_t const *const *rgblight_layers = NULL; - -static bool deferred_set_layer_state = false; -#endif - -rgblight_ranges_t rgblight_ranges = {0, RGBLED_NUM, 0, RGBLED_NUM, RGBLED_NUM}; - -void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds) { - rgblight_ranges.clipping_start_pos = start_pos; - rgblight_ranges.clipping_num_leds = num_leds; -} - -void rgblight_set_effect_range(uint8_t start_pos, uint8_t num_leds) { - if (start_pos >= RGBLED_NUM) return; - if (start_pos + num_leds > RGBLED_NUM) return; - rgblight_ranges.effect_start_pos = start_pos; - rgblight_ranges.effect_end_pos = start_pos + num_leds; - rgblight_ranges.effect_num_leds = num_leds; -} - -__attribute__((weak)) RGB rgblight_hsv_to_rgb(HSV hsv) { - return hsv_to_rgb(hsv); -} - -void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { - HSV hsv = {hue, sat, val}; - RGB rgb = rgblight_hsv_to_rgb(hsv); - setrgb(rgb.r, rgb.g, rgb.b, led1); -} - -void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1) { - sethsv_raw(hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val, led1); -} - -void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1) { - led1->r = r; - led1->g = g; - led1->b = b; -#ifdef RGBW - led1->w = 0; -#endif -} - -void rgblight_check_config(void) { - /* Add some out of bound checks for RGB light config */ - - if (rgblight_config.mode < RGBLIGHT_MODE_STATIC_LIGHT) { - rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT; - } else if (rgblight_config.mode > RGBLIGHT_MODES) { - rgblight_config.mode = RGBLIGHT_MODES; - } - - if (rgblight_config.val > RGBLIGHT_LIMIT_VAL) { - rgblight_config.val = RGBLIGHT_LIMIT_VAL; - } -} - -uint64_t eeconfig_read_rgblight(void) { -#ifdef EEPROM_ENABLE - return (uint64_t)((eeprom_read_dword(EECONFIG_RGBLIGHT)) | ((uint64_t)eeprom_read_byte(EECONFIG_RGBLIGHT_EXTENDED) << 32)); -#else - return 0; -#endif -} - -void eeconfig_update_rgblight(uint64_t val) { -#ifdef EEPROM_ENABLE - rgblight_check_config(); - eeprom_update_dword(EECONFIG_RGBLIGHT, val & 0xFFFFFFFF); - eeprom_update_byte(EECONFIG_RGBLIGHT_EXTENDED, (val >> 32) & 0xFF); -#endif -} - -void eeconfig_update_rgblight_current(void) { - eeconfig_update_rgblight(rgblight_config.raw); -} - -void eeconfig_update_rgblight_default(void) { - rgblight_config.enable = 1; - rgblight_config.mode = RGBLIGHT_DEFAULT_MODE; - rgblight_config.hue = RGBLIGHT_DEFAULT_HUE; - rgblight_config.sat = RGBLIGHT_DEFAULT_SAT; - rgblight_config.val = RGBLIGHT_DEFAULT_VAL; - rgblight_config.speed = RGBLIGHT_DEFAULT_SPD; - RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; - eeconfig_update_rgblight(rgblight_config.raw); -} - -void eeconfig_debug_rgblight(void) { - dprintf("rgblight_config EEPROM:\n"); - dprintf("rgblight_config.enable = %d\n", rgblight_config.enable); - dprintf("rghlight_config.mode = %d\n", rgblight_config.mode); - dprintf("rgblight_config.hue = %d\n", rgblight_config.hue); - dprintf("rgblight_config.sat = %d\n", rgblight_config.sat); - dprintf("rgblight_config.val = %d\n", rgblight_config.val); - dprintf("rgblight_config.speed = %d\n", rgblight_config.speed); -} - -void rgblight_init(void) { - /* if already initialized, don't do it again. - If you must do it again, extern this and set to false, first. - This is a dirty, dirty hack until proper hooks can be added for keyboard startup. */ - if (is_rgblight_initialized) { - return; - } - - dprintf("rgblight_init called.\n"); - dprintf("rgblight_init start!\n"); - if (!eeconfig_is_enabled()) { - dprintf("rgblight_init eeconfig is not enabled.\n"); - eeconfig_init(); - eeconfig_update_rgblight_default(); - } - rgblight_config.raw = eeconfig_read_rgblight(); - RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; - if (!rgblight_config.mode) { - dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n"); - eeconfig_update_rgblight_default(); - rgblight_config.raw = eeconfig_read_rgblight(); - } - rgblight_check_config(); - - eeconfig_debug_rgblight(); // display current eeprom values - - rgblight_timer_init(); // setup the timer - - if (rgblight_config.enable) { - rgblight_mode_noeeprom(rgblight_config.mode); - } - - is_rgblight_initialized = true; -} - -void rgblight_reload_from_eeprom(void) { - /* Reset back to what we have in eeprom */ - rgblight_config.raw = eeconfig_read_rgblight(); - RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; - rgblight_check_config(); - eeconfig_debug_rgblight(); // display current eeprom values - if (rgblight_config.enable) { - rgblight_mode_noeeprom(rgblight_config.mode); - } -} - -uint64_t rgblight_read_qword(void) { - return rgblight_config.raw; -} - -void rgblight_update_qword(uint64_t qword) { - RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; - rgblight_config.raw = qword; - if (rgblight_config.enable) - rgblight_mode_noeeprom(rgblight_config.mode); - else { - rgblight_timer_disable(); - rgblight_set(); - } -} - -void rgblight_increase(void) { - uint8_t mode = 0; - if (rgblight_config.mode < RGBLIGHT_MODES) { - mode = rgblight_config.mode + 1; - } - rgblight_mode(mode); -} -void rgblight_decrease(void) { - uint8_t mode = 0; - // Mode will never be < 1. If it ever is, eeprom needs to be initialized. - if (rgblight_config.mode > RGBLIGHT_MODE_STATIC_LIGHT) { - mode = rgblight_config.mode - 1; - } - rgblight_mode(mode); -} -void rgblight_step_helper(bool write_to_eeprom) { - uint8_t mode = 0; - mode = rgblight_config.mode + 1; - if (mode > RGBLIGHT_MODES) { - mode = 1; - } - rgblight_mode_eeprom_helper(mode, write_to_eeprom); -} -void rgblight_step_noeeprom(void) { - rgblight_step_helper(false); -} -void rgblight_step(void) { - rgblight_step_helper(true); -} -void rgblight_step_reverse_helper(bool write_to_eeprom) { - uint8_t mode = 0; - mode = rgblight_config.mode - 1; - if (mode < 1) { - mode = RGBLIGHT_MODES; - } - rgblight_mode_eeprom_helper(mode, write_to_eeprom); -} -void rgblight_step_reverse_noeeprom(void) { - rgblight_step_reverse_helper(false); -} -void rgblight_step_reverse(void) { - rgblight_step_reverse_helper(true); -} - -uint8_t rgblight_get_mode(void) { - if (!rgblight_config.enable) { - return false; - } - - return rgblight_config.mode; -} - -void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { - if (!rgblight_config.enable) { - return; - } - if (mode < RGBLIGHT_MODE_STATIC_LIGHT) { - rgblight_config.mode = RGBLIGHT_MODE_STATIC_LIGHT; - } else if (mode > RGBLIGHT_MODES) { - rgblight_config.mode = RGBLIGHT_MODES; - } else { - rgblight_config.mode = mode; - } - RGBLIGHT_SPLIT_SET_CHANGE_MODE; - if (write_to_eeprom) { - eeconfig_update_rgblight(rgblight_config.raw); - dprintf("rgblight mode [EEPROM]: %u\n", rgblight_config.mode); - } else { - dprintf("rgblight mode [NOEEPROM]: %u\n", rgblight_config.mode); - } - if (is_static_effect(rgblight_config.mode)) { - rgblight_timer_disable(); - } else { - rgblight_timer_enable(); - } -#ifdef RGBLIGHT_USE_TIMER - animation_status.restart = true; -#endif - rgblight_sethsv_noeeprom(rgblight_config.hue, rgblight_config.sat, rgblight_config.val); -} - -void rgblight_mode(uint8_t mode) { - rgblight_mode_eeprom_helper(mode, true); -} - -void rgblight_mode_noeeprom(uint8_t mode) { - rgblight_mode_eeprom_helper(mode, false); -} - -void rgblight_toggle(void) { - dprintf("rgblight toggle [EEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable); - if (rgblight_config.enable) { - rgblight_disable(); - } else { - rgblight_enable(); - } -} - -void rgblight_toggle_noeeprom(void) { - dprintf("rgblight toggle [NOEEPROM]: rgblight_config.enable = %u\n", !rgblight_config.enable); - if (rgblight_config.enable) { - rgblight_disable_noeeprom(); - } else { - rgblight_enable_noeeprom(); - } -} - -void rgblight_enable(void) { - rgblight_config.enable = 1; - // No need to update EEPROM here. rgblight_mode() will do that, actually - // eeconfig_update_rgblight(rgblight_config.raw); - dprintf("rgblight enable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); - rgblight_mode(rgblight_config.mode); -} - -void rgblight_enable_noeeprom(void) { - rgblight_config.enable = 1; - dprintf("rgblight enable [NOEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); - rgblight_mode_noeeprom(rgblight_config.mode); -} - -void rgblight_disable(void) { - rgblight_config.enable = 0; - eeconfig_update_rgblight(rgblight_config.raw); - dprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); - rgblight_timer_disable(); - RGBLIGHT_SPLIT_SET_CHANGE_MODE; - rgblight_set(); -} - -void rgblight_disable_noeeprom(void) { - rgblight_config.enable = 0; - dprintf("rgblight disable [NOEEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); - rgblight_timer_disable(); - RGBLIGHT_SPLIT_SET_CHANGE_MODE; - rgblight_set(); -} - -void rgblight_enabled_noeeprom(bool state) { - state ? rgblight_enable_noeeprom() : rgblight_disable_noeeprom(); -} - -bool rgblight_is_enabled(void) { - return rgblight_config.enable; -} - -void rgblight_increase_hue_helper(bool write_to_eeprom) { - uint8_t hue = rgblight_config.hue + RGBLIGHT_HUE_STEP; - rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom); -} -void rgblight_increase_hue_noeeprom(void) { - rgblight_increase_hue_helper(false); -} -void rgblight_increase_hue(void) { - rgblight_increase_hue_helper(true); -} -void rgblight_decrease_hue_helper(bool write_to_eeprom) { - uint8_t hue = rgblight_config.hue - RGBLIGHT_HUE_STEP; - rgblight_sethsv_eeprom_helper(hue, rgblight_config.sat, rgblight_config.val, write_to_eeprom); -} -void rgblight_decrease_hue_noeeprom(void) { - rgblight_decrease_hue_helper(false); -} -void rgblight_decrease_hue(void) { - rgblight_decrease_hue_helper(true); -} -void rgblight_increase_sat_helper(bool write_to_eeprom) { - uint8_t sat = qadd8(rgblight_config.sat, RGBLIGHT_SAT_STEP); - rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom); -} -void rgblight_increase_sat_noeeprom(void) { - rgblight_increase_sat_helper(false); -} -void rgblight_increase_sat(void) { - rgblight_increase_sat_helper(true); -} -void rgblight_decrease_sat_helper(bool write_to_eeprom) { - uint8_t sat = qsub8(rgblight_config.sat, RGBLIGHT_SAT_STEP); - rgblight_sethsv_eeprom_helper(rgblight_config.hue, sat, rgblight_config.val, write_to_eeprom); -} -void rgblight_decrease_sat_noeeprom(void) { - rgblight_decrease_sat_helper(false); -} -void rgblight_decrease_sat(void) { - rgblight_decrease_sat_helper(true); -} -void rgblight_increase_val_helper(bool write_to_eeprom) { - uint8_t val = qadd8(rgblight_config.val, RGBLIGHT_VAL_STEP); - rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom); -} -void rgblight_increase_val_noeeprom(void) { - rgblight_increase_val_helper(false); -} -void rgblight_increase_val(void) { - rgblight_increase_val_helper(true); -} -void rgblight_decrease_val_helper(bool write_to_eeprom) { - uint8_t val = qsub8(rgblight_config.val, RGBLIGHT_VAL_STEP); - rgblight_sethsv_eeprom_helper(rgblight_config.hue, rgblight_config.sat, val, write_to_eeprom); -} -void rgblight_decrease_val_noeeprom(void) { - rgblight_decrease_val_helper(false); -} -void rgblight_decrease_val(void) { - rgblight_decrease_val_helper(true); -} - -void rgblight_increase_speed_helper(bool write_to_eeprom) { - if (rgblight_config.speed < 3) rgblight_config.speed++; - // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED? - if (write_to_eeprom) { - eeconfig_update_rgblight(rgblight_config.raw); - } -} -void rgblight_increase_speed(void) { - rgblight_increase_speed_helper(true); -} -void rgblight_increase_speed_noeeprom(void) { - rgblight_increase_speed_helper(false); -} - -void rgblight_decrease_speed_helper(bool write_to_eeprom) { - if (rgblight_config.speed > 0) rgblight_config.speed--; - // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED?? - if (write_to_eeprom) { - eeconfig_update_rgblight(rgblight_config.raw); - } -} -void rgblight_decrease_speed(void) { - rgblight_decrease_speed_helper(true); -} -void rgblight_decrease_speed_noeeprom(void) { - rgblight_decrease_speed_helper(false); -} - -void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) { - if (rgblight_config.enable) { - LED_TYPE tmp_led; - sethsv(hue, sat, val, &tmp_led); - rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); - } -} - -void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom) { - if (rgblight_config.enable) { -#ifdef RGBLIGHT_SPLIT - if (rgblight_config.hue != hue || rgblight_config.sat != sat || rgblight_config.val != val) { - RGBLIGHT_SPLIT_SET_CHANGE_HSVS; - } -#endif - rgblight_status.base_mode = mode_base_table[rgblight_config.mode]; - if (rgblight_config.mode == RGBLIGHT_MODE_STATIC_LIGHT) { - // same static color - LED_TYPE tmp_led; -#ifdef RGBLIGHT_LAYERS_RETAIN_VAL - // needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val - rgblight_config.val = val; -#endif - sethsv(hue, sat, val, &tmp_led); - rgblight_setrgb(tmp_led.r, tmp_led.g, tmp_led.b); - } else { - // all LEDs in same color - if (1 == 0) { // dummy - } -#ifdef RGBLIGHT_EFFECT_BREATHING - else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) { - // breathing mode, ignore the change of val, use in memory value instead - val = rgblight_config.val; - } -#endif -#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD - else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_MOOD) { - // rainbow mood, ignore the change of hue - hue = rgblight_config.hue; - } -#endif -#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL - else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_SWIRL) { - // rainbow swirl, ignore the change of hue - hue = rgblight_config.hue; - } -#endif -#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT - else if (rgblight_status.base_mode == RGBLIGHT_MODE_STATIC_GRADIENT) { - // static gradient - uint8_t delta = rgblight_config.mode - rgblight_status.base_mode; - bool direction = (delta % 2) == 0; - - uint8_t range = pgm_read_byte(&RGBLED_GRADIENT_RANGES[delta / 2]); - for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) { - uint8_t _hue = ((uint16_t)i * (uint16_t)range) / rgblight_ranges.effect_num_leds; - if (direction) { - _hue = hue + _hue; - } else { - _hue = hue - _hue; - } - dprintf("rgblight rainbow set hsv: %d,%d,%d,%u\n", i, _hue, direction, range); - sethsv(_hue, sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]); - } -# ifdef RGBLIGHT_LAYERS_RETAIN_VAL - // needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val - rgblight_config.val = val; -# endif - rgblight_set(); - } -#endif - } - rgblight_config.hue = hue; - rgblight_config.sat = sat; - rgblight_config.val = val; - if (write_to_eeprom) { - eeconfig_update_rgblight(rgblight_config.raw); - dprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); - } else { - dprintf("rgblight set hsv [NOEEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); - } - } -} - -void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val) { - rgblight_sethsv_eeprom_helper(hue, sat, val, true); -} - -void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val) { - rgblight_sethsv_eeprom_helper(hue, sat, val, false); -} - -uint8_t rgblight_get_speed(void) { - return rgblight_config.speed; -} - -void rgblight_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { - rgblight_config.speed = speed; - if (write_to_eeprom) { - eeconfig_update_rgblight(rgblight_config.raw); - dprintf("rgblight set speed [EEPROM]: %u\n", rgblight_config.speed); - } else { - dprintf("rgblight set speed [NOEEPROM]: %u\n", rgblight_config.speed); - } -} - -void rgblight_set_speed(uint8_t speed) { - rgblight_set_speed_eeprom_helper(speed, true); -} - -void rgblight_set_speed_noeeprom(uint8_t speed) { - rgblight_set_speed_eeprom_helper(speed, false); -} - -uint8_t rgblight_get_hue(void) { - return rgblight_config.hue; -} - -uint8_t rgblight_get_sat(void) { - return rgblight_config.sat; -} - -uint8_t rgblight_get_val(void) { - return rgblight_config.val; -} - -HSV rgblight_get_hsv(void) { - return (HSV){rgblight_config.hue, rgblight_config.sat, rgblight_config.val}; -} - -void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b) { - if (!rgblight_config.enable) { - return; - } - - for (uint8_t i = rgblight_ranges.effect_start_pos; i < rgblight_ranges.effect_end_pos; i++) { - led[i].r = r; - led[i].g = g; - led[i].b = b; -#ifdef RGBW - led[i].w = 0; -#endif - } - rgblight_set(); -} - -void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index) { - if (!rgblight_config.enable || index >= RGBLED_NUM) { - return; - } - - led[index].r = r; - led[index].g = g; - led[index].b = b; -#ifdef RGBW - led[index].w = 0; -#endif - rgblight_set(); -} - -void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index) { - if (!rgblight_config.enable) { - return; - } - - LED_TYPE tmp_led; - sethsv(hue, sat, val, &tmp_led); - rgblight_setrgb_at(tmp_led.r, tmp_led.g, tmp_led.b, index); -} - -#if defined(RGBLIGHT_EFFECT_BREATHING) || defined(RGBLIGHT_EFFECT_RAINBOW_MOOD) || defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL) || defined(RGBLIGHT_EFFECT_SNAKE) || defined(RGBLIGHT_EFFECT_KNIGHT) || defined(RGBLIGHT_EFFECT_TWINKLE) - -static uint8_t get_interval_time(const uint8_t *default_interval_address, uint8_t velocikey_min, uint8_t velocikey_max) { - return -# ifdef VELOCIKEY_ENABLE - velocikey_enabled() ? velocikey_match_speed(velocikey_min, velocikey_max) : -# endif - pgm_read_byte(default_interval_address); -} - -#endif - -void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end) { - if (!rgblight_config.enable || start < 0 || start >= end || end > RGBLED_NUM) { - return; - } - - for (uint8_t i = start; i < end; i++) { - led[i].r = r; - led[i].g = g; - led[i].b = b; -#ifdef RGBW - led[i].w = 0; -#endif - } - rgblight_set(); -} - -void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end) { - if (!rgblight_config.enable) { - return; - } - - LED_TYPE tmp_led; - sethsv(hue, sat, val, &tmp_led); - rgblight_setrgb_range(tmp_led.r, tmp_led.g, tmp_led.b, start, end); -} - -#ifndef RGBLIGHT_SPLIT -void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b) { - rgblight_setrgb_range(r, g, b, 0, (uint8_t)RGBLED_NUM / 2); -} - -void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b) { - rgblight_setrgb_range(r, g, b, (uint8_t)RGBLED_NUM / 2, (uint8_t)RGBLED_NUM); -} - -void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val) { - rgblight_sethsv_range(hue, sat, val, 0, (uint8_t)RGBLED_NUM / 2); -} - -void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val) { - rgblight_sethsv_range(hue, sat, val, (uint8_t)RGBLED_NUM / 2, (uint8_t)RGBLED_NUM); -} -#endif // ifndef RGBLIGHT_SPLIT - -#ifdef RGBLIGHT_LAYERS -void rgblight_set_layer_state(uint8_t layer, bool enabled) { - rgblight_layer_mask_t mask = (rgblight_layer_mask_t)1 << layer; - if (enabled) { - rgblight_status.enabled_layer_mask |= mask; - } else { - rgblight_status.enabled_layer_mask &= ~mask; - } - RGBLIGHT_SPLIT_SET_CHANGE_LAYERS; - - // Calling rgblight_set() here (directly or indirectly) could - // potentially cause timing issues when there are multiple - // successive calls to rgblight_set_layer_state(). Instead, - // set a flag and do it the next time rgblight_task() runs. - - deferred_set_layer_state = true; -} - -bool rgblight_get_layer_state(uint8_t layer) { - rgblight_layer_mask_t mask = (rgblight_layer_mask_t)1 << layer; - return (rgblight_status.enabled_layer_mask & mask) != 0; -} - -// Write any enabled LED layers into the buffer -static void rgblight_layers_write(void) { -# ifdef RGBLIGHT_LAYERS_RETAIN_VAL - uint8_t current_val = rgblight_get_val(); -# endif - uint8_t i = 0; - // For each layer - for (const rgblight_segment_t *const *layer_ptr = rgblight_layers; i < RGBLIGHT_MAX_LAYERS; layer_ptr++, i++) { - if (!rgblight_get_layer_state(i)) { - continue; // Layer is disabled - } - const rgblight_segment_t *segment_ptr = pgm_read_ptr(layer_ptr); - if (segment_ptr == NULL) { - break; // No more layers - } - // For each segment - while (1) { - rgblight_segment_t segment; - memcpy_P(&segment, segment_ptr, sizeof(rgblight_segment_t)); - if (segment.index == RGBLIGHT_END_SEGMENT_INDEX) { - break; // No more segments - } - // Write segment.count LEDs - LED_TYPE *const limit = &led[MIN(segment.index + segment.count, RGBLED_NUM)]; - for (LED_TYPE *led_ptr = &led[segment.index]; led_ptr < limit; led_ptr++) { -# ifdef RGBLIGHT_LAYERS_RETAIN_VAL - sethsv(segment.hue, segment.sat, current_val, led_ptr); -# else - sethsv(segment.hue, segment.sat, segment.val, led_ptr); -# endif - } - segment_ptr++; - } - } -} - -# ifdef RGBLIGHT_LAYER_BLINK -rgblight_layer_mask_t _blinking_layer_mask = 0; -static uint16_t _repeat_timer; -static uint8_t _times_remaining; -static uint16_t _dur; - -void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms) { - rgblight_blink_layer_repeat(layer, duration_ms, 1); -} - -void rgblight_blink_layer_repeat(uint8_t layer, uint16_t duration_ms, uint8_t times) { - if (times > UINT8_MAX / 2) { - times = UINT8_MAX / 2; - } - - _times_remaining = times * 2; - _dur = duration_ms; - - rgblight_set_layer_state(layer, true); - _times_remaining--; - _blinking_layer_mask |= (rgblight_layer_mask_t)1 << layer; - _repeat_timer = sync_timer_read() + duration_ms; -} - -void rgblight_unblink_layer(uint8_t layer) { - rgblight_set_layer_state(layer, false); - _blinking_layer_mask &= ~((rgblight_layer_mask_t)1 << layer); -} - -void rgblight_unblink_all_but_layer(uint8_t layer) { - for (uint8_t i = 0; i < RGBLIGHT_MAX_LAYERS; i++) { - if (i != layer) { - if ((_blinking_layer_mask & (rgblight_layer_mask_t)1 << i) != 0) { - rgblight_unblink_layer(i); - } - } - } -} - -void rgblight_blink_layer_repeat_helper(void) { - if (_blinking_layer_mask != 0 && timer_expired(sync_timer_read(), _repeat_timer)) { - for (uint8_t layer = 0; layer < RGBLIGHT_MAX_LAYERS; layer++) { - if ((_blinking_layer_mask & (rgblight_layer_mask_t)1 << layer) != 0) { - if (_times_remaining % 2 == 1) { - rgblight_set_layer_state(layer, false); - } else { - rgblight_set_layer_state(layer, true); - } - } - } - _times_remaining--; - if (_times_remaining <= 0) { - _blinking_layer_mask = 0; - } else { - _repeat_timer = sync_timer_read() + _dur; - } - } -} -# endif - -#endif - -#ifdef RGBLIGHT_SLEEP - -void rgblight_suspend(void) { - rgblight_timer_disable(); - if (!is_suspended) { - is_suspended = true; - pre_suspend_enabled = rgblight_config.enable; - -# ifdef RGBLIGHT_LAYER_BLINK - // make sure any layer blinks don't come back after suspend - rgblight_status.enabled_layer_mask &= ~_blinking_layer_mask; - _blinking_layer_mask = 0; -# endif - - rgblight_disable_noeeprom(); - } -} - -void rgblight_wakeup(void) { - is_suspended = false; - - if (pre_suspend_enabled) { - rgblight_enable_noeeprom(); - } -# ifdef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF - // Need this or else the LEDs won't be set - else if (rgblight_status.enabled_layer_mask != 0) { - rgblight_set(); - } -# endif - - rgblight_timer_enable(); -} - -#endif - -__attribute__((weak)) void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) { - ws2812_setleds(start_led, num_leds); -} - -#ifndef RGBLIGHT_CUSTOM_DRIVER - -void rgblight_set(void) { - LED_TYPE *start_led; - uint8_t num_leds = rgblight_ranges.clipping_num_leds; - - if (!rgblight_config.enable) { - for (uint8_t i = rgblight_ranges.effect_start_pos; i < rgblight_ranges.effect_end_pos; i++) { - led[i].r = 0; - led[i].g = 0; - led[i].b = 0; -# ifdef RGBW - led[i].w = 0; -# endif - } - } - -# ifdef RGBLIGHT_LAYERS - if (rgblight_layers != NULL -# if !defined(RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF) - && rgblight_config.enable -# elif defined(RGBLIGHT_SLEEP) - && !is_suspended -# endif - ) { - rgblight_layers_write(); - } -# endif - -# ifdef RGBLIGHT_LED_MAP - LED_TYPE led0[RGBLED_NUM]; - for (uint8_t i = 0; i < RGBLED_NUM; i++) { - led0[i] = led[pgm_read_byte(&led_map[i])]; - } - start_led = led0 + rgblight_ranges.clipping_start_pos; -# else - start_led = led + rgblight_ranges.clipping_start_pos; -# endif - -# ifdef RGBW - for (uint8_t i = 0; i < num_leds; i++) { - convert_rgb_to_rgbw(&start_led[i]); - } -# endif - rgblight_call_driver(start_led, num_leds); -} -#endif - -#ifdef RGBLIGHT_SPLIT -/* for split keyboard master side */ -uint8_t rgblight_get_change_flags(void) { - return rgblight_status.change_flags; -} - -void rgblight_clear_change_flags(void) { - rgblight_status.change_flags = 0; -} - -void rgblight_get_syncinfo(rgblight_syncinfo_t *syncinfo) { - syncinfo->config = rgblight_config; - syncinfo->status = rgblight_status; -} - -/* for split keyboard slave side */ -void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom) { -# ifdef RGBLIGHT_LAYERS - if (syncinfo->status.change_flags & RGBLIGHT_STATUS_CHANGE_LAYERS) { - rgblight_status.enabled_layer_mask = syncinfo->status.enabled_layer_mask; - } -# endif - if (syncinfo->status.change_flags & RGBLIGHT_STATUS_CHANGE_MODE) { - if (syncinfo->config.enable) { - rgblight_config.enable = 1; // == rgblight_enable_noeeprom(); - rgblight_mode_eeprom_helper(syncinfo->config.mode, write_to_eeprom); - } else { - rgblight_disable_noeeprom(); - } - } - if (syncinfo->status.change_flags & RGBLIGHT_STATUS_CHANGE_HSVS) { - rgblight_sethsv_eeprom_helper(syncinfo->config.hue, syncinfo->config.sat, syncinfo->config.val, write_to_eeprom); - // rgblight_config.speed = config->speed; // NEED??? - } -# ifdef RGBLIGHT_USE_TIMER - if (syncinfo->status.change_flags & RGBLIGHT_STATUS_CHANGE_TIMER) { - if (syncinfo->status.timer_enabled) { - rgblight_timer_enable(); - } else { - rgblight_timer_disable(); - } - } -# ifndef RGBLIGHT_SPLIT_NO_ANIMATION_SYNC - if (syncinfo->status.change_flags & RGBLIGHT_STATUS_ANIMATION_TICK) { - animation_status.restart = true; - } -# endif /* RGBLIGHT_SPLIT_NO_ANIMATION_SYNC */ -# endif /* RGBLIGHT_USE_TIMER */ -} -#endif /* RGBLIGHT_SPLIT */ - -#ifdef RGBLIGHT_USE_TIMER - -typedef void (*effect_func_t)(animation_status_t *anim); - -// Animation timer -- use system timer (AVR Timer0) -void rgblight_timer_init(void) { - rgblight_status.timer_enabled = false; - RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE; -} -void rgblight_timer_enable(void) { - if (!is_static_effect(rgblight_config.mode)) { - rgblight_status.timer_enabled = true; - } - animation_status.last_timer = sync_timer_read(); - RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE; - dprintf("rgblight timer enabled.\n"); -} -void rgblight_timer_disable(void) { - rgblight_status.timer_enabled = false; - RGBLIGHT_SPLIT_SET_CHANGE_TIMER_ENABLE; - dprintf("rgblight timer disable.\n"); -} -void rgblight_timer_toggle(void) { - dprintf("rgblight timer toggle.\n"); - if (rgblight_status.timer_enabled) { - rgblight_timer_disable(); - } else { - rgblight_timer_enable(); - } -} - -void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b) { - rgblight_enable(); - rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); - rgblight_setrgb(r, g, b); -} - -static void rgblight_effect_dummy(animation_status_t *anim) { - // do nothing - /******** - dprintf("rgblight_task() what happened?\n"); - dprintf("is_static_effect %d\n", is_static_effect(rgblight_config.mode)); - dprintf("mode = %d, base_mode = %d, timer_enabled %d, ", - rgblight_config.mode, rgblight_status.base_mode, - rgblight_status.timer_enabled); - dprintf("last_timer = %d\n",anim->last_timer); - **/ -} - -void rgblight_task(void) { - if (rgblight_status.timer_enabled) { - effect_func_t effect_func = rgblight_effect_dummy; - uint16_t interval_time = 2000; // dummy interval - uint8_t delta = rgblight_config.mode - rgblight_status.base_mode; - animation_status.delta = delta; - - // static light mode, do nothing here - if (1 == 0) { // dummy - } -# ifdef RGBLIGHT_EFFECT_BREATHING - else if (rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) { - // breathing mode - interval_time = get_interval_time(&RGBLED_BREATHING_INTERVALS[delta], 1, 100); - effect_func = rgblight_effect_breathing; - } -# endif -# ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD - else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_MOOD) { - // rainbow mood mode - interval_time = get_interval_time(&RGBLED_RAINBOW_MOOD_INTERVALS[delta], 5, 100); - effect_func = rgblight_effect_rainbow_mood; - } -# endif -# ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL - else if (rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_SWIRL) { - // rainbow swirl mode - interval_time = get_interval_time(&RGBLED_RAINBOW_SWIRL_INTERVALS[delta / 2], 1, 100); - effect_func = rgblight_effect_rainbow_swirl; - } -# endif -# ifdef RGBLIGHT_EFFECT_SNAKE - else if (rgblight_status.base_mode == RGBLIGHT_MODE_SNAKE) { - // snake mode - interval_time = get_interval_time(&RGBLED_SNAKE_INTERVALS[delta / 2], 1, 200); - effect_func = rgblight_effect_snake; - } -# endif -# ifdef RGBLIGHT_EFFECT_KNIGHT - else if (rgblight_status.base_mode == RGBLIGHT_MODE_KNIGHT) { - // knight mode - interval_time = get_interval_time(&RGBLED_KNIGHT_INTERVALS[delta], 5, 100); - effect_func = rgblight_effect_knight; - } -# endif -# ifdef RGBLIGHT_EFFECT_CHRISTMAS - else if (rgblight_status.base_mode == RGBLIGHT_MODE_CHRISTMAS) { - // christmas mode - interval_time = RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL; - effect_func = (effect_func_t)rgblight_effect_christmas; - } -# endif -# ifdef RGBLIGHT_EFFECT_RGB_TEST - else if (rgblight_status.base_mode == RGBLIGHT_MODE_RGB_TEST) { - // RGB test mode - interval_time = pgm_read_word(&RGBLED_RGBTEST_INTERVALS[0]); - effect_func = (effect_func_t)rgblight_effect_rgbtest; - } -# endif -# ifdef RGBLIGHT_EFFECT_ALTERNATING - else if (rgblight_status.base_mode == RGBLIGHT_MODE_ALTERNATING) { - interval_time = 500; - effect_func = (effect_func_t)rgblight_effect_alternating; - } -# endif -# ifdef RGBLIGHT_EFFECT_TWINKLE - else if (rgblight_status.base_mode == RGBLIGHT_MODE_TWINKLE) { - interval_time = get_interval_time(&RGBLED_TWINKLE_INTERVALS[delta % 3], 5, 30); - effect_func = (effect_func_t)rgblight_effect_twinkle; - } -# endif - if (animation_status.restart) { - animation_status.restart = false; - animation_status.last_timer = sync_timer_read(); - animation_status.pos16 = 0; // restart signal to local each effect - } - uint16_t now = sync_timer_read(); - if (timer_expired(now, animation_status.last_timer)) { -# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) - static uint16_t report_last_timer = 0; - static bool tick_flag = false; - uint16_t oldpos16; - if (tick_flag) { - tick_flag = false; - if (timer_expired(now, report_last_timer)) { - report_last_timer += 30000; - dprintf("rgblight animation tick report to slave\n"); - RGBLIGHT_SPLIT_ANIMATION_TICK; - } - } - oldpos16 = animation_status.pos16; -# endif - animation_status.last_timer += interval_time; - effect_func(&animation_status); -# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) - if (animation_status.pos16 == 0 && oldpos16 != 0) { - tick_flag = true; - } -# endif - } - } - -# ifdef RGBLIGHT_LAYERS -# ifdef RGBLIGHT_LAYER_BLINK - rgblight_blink_layer_repeat_helper(); -# endif - - if (deferred_set_layer_state) { - deferred_set_layer_state = false; - - // Static modes don't have a ticker running to update the LEDs - if (rgblight_status.timer_enabled == false) { - rgblight_mode_noeeprom(rgblight_config.mode); - } - -# ifdef RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF - // If not enabled, then nothing else will actually set the LEDs... - if (!rgblight_config.enable) { - rgblight_set(); - } -# endif - } -# endif -} - -#endif /* RGBLIGHT_USE_TIMER */ - -#if defined(RGBLIGHT_EFFECT_BREATHING) || defined(RGBLIGHT_EFFECT_TWINKLE) - -# ifndef RGBLIGHT_EFFECT_BREATHE_CENTER -# ifndef RGBLIGHT_BREATHE_TABLE_SIZE -# define RGBLIGHT_BREATHE_TABLE_SIZE 256 // 256 or 128 or 64 -# endif -# include <rgblight_breathe_table.h> -# endif - -static uint8_t breathe_calc(uint8_t pos) { - // http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ -# ifdef RGBLIGHT_EFFECT_BREATHE_TABLE - return pgm_read_byte(&rgblight_effect_breathe_table[pos / table_scale]); -# else - return (exp(sin((pos / 255.0) * M_PI)) - RGBLIGHT_EFFECT_BREATHE_CENTER / M_E) * (RGBLIGHT_EFFECT_BREATHE_MAX / (M_E - 1 / M_E)); -# endif -} - -#endif - -// Effects -#ifdef RGBLIGHT_EFFECT_BREATHING - -__attribute__((weak)) const uint8_t RGBLED_BREATHING_INTERVALS[] PROGMEM = {30, 20, 10, 5}; - -void rgblight_effect_breathing(animation_status_t *anim) { - uint8_t val = breathe_calc(anim->pos); - rgblight_sethsv_noeeprom_old(rgblight_config.hue, rgblight_config.sat, val); - anim->pos = (anim->pos + 1); -} -#endif - -#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD -__attribute__((weak)) const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[] PROGMEM = {120, 60, 30}; - -void rgblight_effect_rainbow_mood(animation_status_t *anim) { - rgblight_sethsv_noeeprom_old(anim->current_hue, rgblight_config.sat, rgblight_config.val); - anim->current_hue++; -} -#endif - -#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL -# ifndef RGBLIGHT_RAINBOW_SWIRL_RANGE -# define RGBLIGHT_RAINBOW_SWIRL_RANGE 255 -# endif - -__attribute__((weak)) const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[] PROGMEM = {100, 50, 20}; - -void rgblight_effect_rainbow_swirl(animation_status_t *anim) { - uint8_t hue; - uint8_t i; - - for (i = 0; i < rgblight_ranges.effect_num_leds; i++) { - hue = (RGBLIGHT_RAINBOW_SWIRL_RANGE / rgblight_ranges.effect_num_leds * i + anim->current_hue); - sethsv(hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]); - } - rgblight_set(); - - if (anim->delta % 2) { - anim->current_hue++; - } else { - anim->current_hue--; - } -} -#endif - -#ifdef RGBLIGHT_EFFECT_SNAKE -__attribute__((weak)) const uint8_t RGBLED_SNAKE_INTERVALS[] PROGMEM = {100, 50, 20}; - -void rgblight_effect_snake(animation_status_t *anim) { - static uint8_t pos = 0; - uint8_t i, j; - int8_t k; - int8_t increment = 1; - - if (anim->delta % 2) { - increment = -1; - } - -# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) - if (anim->pos == 0) { // restart signal - if (increment == 1) { - pos = rgblight_ranges.effect_num_leds - 1; - } else { - pos = 0; - } - anim->pos = 1; - } -# endif - - for (i = 0; i < rgblight_ranges.effect_num_leds; i++) { - LED_TYPE *ledp = led + i + rgblight_ranges.effect_start_pos; - ledp->r = 0; - ledp->g = 0; - ledp->b = 0; -# ifdef RGBW - ledp->w = 0; -# endif - for (j = 0; j < RGBLIGHT_EFFECT_SNAKE_LENGTH; j++) { - k = pos + j * increment; - if (k > RGBLED_NUM) { - k = k % (RGBLED_NUM); - } - if (k < 0) { - k = k + rgblight_ranges.effect_num_leds; - } - if (i == k) { - sethsv(rgblight_config.hue, rgblight_config.sat, (uint8_t)(rgblight_config.val * (RGBLIGHT_EFFECT_SNAKE_LENGTH - j) / RGBLIGHT_EFFECT_SNAKE_LENGTH), ledp); - } - } - } - rgblight_set(); - if (increment == 1) { - if (pos - RGBLIGHT_EFFECT_SNAKE_INCREMENT < 0) { - pos = rgblight_ranges.effect_num_leds - 1; -# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) - anim->pos = 0; -# endif - } else { - pos -= RGBLIGHT_EFFECT_SNAKE_INCREMENT; -# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) - anim->pos = 1; -# endif - } - } else { - pos = (pos + RGBLIGHT_EFFECT_SNAKE_INCREMENT) % rgblight_ranges.effect_num_leds; -# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) - anim->pos = pos; -# endif - } -} -#endif - -#ifdef RGBLIGHT_EFFECT_KNIGHT -__attribute__((weak)) const uint8_t RGBLED_KNIGHT_INTERVALS[] PROGMEM = {127, 63, 31}; - -void rgblight_effect_knight(animation_status_t *anim) { - static int8_t low_bound = 0; - static int8_t high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1; - static int8_t increment = RGBLIGHT_EFFECT_KNIGHT_INCREMENT; - uint8_t i, cur; - -# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) - if (anim->pos == 0) { // restart signal - anim->pos = 1; - low_bound = 0; - high_bound = RGBLIGHT_EFFECT_KNIGHT_LENGTH - 1; - increment = 1; - } -# endif - // Set all the LEDs to 0 - for (i = rgblight_ranges.effect_start_pos; i < rgblight_ranges.effect_end_pos; i++) { - led[i].r = 0; - led[i].g = 0; - led[i].b = 0; -# ifdef RGBW - led[i].w = 0; -# endif - } - // Determine which LEDs should be lit up - for (i = 0; i < RGBLIGHT_EFFECT_KNIGHT_LED_NUM; i++) { - cur = (i + RGBLIGHT_EFFECT_KNIGHT_OFFSET) % rgblight_ranges.effect_num_leds + rgblight_ranges.effect_start_pos; - - if (i >= low_bound && i <= high_bound) { - sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, (LED_TYPE *)&led[cur]); - } else { - led[cur].r = 0; - led[cur].g = 0; - led[cur].b = 0; -# ifdef RGBW - led[cur].w = 0; -# endif - } - } - rgblight_set(); - - // Move from low_bound to high_bound changing the direction we increment each - // time a boundary is hit. - low_bound += increment; - high_bound += increment; - - if (high_bound <= 0 || low_bound >= RGBLIGHT_EFFECT_KNIGHT_LED_NUM - 1) { - increment = -increment; -# if defined(RGBLIGHT_SPLIT) && !defined(RGBLIGHT_SPLIT_NO_ANIMATION_SYNC) - if (increment == 1) { - anim->pos = 0; - } -# endif - } -} -#endif - -#ifdef RGBLIGHT_EFFECT_CHRISTMAS -# define CUBED(x) ((x) * (x) * (x)) - -/** - * Christmas lights effect, with a smooth animation between red & green. - */ -void rgblight_effect_christmas(animation_status_t *anim) { - static int8_t increment = 1; - const uint8_t max_pos = 32; - const uint8_t hue_green = 85; - - uint32_t xa; - uint8_t hue, val; - uint8_t i; - - // The effect works by animating anim->pos from 0 to 32 and back to 0. - // The pos is used in a cubic bezier formula to ease-in-out between red and green, leaving the interpolated colors visible as short as possible. - xa = CUBED((uint32_t)anim->pos); - hue = ((uint32_t)hue_green) * xa / (xa + CUBED((uint32_t)(max_pos - anim->pos))); - // Additionally, these interpolated colors get shown with a slightly darker value, to make them less prominent than the main colors. - val = 255 - (3 * (hue < hue_green / 2 ? hue : hue_green - hue) / 2); - - for (i = 0; i < rgblight_ranges.effect_num_leds; i++) { - uint8_t local_hue = (i / RGBLIGHT_EFFECT_CHRISTMAS_STEP) % 2 ? hue : hue_green - hue; - sethsv(local_hue, rgblight_config.sat, val, (LED_TYPE *)&led[i + rgblight_ranges.effect_start_pos]); - } - rgblight_set(); - - if (anim->pos == 0) { - increment = 1; - } else if (anim->pos == max_pos) { - increment = -1; - } - anim->pos += increment; -} -#endif - -#ifdef RGBLIGHT_EFFECT_RGB_TEST -__attribute__((weak)) const uint16_t RGBLED_RGBTEST_INTERVALS[] PROGMEM = {1024}; - -void rgblight_effect_rgbtest(animation_status_t *anim) { - static uint8_t maxval = 0; - uint8_t g; - uint8_t r; - uint8_t b; - - if (maxval == 0) { - LED_TYPE tmp_led; - sethsv(0, 255, RGBLIGHT_LIMIT_VAL, &tmp_led); - maxval = tmp_led.r; - } - g = r = b = 0; - switch (anim->pos) { - case 0: - r = maxval; - break; - case 1: - g = maxval; - break; - case 2: - b = maxval; - break; - } - rgblight_setrgb(r, g, b); - anim->pos = (anim->pos + 1) % 3; -} -#endif - -#ifdef RGBLIGHT_EFFECT_ALTERNATING -void rgblight_effect_alternating(animation_status_t *anim) { - for (int i = 0; i < rgblight_ranges.effect_num_leds; i++) { - LED_TYPE *ledp = led + i + rgblight_ranges.effect_start_pos; - if (i < rgblight_ranges.effect_num_leds / 2 && anim->pos) { - sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, ledp); - } else if (i >= rgblight_ranges.effect_num_leds / 2 && !anim->pos) { - sethsv(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, ledp); - } else { - sethsv(rgblight_config.hue, rgblight_config.sat, 0, ledp); - } - } - rgblight_set(); - anim->pos = (anim->pos + 1) % 2; -} -#endif - -#ifdef RGBLIGHT_EFFECT_TWINKLE -__attribute__((weak)) const uint8_t RGBLED_TWINKLE_INTERVALS[] PROGMEM = {30, 15, 5}; - -typedef struct PACKED { - HSV hsv; - uint8_t life; - uint8_t max_life; -} TwinkleState; - -static TwinkleState led_twinkle_state[RGBLED_NUM]; - -void rgblight_effect_twinkle(animation_status_t *anim) { - const bool random_color = anim->delta / 3; - const bool restart = anim->pos == 0; - anim->pos = 1; - - const uint8_t bottom = breathe_calc(0); - const uint8_t top = breathe_calc(127); - - uint8_t frac(uint8_t n, uint8_t d) { - return (uint16_t)255 * n / d; - } - uint8_t scale(uint16_t v, uint8_t scale) { - return (v * scale) >> 8; - } - - const uint8_t trigger = scale((uint16_t)0xFF * RGBLIGHT_EFFECT_TWINKLE_PROBABILITY, 127 + rgblight_config.val / 2); - - for (uint8_t i = 0; i < rgblight_ranges.effect_num_leds; i++) { - TwinkleState *t = &(led_twinkle_state[i]); - HSV * c = &(t->hsv); - - if (!random_color) { - c->h = rgblight_config.hue; - c->s = rgblight_config.sat; - } - - if (restart) { - // Restart - t->life = 0; - c->v = 0; - } else if (t->life) { - // This LED is already on, either brightening or dimming - t->life--; - uint8_t unscaled = frac(breathe_calc(frac(t->life, t->max_life)) - bottom, top - bottom); - c->v = scale(rgblight_config.val, unscaled); - } else if ((rand() % 0xFF) < trigger) { - // This LED is off, but was randomly selected to start brightening - if (random_color) { - c->h = rand() % 0xFF; - c->s = (rand() % (rgblight_config.sat / 2)) + (rgblight_config.sat / 2); - } - c->v = 0; - t->max_life = MAX(20, MIN(RGBLIGHT_EFFECT_TWINKLE_LIFE, rgblight_config.val)); - t->life = t->max_life; - } else { - // This LED is off, and was NOT selected to start brightening - } - - LED_TYPE *ledp = led + i + rgblight_ranges.effect_start_pos; - sethsv(c->h, c->s, c->v, ledp); - } - - rgblight_set(); -} -#endif diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h deleted file mode 100644 index 001058f962..0000000000 --- a/quantum/rgblight/rgblight.h +++ /dev/null @@ -1,448 +0,0 @@ -/* Copyright 2017 Yang Liu - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -/***** rgblight_mode(mode)/rgblight_mode_noeeprom(mode) **** - - old mode number (before 0.6.117) to new mode name table - -|-----------------|-----------------------------------| -| old mode number | new mode name | -|-----------------|-----------------------------------| -| 1 | RGBLIGHT_MODE_STATIC_LIGHT | -| 2 | RGBLIGHT_MODE_BREATHING | -| 3 | RGBLIGHT_MODE_BREATHING + 1 | -| 4 | RGBLIGHT_MODE_BREATHING + 2 | -| 5 | RGBLIGHT_MODE_BREATHING + 3 | -| 6 | RGBLIGHT_MODE_RAINBOW_MOOD | -| 7 | RGBLIGHT_MODE_RAINBOW_MOOD + 1 | -| 8 | RGBLIGHT_MODE_RAINBOW_MOOD + 2 | -| 9 | RGBLIGHT_MODE_RAINBOW_SWIRL | -| 10 | RGBLIGHT_MODE_RAINBOW_SWIRL + 1 | -| 11 | RGBLIGHT_MODE_RAINBOW_SWIRL + 2 | -| 12 | RGBLIGHT_MODE_RAINBOW_SWIRL + 3 | -| 13 | RGBLIGHT_MODE_RAINBOW_SWIRL + 4 | -| 14 | RGBLIGHT_MODE_RAINBOW_SWIRL + 5 | -| 15 | RGBLIGHT_MODE_SNAKE | -| 16 | RGBLIGHT_MODE_SNAKE + 1 | -| 17 | RGBLIGHT_MODE_SNAKE + 2 | -| 18 | RGBLIGHT_MODE_SNAKE + 3 | -| 19 | RGBLIGHT_MODE_SNAKE + 4 | -| 20 | RGBLIGHT_MODE_SNAKE + 5 | -| 21 | RGBLIGHT_MODE_KNIGHT | -| 22 | RGBLIGHT_MODE_KNIGHT + 1 | -| 23 | RGBLIGHT_MODE_KNIGHT + 2 | -| 24 | RGBLIGHT_MODE_CHRISTMAS | -| 25 | RGBLIGHT_MODE_STATIC_GRADIENT | -| 26 | RGBLIGHT_MODE_STATIC_GRADIENT + 1 | -| 27 | RGBLIGHT_MODE_STATIC_GRADIENT + 2 | -| 28 | RGBLIGHT_MODE_STATIC_GRADIENT + 3 | -| 29 | RGBLIGHT_MODE_STATIC_GRADIENT + 4 | -| 30 | RGBLIGHT_MODE_STATIC_GRADIENT + 5 | -| 31 | RGBLIGHT_MODE_STATIC_GRADIENT + 6 | -| 32 | RGBLIGHT_MODE_STATIC_GRADIENT + 7 | -| 33 | RGBLIGHT_MODE_STATIC_GRADIENT + 8 | -| 34 | RGBLIGHT_MODE_STATIC_GRADIENT + 9 | -| 35 | RGBLIGHT_MODE_RGB_TEST | -| 36 | RGBLIGHT_MODE_ALTERNATING | -| 37 | RGBLIGHT_MODE_TWINKLE | -| 38 | RGBLIGHT_MODE_TWINKLE + 1 | -| 39 | RGBLIGHT_MODE_TWINKLE + 2 | -| 40 | RGBLIGHT_MODE_TWINKLE + 3 | -| 41 | RGBLIGHT_MODE_TWINKLE + 4 | -| 42 | RGBLIGHT_MODE_TWINKLE + 5 | -|-----------------|-----------------------------------| - *****/ - -// clang-format off - -// check dynamic animation effects chose ? -#if defined(RGBLIGHT_EFFECT_BREATHING) \ - || defined(RGBLIGHT_EFFECT_RAINBOW_MOOD) \ - || defined(RGBLIGHT_EFFECT_RAINBOW_SWIRL) \ - || defined(RGBLIGHT_EFFECT_SNAKE) \ - || defined(RGBLIGHT_EFFECT_KNIGHT) \ - || defined(RGBLIGHT_EFFECT_CHRISTMAS) \ - || defined(RGBLIGHT_EFFECT_RGB_TEST) \ - || defined(RGBLIGHT_EFFECT_ALTERNATING) \ - || defined(RGBLIGHT_EFFECT_TWINKLE) -# define RGBLIGHT_USE_TIMER -#endif - -// clang-format on - -#define _RGBM_SINGLE_STATIC(sym) RGBLIGHT_MODE_##sym, -#define _RGBM_SINGLE_DYNAMIC(sym) RGBLIGHT_MODE_##sym, -#define _RGBM_MULTI_STATIC(sym) RGBLIGHT_MODE_##sym, -#define _RGBM_MULTI_DYNAMIC(sym) RGBLIGHT_MODE_##sym, -#define _RGBM_TMP_STATIC(sym, msym) RGBLIGHT_MODE_##sym, -#define _RGBM_TMP_DYNAMIC(sym, msym) RGBLIGHT_MODE_##sym, -enum RGBLIGHT_EFFECT_MODE { - RGBLIGHT_MODE_zero = 0, -#include "rgblight_modes.h" - RGBLIGHT_MODE_last -}; - -#define RGBLIGHT_MODES (RGBLIGHT_MODE_last - 1) - -// sample: #define RGBLIGHT_EFFECT_BREATHE_CENTER 1.85 - -#ifndef RGBLIGHT_EFFECT_BREATHE_MAX -# define RGBLIGHT_EFFECT_BREATHE_MAX 255 // 0-255 -#endif - -#ifndef RGBLIGHT_EFFECT_SNAKE_LENGTH -# define RGBLIGHT_EFFECT_SNAKE_LENGTH 4 -#endif - -#ifndef RGBLIGHT_EFFECT_SNAKE_INCREMENT -# define RGBLIGHT_EFFECT_SNAKE_INCREMENT 1 -#endif - -#ifndef RGBLIGHT_EFFECT_KNIGHT_LENGTH -# define RGBLIGHT_EFFECT_KNIGHT_LENGTH 3 -#endif - -#ifndef RGBLIGHT_EFFECT_KNIGHT_INCREMENT -# define RGBLIGHT_EFFECT_KNIGHT_INCREMENT 1 -#endif - -#ifndef RGBLIGHT_EFFECT_KNIGHT_OFFSET -# define RGBLIGHT_EFFECT_KNIGHT_OFFSET 0 -#endif - -#ifndef RGBLIGHT_EFFECT_KNIGHT_LED_NUM -# define RGBLIGHT_EFFECT_KNIGHT_LED_NUM (rgblight_ranges.effect_num_leds) -#endif - -#ifndef RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL -# define RGBLIGHT_EFFECT_CHRISTMAS_INTERVAL 40 -#endif - -#ifndef RGBLIGHT_EFFECT_CHRISTMAS_STEP -# define RGBLIGHT_EFFECT_CHRISTMAS_STEP 2 -#endif - -#ifndef RGBLIGHT_EFFECT_TWINKLE_LIFE -# define RGBLIGHT_EFFECT_TWINKLE_LIFE 200 -#endif - -#ifndef RGBLIGHT_EFFECT_TWINKLE_PROBABILITY -# define RGBLIGHT_EFFECT_TWINKLE_PROBABILITY 1 / 127 -#endif - -#ifndef RGBLIGHT_HUE_STEP -# define RGBLIGHT_HUE_STEP 8 -#endif -#ifndef RGBLIGHT_SAT_STEP -# define RGBLIGHT_SAT_STEP 17 -#endif -#ifndef RGBLIGHT_VAL_STEP -# define RGBLIGHT_VAL_STEP 17 -#endif -#ifndef RGBLIGHT_LIMIT_VAL -# define RGBLIGHT_LIMIT_VAL 255 -#endif - -#include <stdint.h> -#include <stdbool.h> -#include "progmem.h" -#include "eeconfig.h" -#include "ws2812.h" -#include "color.h" - -#ifdef RGBLIGHT_LAYERS -typedef struct { - uint8_t index; // The first LED to light - uint8_t count; // The number of LEDs to light - uint8_t hue; - uint8_t sat; - uint8_t val; -} rgblight_segment_t; - -// rgblight_set_layer_state doesn't take effect until the next time -// rgblight_task runs, so timers must be enabled for layers to work. -# define RGBLIGHT_USE_TIMER - -# define RGBLIGHT_END_SEGMENT_INDEX (255) -# define RGBLIGHT_END_SEGMENTS \ - { RGBLIGHT_END_SEGMENT_INDEX, 0, 0, 0 } -# ifndef RGBLIGHT_MAX_LAYERS -# define RGBLIGHT_MAX_LAYERS 8 -# endif -# if RGBLIGHT_MAX_LAYERS <= 0 -# error invalid RGBLIGHT_MAX_LAYERS value (must be >= 1) -# elif RGBLIGHT_MAX_LAYERS <= 8 -typedef uint8_t rgblight_layer_mask_t; -# elif RGBLIGHT_MAX_LAYERS <= 16 -typedef uint16_t rgblight_layer_mask_t; -# elif RGBLIGHT_MAX_LAYERS <= 32 -typedef uint32_t rgblight_layer_mask_t; -# else -# error invalid RGBLIGHT_MAX_LAYERS value (must be <= 32) -# endif -# define RGBLIGHT_LAYER_SEGMENTS(...) \ - { __VA_ARGS__, RGBLIGHT_END_SEGMENTS } -# define RGBLIGHT_LAYERS_LIST(...) \ - { __VA_ARGS__, NULL } - -// Get/set enabled rgblight layers -void rgblight_set_layer_state(uint8_t layer, bool enabled); -bool rgblight_get_layer_state(uint8_t layer); - -// Point this to an array of rgblight_segment_t arrays in keyboard_post_init_user to use rgblight layers -extern const rgblight_segment_t *const *rgblight_layers; - -# ifdef RGBLIGHT_LAYER_BLINK -# define RGBLIGHT_USE_TIMER -void rgblight_blink_layer(uint8_t layer, uint16_t duration_ms); -void rgblight_blink_layer_repeat(uint8_t layer, uint16_t duration_ms, uint8_t times); -/** - * \brief Stop blinking on one layer. - * - * Stop a layer that is blinking. If the layer is not blinking it will - * be unaffected. - * - * \param layer Layer number to stop blinking. - */ -void rgblight_unblink_layer(uint8_t layer); -/** - * \brief Stop blinking all layers except one. - * - * Stop all layers that are blinking except for one specific layer. - * Layers that are not blinking are unaffected. - * - * \param layer Layer number to keep blinking. - */ -void rgblight_unblink_all_but_layer(uint8_t layer); -# endif - -#endif - -extern LED_TYPE led[RGBLED_NUM]; - -extern const uint8_t RGBLED_BREATHING_INTERVALS[4] PROGMEM; -extern const uint8_t RGBLED_RAINBOW_MOOD_INTERVALS[3] PROGMEM; -extern const uint8_t RGBLED_RAINBOW_SWIRL_INTERVALS[3] PROGMEM; -extern const uint8_t RGBLED_SNAKE_INTERVALS[3] PROGMEM; -extern const uint8_t RGBLED_KNIGHT_INTERVALS[3] PROGMEM; -extern const uint16_t RGBLED_RGBTEST_INTERVALS[1] PROGMEM; -extern const uint8_t RGBLED_TWINKLE_INTERVALS[3] PROGMEM; -extern bool is_rgblight_initialized; - -typedef union { - uint64_t raw; - struct { - bool enable : 1; - uint8_t mode : 7; - uint8_t hue : 8; - uint8_t sat : 8; - uint8_t val : 8; - uint8_t speed : 8; - }; -} rgblight_config_t; - -_Static_assert(sizeof(rgblight_config_t) == sizeof(uint64_t), "RGB Light EECONFIG out of spec."); - -typedef struct _rgblight_status_t { - uint8_t base_mode; - bool timer_enabled; -#ifdef RGBLIGHT_SPLIT - uint8_t change_flags; -#endif -#ifdef RGBLIGHT_LAYERS - rgblight_layer_mask_t enabled_layer_mask; -#endif -} rgblight_status_t; - -/* - * Structure for RGB Light clipping ranges - */ -typedef struct _rgblight_ranges_t { - uint8_t clipping_start_pos; - uint8_t clipping_num_leds; - uint8_t effect_start_pos; - uint8_t effect_end_pos; - uint8_t effect_num_leds; -} rgblight_ranges_t; - -extern rgblight_ranges_t rgblight_ranges; - -/* === Utility Functions ===*/ -void sethsv(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); -void sethsv_raw(uint8_t hue, uint8_t sat, uint8_t val, LED_TYPE *led1); // without RGBLIGHT_LIMIT_VAL check -void setrgb(uint8_t r, uint8_t g, uint8_t b, LED_TYPE *led1); - -/* === Low level Functions === */ -void rgblight_set(void); -void rgblight_set_clipping_range(uint8_t start_pos, uint8_t num_leds); - -/* === Effects and Animations Functions === */ -/* effect range setting */ -void rgblight_set_effect_range(uint8_t start_pos, uint8_t num_leds); - -/* direct operation */ -void rgblight_setrgb_at(uint8_t r, uint8_t g, uint8_t b, uint8_t index); -void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index); -void rgblight_setrgb_range(uint8_t r, uint8_t g, uint8_t b, uint8_t start, uint8_t end); -void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, uint8_t end); -void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b); - -#ifndef RGBLIGHT_SPLIT -void rgblight_setrgb_master(uint8_t r, uint8_t g, uint8_t b); -void rgblight_setrgb_slave(uint8_t r, uint8_t g, uint8_t b); -void rgblight_sethsv_master(uint8_t hue, uint8_t sat, uint8_t val); -void rgblight_sethsv_slave(uint8_t hue, uint8_t sat, uint8_t val); -#endif - -/* effect mode change */ -void rgblight_mode(uint8_t mode); -void rgblight_mode_noeeprom(uint8_t mode); -void rgblight_increase(void); -void rgblight_decrease(void); -void rgblight_step(void); -void rgblight_step_noeeprom(void); -void rgblight_step_reverse(void); -void rgblight_step_reverse_noeeprom(void); - -/* effects mode disable/enable */ -void rgblight_toggle(void); -void rgblight_toggle_noeeprom(void); -void rgblight_enable(void); -void rgblight_enable_noeeprom(void); -void rgblight_disable(void); -void rgblight_disable_noeeprom(void); -void rgblight_enabled_noeeprom(bool state); - -/* hue, sat, val change */ -void rgblight_increase_hue(void); -void rgblight_increase_hue_noeeprom(void); -void rgblight_decrease_hue(void); -void rgblight_decrease_hue_noeeprom(void); -void rgblight_increase_sat(void); -void rgblight_increase_sat_noeeprom(void); -void rgblight_decrease_sat(void); -void rgblight_decrease_sat_noeeprom(void); -void rgblight_increase_val(void); -void rgblight_increase_val_noeeprom(void); -void rgblight_decrease_val(void); -void rgblight_decrease_val_noeeprom(void); -void rgblight_increase_speed(void); -void rgblight_increase_speed_noeeprom(void); -void rgblight_decrease_speed(void); -void rgblight_decrease_speed_noeeprom(void); -void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val); -void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val); - -/* effect speed */ -uint8_t rgblight_get_speed(void); -void rgblight_set_speed(uint8_t speed); -void rgblight_set_speed_noeeprom(uint8_t speed); - -/* reset */ -void rgblight_reload_from_eeprom(void); - -/* query */ -uint8_t rgblight_get_mode(void); -uint8_t rgblight_get_hue(void); -uint8_t rgblight_get_sat(void); -uint8_t rgblight_get_val(void); -bool rgblight_is_enabled(void); -HSV rgblight_get_hsv(void); - -/* === qmk_firmware (core)internal Functions === */ -void rgblight_init(void); -void rgblight_suspend(void); -void rgblight_wakeup(void); -uint64_t rgblight_read_qword(void); -void rgblight_update_qword(uint64_t qword); -uint64_t eeconfig_read_rgblight(void); -void eeconfig_update_rgblight(uint64_t val); -void eeconfig_update_rgblight_current(void); -void eeconfig_update_rgblight_default(void); -void eeconfig_debug_rgblight(void); - -void rgb_matrix_increase(void); -void rgb_matrix_decrease(void); - -void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool write_to_eeprom); -void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom); - -#define EZ_RGB(val) rgblight_show_solid_color((val >> 16) & 0xFF, (val >> 8) & 0xFF, val & 0xFF) -void rgblight_show_solid_color(uint8_t r, uint8_t g, uint8_t b); - -#ifdef RGBLIGHT_USE_TIMER -void rgblight_task(void); -void rgblight_timer_init(void); -void rgblight_timer_enable(void); -void rgblight_timer_disable(void); -void rgblight_timer_toggle(void); -#else -# define rgblight_task() -# define rgblight_timer_init() -# define rgblight_timer_enable() -# define rgblight_timer_disable() -# define rgblight_timer_toggle() -#endif - -#ifdef RGBLIGHT_SPLIT -# define RGBLIGHT_STATUS_CHANGE_MODE (1 << 0) -# define RGBLIGHT_STATUS_CHANGE_HSVS (1 << 1) -# define RGBLIGHT_STATUS_CHANGE_TIMER (1 << 2) -# define RGBLIGHT_STATUS_ANIMATION_TICK (1 << 3) -# define RGBLIGHT_STATUS_CHANGE_LAYERS (1 << 4) - -typedef struct _rgblight_syncinfo_t { - rgblight_config_t config; - rgblight_status_t status; -} rgblight_syncinfo_t; - -/* for split keyboard master side */ -uint8_t rgblight_get_change_flags(void); -void rgblight_clear_change_flags(void); -void rgblight_get_syncinfo(rgblight_syncinfo_t *syncinfo); -/* for split keyboard slave side */ -void rgblight_update_sync(rgblight_syncinfo_t *syncinfo, bool write_to_eeprom); -#endif - -#ifdef RGBLIGHT_USE_TIMER - -typedef struct _animation_status_t { - uint16_t last_timer; - uint8_t delta; /* mode - base_mode */ - bool restart; - union { - uint16_t pos16; - uint8_t pos; - int8_t current_hue; - uint16_t current_offset; - }; -} animation_status_t; - -extern animation_status_t animation_status; - -void rgblight_effect_breathing(animation_status_t *anim); -void rgblight_effect_rainbow_mood(animation_status_t *anim); -void rgblight_effect_rainbow_swirl(animation_status_t *anim); -void rgblight_effect_snake(animation_status_t *anim); -void rgblight_effect_knight(animation_status_t *anim); -void rgblight_effect_christmas(animation_status_t *anim); -void rgblight_effect_rgbtest(animation_status_t *anim); -void rgblight_effect_alternating(animation_status_t *anim); -void rgblight_effect_twinkle(animation_status_t *anim); - -#endif diff --git a/quantum/rgblight/rgblight_breathe_table.h b/quantum/rgblight/rgblight_breathe_table.h deleted file mode 100644 index 5c7660ab6a..0000000000 --- a/quantum/rgblight/rgblight_breathe_table.h +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright 2023 QMK -// SPDX-License-Identifier: GPL-2.0-or-later - -/******************************************************************************* - 88888888888 888 d8b .d888 d8b 888 d8b - 888 888 Y8P d88P" Y8P 888 Y8P - 888 888 888 888 - 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b - 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K - 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b. - 888 888 888 888 X88 888 888 888 Y8b. 888 X88 - 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P' - 888 888 - 888 888 - 888 888 - .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888 - d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888 - 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888 - Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888 - "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888 - 888 - Y8b d88P - "Y88P" -*******************************************************************************/ - -#pragma once -// clang-format off -#define RGBLIGHT_EFFECT_BREATHE_TABLE - -// Breathing center: 1.85 -// Breathing max: 255 - -const uint8_t PROGMEM rgblight_effect_breathe_table[] = { -#if RGBLIGHT_BREATHE_TABLE_SIZE == 256 - 0x22, 0x23, 0x25, 0x26, 0x28, 0x29, 0x2A, 0x2C, - 0x2D, 0x2F, 0x30, 0x32, 0x33, 0x35, 0x36, 0x38, - 0x3A, 0x3B, 0x3D, 0x3E, 0x40, 0x42, 0x43, 0x45, - 0x47, 0x49, 0x4A, 0x4C, 0x4E, 0x50, 0x51, 0x53, - 0x55, 0x57, 0x59, 0x5A, 0x5C, 0x5E, 0x60, 0x62, - 0x64, 0x66, 0x68, 0x69, 0x6B, 0x6D, 0x6F, 0x71, - 0x73, 0x75, 0x77, 0x79, 0x7B, 0x7D, 0x7F, 0x81, - 0x83, 0x85, 0x87, 0x89, 0x8A, 0x8C, 0x8E, 0x90, - 0x92, 0x94, 0x96, 0x98, 0x9A, 0x9C, 0x9E, 0x9F, - 0xA1, 0xA3, 0xA5, 0xA7, 0xA8, 0xAA, 0xAC, 0xAE, - 0xAF, 0xB1, 0xB3, 0xB4, 0xB6, 0xB8, 0xB9, 0xBB, - 0xBC, 0xBE, 0xBF, 0xC1, 0xC2, 0xC3, 0xC5, 0xC6, - 0xC7, 0xC9, 0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xD0, - 0xD1, 0xD2, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, - 0xD7, 0xD8, 0xD9, 0xD9, 0xDA, 0xDA, 0xDB, 0xDB, - 0xDB, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDD, 0xDD, - 0xDD, 0xDD, 0xDC, 0xDC, 0xDC, 0xDC, 0xDC, 0xDB, - 0xDB, 0xDB, 0xDA, 0xDA, 0xD9, 0xD9, 0xD8, 0xD7, - 0xD7, 0xD6, 0xD5, 0xD4, 0xD3, 0xD2, 0xD2, 0xD1, - 0xD0, 0xCE, 0xCD, 0xCC, 0xCB, 0xCA, 0xC9, 0xC7, - 0xC6, 0xC5, 0xC3, 0xC2, 0xC1, 0xBF, 0xBE, 0xBC, - 0xBB, 0xB9, 0xB8, 0xB6, 0xB4, 0xB3, 0xB1, 0xAF, - 0xAE, 0xAC, 0xAA, 0xA8, 0xA7, 0xA5, 0xA3, 0xA1, - 0x9F, 0x9E, 0x9C, 0x9A, 0x98, 0x96, 0x94, 0x92, - 0x90, 0x8E, 0x8C, 0x8A, 0x89, 0x87, 0x85, 0x83, - 0x81, 0x7F, 0x7D, 0x7B, 0x79, 0x77, 0x75, 0x73, - 0x71, 0x6F, 0x6D, 0x6B, 0x69, 0x68, 0x66, 0x64, - 0x62, 0x60, 0x5E, 0x5C, 0x5A, 0x59, 0x57, 0x55, - 0x53, 0x51, 0x50, 0x4E, 0x4C, 0x4A, 0x49, 0x47, - 0x45, 0x43, 0x42, 0x40, 0x3E, 0x3D, 0x3B, 0x3A, - 0x38, 0x36, 0x35, 0x33, 0x32, 0x30, 0x2F, 0x2D, - 0x2C, 0x2A, 0x29, 0x28, 0x26, 0x25, 0x23, 0x22 -#endif - -#if RGBLIGHT_BREATHE_TABLE_SIZE == 128 - 0x22, 0x25, 0x28, 0x2A, - 0x2D, 0x30, 0x33, 0x36, - 0x3A, 0x3D, 0x40, 0x43, - 0x47, 0x4A, 0x4E, 0x51, - 0x55, 0x59, 0x5C, 0x60, - 0x64, 0x68, 0x6B, 0x6F, - 0x73, 0x77, 0x7B, 0x7F, - 0x83, 0x87, 0x8A, 0x8E, - 0x92, 0x96, 0x9A, 0x9E, - 0xA1, 0xA5, 0xA8, 0xAC, - 0xAF, 0xB3, 0xB6, 0xB9, - 0xBC, 0xBF, 0xC2, 0xC5, - 0xC7, 0xCA, 0xCC, 0xCE, - 0xD1, 0xD2, 0xD4, 0xD6, - 0xD7, 0xD9, 0xDA, 0xDB, - 0xDB, 0xDC, 0xDC, 0xDD, - 0xDD, 0xDC, 0xDC, 0xDC, - 0xDB, 0xDA, 0xD9, 0xD8, - 0xD7, 0xD5, 0xD3, 0xD2, - 0xD0, 0xCD, 0xCB, 0xC9, - 0xC6, 0xC3, 0xC1, 0xBE, - 0xBB, 0xB8, 0xB4, 0xB1, - 0xAE, 0xAA, 0xA7, 0xA3, - 0x9F, 0x9C, 0x98, 0x94, - 0x90, 0x8C, 0x89, 0x85, - 0x81, 0x7D, 0x79, 0x75, - 0x71, 0x6D, 0x69, 0x66, - 0x62, 0x5E, 0x5A, 0x57, - 0x53, 0x50, 0x4C, 0x49, - 0x45, 0x42, 0x3E, 0x3B, - 0x38, 0x35, 0x32, 0x2F, - 0x2C, 0x29, 0x26, 0x23 -#endif - -#if RGBLIGHT_BREATHE_TABLE_SIZE == 64 - 0x22, 0x28, - 0x2D, 0x33, - 0x3A, 0x40, - 0x47, 0x4E, - 0x55, 0x5C, - 0x64, 0x6B, - 0x73, 0x7B, - 0x83, 0x8A, - 0x92, 0x9A, - 0xA1, 0xA8, - 0xAF, 0xB6, - 0xBC, 0xC2, - 0xC7, 0xCC, - 0xD1, 0xD4, - 0xD7, 0xDA, - 0xDB, 0xDC, - 0xDD, 0xDC, - 0xDB, 0xD9, - 0xD7, 0xD3, - 0xD0, 0xCB, - 0xC6, 0xC1, - 0xBB, 0xB4, - 0xAE, 0xA7, - 0x9F, 0x98, - 0x90, 0x89, - 0x81, 0x79, - 0x71, 0x69, - 0x62, 0x5A, - 0x53, 0x4C, - 0x45, 0x3E, - 0x38, 0x32, - 0x2C, 0x26 -#endif -}; - -static const int table_scale = 256 / sizeof(rgblight_effect_breathe_table); - diff --git a/quantum/rgblight/rgblight_modes.h b/quantum/rgblight/rgblight_modes.h deleted file mode 100644 index 7abdb87bc6..0000000000 --- a/quantum/rgblight/rgblight_modes.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifdef _RGBM_SINGLE_STATIC -_RGBM_SINGLE_STATIC(STATIC_LIGHT) -# ifdef RGBLIGHT_EFFECT_BREATHING -_RGBM_MULTI_DYNAMIC(BREATHING) -_RGBM_TMP_DYNAMIC(breathing_3, BREATHING) -_RGBM_TMP_DYNAMIC(breathing_4, BREATHING) -_RGBM_TMP_DYNAMIC(BREATHING_end, BREATHING) -# endif -# ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD -_RGBM_MULTI_DYNAMIC(RAINBOW_MOOD) -_RGBM_TMP_DYNAMIC(rainbow_mood_7, RAINBOW_MOOD) -_RGBM_TMP_DYNAMIC(RAINBOW_MOOD_end, RAINBOW_MOOD) -# endif -# ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL -_RGBM_MULTI_DYNAMIC(RAINBOW_SWIRL) -_RGBM_TMP_DYNAMIC(rainbow_swirl_10, RAINBOW_SWIRL) -_RGBM_TMP_DYNAMIC(rainbow_swirl_11, RAINBOW_SWIRL) -_RGBM_TMP_DYNAMIC(rainbow_swirl_12, RAINBOW_SWIRL) -_RGBM_TMP_DYNAMIC(rainbow_swirl_13, RAINBOW_SWIRL) -_RGBM_TMP_DYNAMIC(RAINBOW_SWIRL_end, RAINBOW_SWIRL) -# endif -# ifdef RGBLIGHT_EFFECT_SNAKE -_RGBM_MULTI_DYNAMIC(SNAKE) -_RGBM_TMP_DYNAMIC(snake_16, SNAKE) -_RGBM_TMP_DYNAMIC(snake_17, SNAKE) -_RGBM_TMP_DYNAMIC(snake_18, SNAKE) -_RGBM_TMP_DYNAMIC(snake_19, SNAKE) -_RGBM_TMP_DYNAMIC(SNAKE_end, SNAKE) -# endif -# ifdef RGBLIGHT_EFFECT_KNIGHT -_RGBM_MULTI_DYNAMIC(KNIGHT) -_RGBM_TMP_DYNAMIC(knight_22, KNIGHT) -_RGBM_TMP_DYNAMIC(KNIGHT_end, KNIGHT) -# endif -# ifdef RGBLIGHT_EFFECT_CHRISTMAS -_RGBM_SINGLE_DYNAMIC(CHRISTMAS) -# endif -# ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT -_RGBM_MULTI_STATIC(STATIC_GRADIENT) -_RGBM_TMP_STATIC(static_gradient_26, STATIC_GRADIENT) -_RGBM_TMP_STATIC(static_gradient_27, STATIC_GRADIENT) -_RGBM_TMP_STATIC(static_gradient_28, STATIC_GRADIENT) -_RGBM_TMP_STATIC(static_gradient_29, STATIC_GRADIENT) -_RGBM_TMP_STATIC(static_gradient_30, STATIC_GRADIENT) -_RGBM_TMP_STATIC(static_gradient_31, STATIC_GRADIENT) -_RGBM_TMP_STATIC(static_gradient_32, STATIC_GRADIENT) -_RGBM_TMP_STATIC(static_gradient_33, STATIC_GRADIENT) -_RGBM_TMP_STATIC(STATIC_GRADIENT_end, STATIC_GRADIENT) -# endif -# ifdef RGBLIGHT_EFFECT_RGB_TEST -_RGBM_SINGLE_DYNAMIC(RGB_TEST) -# endif -# ifdef RGBLIGHT_EFFECT_ALTERNATING -_RGBM_SINGLE_DYNAMIC(ALTERNATING) -# endif -# ifdef RGBLIGHT_EFFECT_TWINKLE -_RGBM_MULTI_DYNAMIC(TWINKLE) -_RGBM_TMP_DYNAMIC(twinkle_38, TWINKLE) -_RGBM_TMP_DYNAMIC(twinkle_39, TWINKLE) -_RGBM_TMP_DYNAMIC(twinkle_40, TWINKLE) -_RGBM_TMP_DYNAMIC(twinkle_41, TWINKLE) -_RGBM_TMP_DYNAMIC(TWINKLE_end, TWINKLE) -# endif -//// Add a new mode here. -// #ifdef RGBLIGHT_EFFECT_<name> -// _RGBM_<SINGLE|MULTI>_<STATIC|DYNAMIC>( <name> ) -// #endif -#endif - -#undef _RGBM_SINGLE_STATIC -#undef _RGBM_SINGLE_DYNAMIC -#undef _RGBM_MULTI_STATIC -#undef _RGBM_MULTI_DYNAMIC -#undef _RGBM_TMP_STATIC -#undef _RGBM_TMP_DYNAMIC diff --git a/quantum/rgblight/rgblight_post_config.h b/quantum/rgblight/rgblight_post_config.h deleted file mode 100644 index 3c14cb6109..0000000000 --- a/quantum/rgblight/rgblight_post_config.h +++ /dev/null @@ -1,5 +0,0 @@ -#if defined(RGBLED_SPLIT) && !defined(RGBLIGHT_SPLIT) -// When RGBLED_SPLIT is defined, -// it is considered that RGBLIGHT_SPLIT is defined implicitly. -# define RGBLIGHT_SPLIT -#endif |