- if (initialize) {
- rgb_matrix_set_color_all(0, 0, 0);
- memset(map, 0, sizeof map);
- drop = 0;
- }
- 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
- map[col][row] = max_intensity;
- }
- else if (map[col][row] > 0 && map[col][row] < max_intensity) {
- // neither fully bright nor dark, decay it
- map[col][row]--;
- }
- // set the pixel colour
- uint8_t led, led_count;
- map_row_column_to_led(row, col, &led, &led_count);
-
- if (map[col][row] > pure_green_intensity) {
- const uint8_t boost = (uint8_t) ((uint16_t) max_brightness_boost
- * (map[col][row] - pure_green_intensity) / (max_intensity - pure_green_intensity));
- rgb_matrix_set_color(led, boost, max_intensity, boost);
- }
- else {
- const uint8_t green = (uint8_t) ((uint16_t) max_intensity * map[col][row] / pure_green_intensity);
- rgb_matrix_set_color(led, 0, green, 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 && map[col][row] == max_intensity) {
- map[col][row]--;
- }
- // check if the pixel above is bright
- if (map[col][row - 1] == max_intensity) {
- // allow old bright pixel to decay
- map[col][row - 1]--;
- // make this pixel bright
- map[col][row] = max_intensity;
- }
- }
- }
- }
-}
-
-void rgb_matrix_multisplash(void) {
- // if (g_any_key_hit < 0xFF) {
- HSV hsv = { .h = rgb_matrix_config.hue, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val };
- RGB rgb;
- rgb_led led;
- for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
- led = g_rgb_leds[i];
- uint16_t c = 0, d = 0;
- rgb_led last_led;
- // if (g_last_led_count) {
- for (uint8_t last_i = 0; last_i < g_last_led_count; last_i++) {
- last_led = g_rgb_leds[g_last_led_hit[last_i]];
- uint16_t dist = (uint16_t)sqrt(pow(led.point.x - last_led.point.x, 2) + pow(led.point.y - last_led.point.y, 2));
- uint16_t effect = (g_key_hit[g_last_led_hit[last_i]] << 2) - dist;
- c += MIN(MAX(effect, 0), 255);
- d += 255 - MIN(MAX(effect, 0), 255);
- }
- // } else {
- // d = 255;
- // }
- hsv.h = (rgb_matrix_config.hue + c) % 256;
- hsv.v = MAX(MIN(d, 255), 0);
- rgb = hsv_to_rgb( hsv );
- rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b );
- }
- // } else {
- // rgb_matrix_set_color_all( 0, 0, 0 );
- // }
-}
-
-
-void rgb_matrix_splash(void) {
- g_last_led_count = MIN(g_last_led_count, 1);
- rgb_matrix_multisplash();
-}
-
-
-void rgb_matrix_solid_multisplash(void) {
- // if (g_any_key_hit < 0xFF) {
- HSV hsv = { .h = rgb_matrix_config.hue, .s = rgb_matrix_config.sat, .v = rgb_matrix_config.val };
- RGB rgb;
- rgb_led led;
- for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
- led = g_rgb_leds[i];
- uint16_t d = 0;
- rgb_led last_led;
- // if (g_last_led_count) {
- for (uint8_t last_i = 0; last_i < g_last_led_count; last_i++) {
- last_led = g_rgb_leds[g_last_led_hit[last_i]];
- uint16_t dist = (uint16_t)sqrt(pow(led.point.x - last_led.point.x, 2) + pow(led.point.y - last_led.point.y, 2));
- uint16_t effect = (g_key_hit[g_last_led_hit[last_i]] << 2) - dist;
- d += 255 - MIN(MAX(effect, 0), 255);
- }
- // } else {
- // d = 255;
- // }
- hsv.v = MAX(MIN(d, 255), 0);
- rgb = hsv_to_rgb( hsv );
- rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b );
- }
- // } else {
- // rgb_matrix_set_color_all( 0, 0, 0 );
- // }
-}
-
-
-void rgb_matrix_solid_splash(void) {
- g_last_led_count = MIN(g_last_led_count, 1);
- rgb_matrix_solid_multisplash();
-}
-
-
-// Needs eeprom access that we don't have setup currently
-
-void rgb_matrix_custom(void) {
-// HSV hsv;
-// RGB rgb;
-// for ( int i=0; i<DRIVER_LED_TOTAL; i++ )
-// {
-// backlight_get_key_color(i, &hsv);
-// // Override brightness with global brightness control
-// hsv.v = rgb_matrix_config.val;
-// rgb = hsv_to_rgb( hsv );
-// rgb_matrix_set_color( i, rgb.r, rgb.g, rgb.b );
-// }