@@ -50,89 +50,96 @@ static void vfx_task_handle(void *pvParameter)
5050 while (1 ) {
5151#if defined(CONFIG_SCREEN_PANEL_OUTPUT_FFT )
5252 // LCD FFT Output
53- uint8_t color_cnt = 0 ;
54- uint16_t color_tmp = 0 ;
55- uint16_t color_idx = 0 ;
56- uint16_t color_ctr = vfx_ctr ;
57- float fft_amp [64 ] = {0 };
58- const uint16_t fft_n = 128 ;
59- GDisplay * g = gdispGetDisplay (0 );
60- coord_t disp_width = gdispGGetWidth (g );
61- coord_t disp_height = gdispGGetHeight (g );
62-
63- fft_config_t * fft_plan = fft_init (fft_n , FFT_REAL , FFT_FORWARD , NULL , NULL );
64- while (1 ) {
65- if (xEventGroupGetBits (user_event_group ) & VFX_RELOAD_BIT ) {
66- xEventGroupClearBits (user_event_group , VFX_RELOAD_BIT );
67- vfx_clear_cube ();
68- break ;
69- }
70-
71- for (uint16_t k = 0 ; k < fft_n ; k ++ ) {
72- fft_plan -> input [k ] = (float )vfx_fifo_read ();
73- }
53+ switch (vfx_mode ) {
54+ case 0x00 :
55+ gfxSleepMilliseconds (1000 );
56+ break ;
57+ default : {
58+ uint8_t color_cnt = 0 ;
59+ uint16_t color_tmp = 0 ;
60+ uint16_t color_idx = 0 ;
61+ uint16_t color_ctr = vfx_ctr ;
62+ float fft_amp [64 ] = {0 };
63+ const uint16_t fft_n = 128 ;
64+ GDisplay * g = gdispGetDisplay (0 );
65+ coord_t disp_width = gdispGGetWidth (g );
66+ coord_t disp_height = gdispGGetHeight (g );
7467
75- fft_execute (fft_plan );
68+ fft_config_t * fft_plan = fft_init (fft_n , FFT_REAL , FFT_FORWARD , NULL , NULL );
69+ while (1 ) {
70+ if (xEventGroupGetBits (user_event_group ) & VFX_RELOAD_BIT ) {
71+ xEventGroupClearBits (user_event_group , VFX_RELOAD_BIT );
72+ vfx_clear_cube ();
73+ break ;
74+ }
7675
77- fft_amp [0 ] = sqrt (pow (fft_plan -> output [0 ], 2 ) + pow (fft_plan -> output [1 ], 2 )) / fft_n ;
78- for (uint16_t k = 1 ; k < fft_n /2 ; k ++ ) {
79- fft_amp [k ] = sqrt (pow (fft_plan -> output [2 * k ], 2 ) + pow (fft_plan -> output [2 * k + 1 ], 2 )) / fft_n * 2 ;
80- }
76+ for (uint16_t k = 0 ; k < fft_n ; k ++ ) {
77+ fft_plan -> input [k ] = (float )vfx_fifo_read ();
78+ }
8179
82- color_tmp = color_idx ;
83- for (uint16_t i = 0 ; i < disp_width ; i ++ ) {
84- uint16_t temp = fft_amp [i ] / (65536 / disp_height ) * fft_scale ;
85- uint32_t pixel_color = vfx_read_color_from_table (color_idx , color_ctr );
80+ fft_execute (fft_plan );
8681
87- if (temp > disp_height ) {
88- temp = disp_height ;
89- } else if (temp < 1 ) {
90- temp = 1 ;
82+ fft_amp [0 ] = sqrt (pow (fft_plan -> output [0 ], 2 ) + pow (fft_plan -> output [1 ], 2 )) / fft_n ;
83+ for (uint16_t k = 1 ; k < fft_n /2 ; k ++ ) {
84+ fft_amp [k ] = sqrt (pow (fft_plan -> output [2 * k ], 2 ) + pow (fft_plan -> output [2 * k + 1 ], 2 )) / fft_n * 2 ;
9185 }
9286
87+ color_tmp = color_idx ;
88+ for (uint16_t i = 0 ; i < disp_width ; i ++ ) {
89+ uint16_t temp = fft_amp [i ] / (65536 / disp_height ) * fft_scale ;
90+ uint32_t pixel_color = vfx_read_color_from_table (color_idx , color_ctr );
91+
92+ if (temp > disp_height ) {
93+ temp = disp_height ;
94+ } else if (temp < 1 ) {
95+ temp = 1 ;
96+ }
97+
9398#if defined(CONFIG_VFX_OUTPUT_ST7735 )
94- uint16_t clear_x = i * 3 ;
95- uint16_t clear_cx = 3 ;
96- uint16_t clear_y = 0 ;
97- uint16_t clear_cy = disp_height - temp ;
98-
99- uint16_t fill_x = i * 3 ;
100- uint16_t fill_cx = 3 ;
101- uint16_t fill_y = disp_height - temp ;
102- uint16_t fill_cy = temp ;
99+ uint16_t clear_x = i * 3 ;
100+ uint16_t clear_cx = 3 ;
101+ uint16_t clear_y = 0 ;
102+ uint16_t clear_cy = disp_height - temp ;
103+
104+ uint16_t fill_x = i * 3 ;
105+ uint16_t fill_cx = 3 ;
106+ uint16_t fill_y = disp_height - temp ;
107+ uint16_t fill_cy = temp ;
103108#else
104- uint16_t clear_x = i * 4 ;
105- uint16_t clear_cx = 4 ;
106- uint16_t clear_y = 0 ;
107- uint16_t clear_cy = disp_height - temp ;
108-
109- uint16_t fill_x = i * 4 ;
110- uint16_t fill_cx = 4 ;
111- uint16_t fill_y = disp_height - temp ;
112- uint16_t fill_cy = temp ;
109+ uint16_t clear_x = i * 4 ;
110+ uint16_t clear_cx = 4 ;
111+ uint16_t clear_y = 0 ;
112+ uint16_t clear_cy = disp_height - temp ;
113+
114+ uint16_t fill_x = i * 4 ;
115+ uint16_t fill_cx = 4 ;
116+ uint16_t fill_y = disp_height - temp ;
117+ uint16_t fill_cy = temp ;
113118#endif
114119
115- gdispGFillArea (g , clear_x , clear_y , clear_cx , clear_cy , 0x000000 );
116- gdispGFillArea (g , fill_x , fill_y , fill_cx , fill_cy , pixel_color );
120+ gdispGFillArea (g , clear_x , clear_y , clear_cx , clear_cy , 0x000000 );
121+ gdispGFillArea (g , fill_x , fill_y , fill_cx , fill_cy , pixel_color );
117122
118- if (++ color_idx > 511 ) {
119- color_idx = 0 ;
123+ if (++ color_idx > 511 ) {
124+ color_idx = 0 ;
125+ }
120126 }
121- }
122127
123- if (++ color_cnt % (16 / FFT_PERIOD ) == 0 ) {
124- color_idx = ++ color_tmp ;
125- } else {
126- color_idx = color_tmp ;
127- }
128+ if (++ color_cnt % (16 / FFT_PERIOD ) == 0 ) {
129+ color_idx = ++ color_tmp ;
130+ } else {
131+ color_idx = color_tmp ;
132+ }
128133
129- if (color_idx > 511 ) {
130- color_idx = 0 ;
131- }
134+ if (color_idx > 511 ) {
135+ color_idx = 0 ;
136+ }
132137
133- gfxSleepMilliseconds (FFT_PERIOD );
138+ gfxSleepMilliseconds (FFT_PERIOD );
139+ }
140+ fft_destroy (fft_plan );
141+ break ;
134142 }
135- fft_destroy (fft_plan );
136143#else
137144 // Light Cube Output
138145 switch (vfx_mode ) {
@@ -874,7 +881,6 @@ static void vfx_task_handle(void *pvParameter)
874881 break ;
875882 }
876883 default :
877- vfx_clear_cube ();
878884 gfxSleepMilliseconds (1000 );
879885exit :
880886 break ;
0 commit comments