Skip to content

Commit 7676ffc

Browse files
committed
vfx: fix fft amp error
1 parent 6619025 commit 7676ffc

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

main/src/user/vfx.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,15 @@ static void vfx_task_handle(void *pvParameter)
222222

223223
fft_execute(fft_plan);
224224

225-
for (uint16_t k=0; k<64; k++) {
226-
fft_amp[k] = sqrt(pow(fft_plan->output[2*k], 2) + pow(fft_plan->output[2*k+1], 2));
225+
fft_amp[0] = sqrt(pow(fft_plan->output[0], 2) + pow(fft_plan->output[1], 2)) / 128;
226+
for (uint16_t k=1; k<64; k++) {
227+
fft_amp[k] = sqrt(pow(fft_plan->output[2*k], 2) + pow(fft_plan->output[2*k+1], 2)) / 128 * 2;
227228
}
228229

229230
color_tmp = color_idx;
230231
#if defined(CONFIG_VFX_OUTPUT_ST7735)
231232
for (uint16_t i=0; i<52; i++) {
232-
uint16_t temp = fft_amp[i] / 819.2;
233+
uint16_t temp = fft_amp[i] / 32;
233234
uint32_t pixel_color = read_color_from_table(color_idx, color_ctr);
234235

235236
if (temp > 80) {
@@ -249,7 +250,7 @@ static void vfx_task_handle(void *pvParameter)
249250
uint16_t fill_cy = temp;
250251
#else
251252
for (uint16_t i=0; i<60; i++) {
252-
uint16_t temp = fft_amp[i] / 485.5;
253+
uint16_t temp = fft_amp[i] / 16;
253254
uint32_t pixel_color = read_color_from_table(color_idx, color_ctr);
254255

255256
if (temp > 135) {
@@ -779,13 +780,14 @@ static void vfx_task_handle(void *pvParameter)
779780

780781
fft_execute(fft_plan);
781782

782-
for (uint16_t k=0; k<64; k++) {
783-
fft_amp[k] = sqrt(pow(fft_plan->output[2*k], 2) + pow(fft_plan->output[2*k+1], 2));
783+
fft_amp[0] = sqrt(pow(fft_plan->output[0], 2) + pow(fft_plan->output[1], 2)) / 128;
784+
for (uint16_t k=1; k<64; k++) {
785+
fft_amp[k] = sqrt(pow(fft_plan->output[2*k], 2) + pow(fft_plan->output[2*k+1], 2)) / 128 * 2;
784786
}
785787

786788
color_idx = 63;
787789
for (uint16_t i=0; i<64; i++) {
788-
uint16_t temp = fft_amp[i] / 8192;
790+
uint16_t temp = fft_amp[i] / 320;
789791
if (temp != 0) {
790792
fill_cube(x, 7-y, 0, x, 7-y, 7-temp, 0, 511);
791793
fill_cube(x, 7-y, 7-temp, x, 7-y, 7, color_idx, color_ctr);
@@ -835,13 +837,14 @@ static void vfx_task_handle(void *pvParameter)
835837

836838
fft_execute(fft_plan);
837839

838-
for (uint16_t k=0; k<64; k++) {
839-
fft_amp[k] = sqrt(pow(fft_plan->output[2*k], 2) + pow(fft_plan->output[2*k+1], 2));
840+
fft_amp[0] = sqrt(pow(fft_plan->output[0], 2) + pow(fft_plan->output[1], 2)) / 128;
841+
for (uint16_t k=1; k<64; k++) {
842+
fft_amp[k] = sqrt(pow(fft_plan->output[2*k], 2) + pow(fft_plan->output[2*k+1], 2)) / 128 * 2;
840843
}
841844

842845
color_idx = color_tmp;
843846
for (uint16_t i=0; i<64; i++) {
844-
uint16_t temp = fft_amp[i] / 8192;
847+
uint16_t temp = fft_amp[i] / 320;
845848
if (temp != 0) {
846849
fill_cube(x, 7-y, 0, x, 7-y, 7-temp, 0, 511);
847850
fill_cube(x, 7-y, 7-temp, x, 7-y, 7, color_idx, color_ctr);
@@ -916,15 +919,16 @@ static void vfx_task_handle(void *pvParameter)
916919

917920
fft_execute(fft_plan);
918921

919-
for (uint16_t k=0; k<64; k++) {
920-
fft_amp[k] = sqrt(pow(fft_plan->output[2*k], 2) + pow(fft_plan->output[2*k+1], 2));
922+
fft_amp[0] = sqrt(pow(fft_plan->output[0], 2) + pow(fft_plan->output[1], 2)) / 128;
923+
for (uint16_t k=1; k<64; k++) {
924+
fft_amp[k] = sqrt(pow(fft_plan->output[2*k], 2) + pow(fft_plan->output[2*k+1], 2)) / 128 * 2;
921925
}
922926

923927
for (uint16_t i=0; i<64; i++) {
924928
x = led_idx_table[0][i];
925929
y = led_idx_table[1][i];
926930

927-
uint16_t temp = fft_amp[i] / 8192;
931+
uint16_t temp = fft_amp[i] / 320;
928932
if (temp != 0) {
929933
fill_cube(x, 7-y, 0, x, 7-y, 7-temp, 0, 511);
930934
fill_cube(x, 7-y, 7-temp, x, 7-y, 7, color_idx[i], color_ctr[i]);

0 commit comments

Comments
 (0)