57 lines
1.3 KiB
C
57 lines
1.3 KiB
C
#ifdef RGB_MATRIX_FRAMEBUFFER_EFFECTS
|
|
#ifndef DISABLE_RGB_MATRIX_FFT_ANIM
|
|
RGB_MATRIX_EFFECT(FFT_ANIM)
|
|
|
|
#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS
|
|
|
|
#include "extra_mappings.h"
|
|
|
|
// 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);
|
|
}
|
|
|
|
|
|
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 |