#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS #ifndef DISABLE_RGB_MATRIX_FFT_ANIM RGB_MATRIX_EFFECT(FFT_ANIM) #ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS static int8_t fft_array_to_col[4][14] = { // Each number represets a bin and a height: // x % bin_height = height, // x / bin_height = bin // // Indices are [col][row]. // Right side { 29, 34, 39, 44, 49, 28, 33, 38, 43, 48, 27, 32, 37, 42},{47, 26, 31, 36, 41, 46, 30, 35, 40, 45, // Left side, mirrored 24, 19, 14, 9},{ 4, 23, 18, 13, 8, 3, 22, 17, 12, 7, 2, 21, 16, 11},{ 6, 1, 20, 15, 10, 5, 0, // No keys here, fill array length 0, 0, 0, 0, 0, 0, 0} }; static int8_t fft_col_to_array[10][5] = { { 47, 43, 38, 33, 28 }, { 46, 42, 37, 32, 27 }, { 45, 41, 36, 31, 26 }, { 44, 40, 35, 30, 25 }, { -1, 39, 34, 29, 24 }, { -1, 15, 10, 5, 0 }, { 20, 16, 11, 6, 1 }, { 21, 17, 12, 7, 2 }, { 22, 18, 13, 8, 3 }, { 23, 19, 14, 9, 4 } }; // TODO: // Dynamic color settings bool FFT_ANIM(effect_params_t* params) { uint8_t led_min = RGB_MATRIX_LED_PROCESS_LIMIT * params->iter; uint8_t led_max = led_min + RGB_MATRIX_LED_PROCESS_LIMIT; if (led_max > sizeof(g_rgb_frame_buffer)) led_max = sizeof(g_rgb_frame_buffer); if (params->init) { rgb_matrix_set_color_all(0, 0, 0); memset(g_rgb_frame_buffer, 0, sizeof g_rgb_frame_buffer); } // Render heatmap & decrease for (int i = led_min; i < led_max; i++) { uint8_t row = i % MATRIX_ROWS; uint8_t col = i / MATRIX_ROWS; uint8_t val = g_rgb_frame_buffer[row][col]; bool is_topmost = false; int8_t height = fft_array_to_col[col][row] % 5; int8_t bin = fft_array_to_col[col][row] / 5; if (height == 5 - 1) { is_topmost = true; } else { // Row and col of key above this one if ( g_rgb_frame_buffer[ fft_col_to_array[bin][height + 1] % MATRIX_ROWS ][ fft_col_to_array[bin][height + 1] / MATRIX_ROWS ] == 0 ) { is_topmost = true; } } if (is_topmost) { rgb_matrix_set_color(i, val, 0x00, val); } else { rgb_matrix_set_color(i, 0x00, 0x00, val); } } return led_max < sizeof(g_rgb_frame_buffer); } #endif #endif #endif