From 1038ade342606f155b2ed0bee6542a24580fe6b9 Mon Sep 17 00:00:00 2001 From: 3araht <69518343+3araht@users.noreply.github.com> Date: Thu, 11 Aug 2022 10:38:32 +0900 Subject: [Keyboard] add chromatonemini keyboard (#13516) --- keyboards/chromatonemini/rgb_matrix_kb.inc | 58 ++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 keyboards/chromatonemini/rgb_matrix_kb.inc (limited to 'keyboards/chromatonemini/rgb_matrix_kb.inc') diff --git a/keyboards/chromatonemini/rgb_matrix_kb.inc b/keyboards/chromatonemini/rgb_matrix_kb.inc new file mode 100644 index 0000000000..4fe474e12c --- /dev/null +++ b/keyboards/chromatonemini/rgb_matrix_kb.inc @@ -0,0 +1,58 @@ +#ifdef RGB_MATRIX_KEYREACTIVE_ENABLED +RGB_MATRIX_EFFECT(my_solid_reactive_multiwide_col) +RGB_MATRIX_EFFECT(my_solid_reactive_col) +RGB_MATRIX_EFFECT(my_party_rocks) + +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS + +static HSV my_solid_reactive_multiwide_col_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; + dx = dx * 16 > 255 ? 255 : dx * 16; + effect += dx; + if (effect > 255) effect = 255; + hsv.v = qadd8(hsv.v, 255 - effect); + // hsv.h += qsub8(130, effect); + return hsv; +} + +bool my_solid_reactive_multiwide_col(effect_params_t* params) { + return effect_runner_reactive_splash(0, params, &my_solid_reactive_multiwide_col_math); +} + + +bool my_solid_reactive_col(effect_params_t* params) { + RGB_MATRIX_USE_LIMITS(led_min, led_max); + + uint16_t max_tick = 65535 / rgb_matrix_config.speed; + for (uint8_t i = led_min; i < led_max; i++) { + RGB_MATRIX_TEST_LED_FLAGS(); + HSV hsv = rgb_matrix_config.hsv; + 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.x[j] == g_led_config.point[i].x && g_last_hit_tracker.tick[j] < tick) { + tick = g_last_hit_tracker.tick[j]; + break; + } + } + + uint16_t offset = scale16by8(tick, rgb_matrix_config.speed); + hsv.h += qsub8(130, offset); + RGB rgb = rgb_matrix_hsv_to_rgb(hsv); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } + return led_max < DRIVER_LED_TOTAL; +} + +bool my_party_rocks(effect_params_t* params) { + RGB_MATRIX_USE_LIMITS(led_min, led_max); + HSV hsv = {rand() & 0xFF, rand() & 0xFF, rgb_matrix_config.hsv.v}; + RGB rgb = rgb_matrix_hsv_to_rgb(hsv); + // rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + rgb_matrix_set_color_all(rgb.r, rgb.g, rgb.b); + return led_max < DRIVER_LED_TOTAL; +} + +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // RGB_MATRIX_KEYREACTIVE_ENABLED -- cgit v1.2.1