@@ -57,22 +57,20 @@ static void write_pixel(uint8_t x, uint8_t y, uint8_t z,
5757#endif
5858}
5959
60- static void fill_cube (uint8_t x0 , uint8_t y0 , uint8_t z0 ,
61- uint8_t x1 , uint8_t y1 , uint8_t z1 ,
60+ static void fill_cube (uint8_t x , uint8_t y , uint8_t z ,
61+ uint8_t cx , uint8_t cy , uint8_t cz ,
6262 uint16_t color_idx , uint16_t color_ctr )
6363{
64- for (uint8_t x = x0 ; x <= x1 ; x ++ ) {
65- for (uint8_t y = y0 ; y <= y1 ; y ++ ) {
66- for (uint8_t z = z0 ; z <= z1 ; z ++ ) {
67- write_pixel (x , y , z , color_idx , color_ctr );
64+ for (uint8_t i = 0 ; i < cx ; i ++ ) {
65+ for (uint8_t j = 0 ; j < cy ; j ++ ) {
66+ for (uint8_t k = 0 ; k < cz ; k ++ ) {
67+ write_pixel (x + i , y + j , z + k , color_idx , color_ctr );
6868 }
6969 }
7070 }
7171}
7272
73- static void write_cube_bitmap (uint8_t x0 , uint8_t y0 , uint8_t z0 ,
74- uint8_t x1 , uint8_t y1 , uint8_t z1 ,
75- const uint8_t * bitmap )
73+ static void write_cube_bitmap (const uint8_t * bitmap )
7674{
7775 uint8_t x = 0 ;
7876 uint8_t y = 0 ;
@@ -230,7 +228,7 @@ static void vfx_task_handle(void *pvParameter)
230228 color_tmp = color_idx ;
231229#if defined(CONFIG_VFX_OUTPUT_ST7735 )
232230 for (uint16_t i = 0 ; i < 52 ; i ++ ) {
233- uint16_t temp = fft_amp [i ] / 32 ;
231+ uint16_t temp = fft_amp [i ] / 8.192 ;
234232 uint32_t pixel_color = read_color_from_table (color_idx , color_ctr );
235233
236234 if (temp > 80 ) {
@@ -250,7 +248,7 @@ static void vfx_task_handle(void *pvParameter)
250248 uint16_t fill_cy = temp ;
251249#else
252250 for (uint16_t i = 0 ; i < 60 ; i ++ ) {
253- uint16_t temp = fft_amp [i ] / 16 ;
251+ uint16_t temp = fft_amp [i ] / 4.8 ;
254252 uint32_t pixel_color = read_color_from_table (color_idx , color_ctr );
255253
256254 if (temp > 135 ) {
@@ -366,7 +364,7 @@ static void vfx_task_handle(void *pvParameter)
366364 clear_cube ();
367365 break ;
368366 }
369- fill_cube (0 , 0 , 0 , 7 , 7 , 7 , color_idx , color_ctr );
367+ fill_cube (0 , 0 , 0 , 8 , 8 , 8 , color_idx , color_ctr );
370368 if (++ color_idx > 511 ) {
371369 color_idx = 0 ;
372370 }
@@ -385,7 +383,7 @@ static void vfx_task_handle(void *pvParameter)
385383 clear_cube ();
386384 break ;
387385 }
388- fill_cube (0 , 0 , 0 , 7 , 7 , 7 , color_idx , color_ctr );
386+ fill_cube (0 , 0 , 0 , 8 , 8 , 8 , color_idx , color_ctr );
389387 if (ctr_dir == 0 ) { // 暗->明
390388 if (color_ctr -- == vfx_ctr ) {
391389 color_ctr = vfx_ctr ;
@@ -701,7 +699,7 @@ static void vfx_task_handle(void *pvParameter)
701699 clear_cube ();
702700 break ;
703701 }
704- write_cube_bitmap (0 , 0 , 0 , 7 , 7 , 7 , bitmap_wave [frame_idx ]);
702+ write_cube_bitmap (bitmap_wave [frame_idx ]);
705703 if (frame_idx ++ == 44 ) {
706704 frame_idx = 8 ;
707705 }
@@ -787,15 +785,35 @@ static void vfx_task_handle(void *pvParameter)
787785
788786 color_idx = 63 ;
789787 for (uint16_t i = 0 ; i < 64 ; i ++ ) {
790- uint16_t temp = fft_amp [i ] / 320 ;
791- if (temp != 0 ) {
792- fill_cube (x , 7 - y , 0 , x , 7 - y , 7 - temp , 0 , 511 );
793- fill_cube (x , 7 - y , 7 - temp , x , 7 - y , 7 , color_idx , color_ctr );
794- } else {
795- fill_cube (x , 7 - y , 0 , x , 7 - y , 6 , 0 , 511 );
796- fill_cube (x , 7 - y , 7 , x , 7 - y , 7 , color_idx , color_ctr );
788+ uint8_t temp = fft_amp [i ] / 81.92 ;
789+
790+ if (temp > 8 ) {
791+ temp = 8 ;
792+ } else if (temp < 1 ) {
793+ temp = 1 ;
797794 }
798795
796+ uint8_t clear_x = x ;
797+ uint8_t clear_cx = 1 ;
798+ uint8_t clear_y = 7 - y ;
799+ uint8_t clear_cy = 1 ;
800+ uint8_t clear_z = 0 ;
801+ uint8_t clear_cz = 8 - temp ;
802+
803+ uint8_t fill_x = x ;
804+ uint8_t fill_cx = 1 ;
805+ uint8_t fill_y = 7 - y ;
806+ uint8_t fill_cy = 1 ;
807+ uint8_t fill_z = 8 - temp ;
808+ uint8_t fill_cz = temp ;
809+
810+ fill_cube (clear_x , clear_y , clear_z ,
811+ clear_cx , clear_cy , clear_cz ,
812+ 0 , 511 );
813+ fill_cube (fill_x , fill_y , fill_z ,
814+ fill_cx , fill_cy , fill_cz ,
815+ color_idx , color_ctr );
816+
799817 if (y ++ == 7 ) {
800818 y = 0 ;
801819 if (x ++ == 7 ) {
@@ -844,15 +862,35 @@ static void vfx_task_handle(void *pvParameter)
844862
845863 color_idx = color_tmp ;
846864 for (uint16_t i = 0 ; i < 64 ; i ++ ) {
847- uint16_t temp = fft_amp [i ] / 320 ;
848- if (temp != 0 ) {
849- fill_cube (x , 7 - y , 0 , x , 7 - y , 7 - temp , 0 , 511 );
850- fill_cube (x , 7 - y , 7 - temp , x , 7 - y , 7 , color_idx , color_ctr );
851- } else {
852- fill_cube (x , 7 - y , 0 , x , 7 - y , 6 , 0 , 511 );
853- fill_cube (x , 7 - y , 7 , x , 7 - y , 7 , color_idx , color_ctr );
865+ uint8_t temp = fft_amp [i ] / 81.92 ;
866+
867+ if (temp > 8 ) {
868+ temp = 8 ;
869+ } else if (temp < 1 ) {
870+ temp = 1 ;
854871 }
855872
873+ uint8_t clear_x = x ;
874+ uint8_t clear_cx = 1 ;
875+ uint8_t clear_y = 7 - y ;
876+ uint8_t clear_cy = 1 ;
877+ uint8_t clear_z = 0 ;
878+ uint8_t clear_cz = 8 - temp ;
879+
880+ uint8_t fill_x = x ;
881+ uint8_t fill_cx = 1 ;
882+ uint8_t fill_y = 7 - y ;
883+ uint8_t fill_cy = 1 ;
884+ uint8_t fill_z = 8 - temp ;
885+ uint8_t fill_cz = temp ;
886+
887+ fill_cube (clear_x , clear_y , clear_z ,
888+ clear_cx , clear_cy , clear_cz ,
889+ 0 , 511 );
890+ fill_cube (fill_x , fill_y , fill_z ,
891+ fill_cx , fill_cy , fill_cz ,
892+ color_idx , color_ctr );
893+
856894 if (y ++ == 7 ) {
857895 y = 0 ;
858896 if (x ++ == 7 ) {
@@ -928,15 +966,35 @@ static void vfx_task_handle(void *pvParameter)
928966 x = led_idx_table [0 ][i ];
929967 y = led_idx_table [1 ][i ];
930968
931- uint16_t temp = fft_amp [i ] / 320 ;
932- if (temp != 0 ) {
933- fill_cube (x , 7 - y , 0 , x , 7 - y , 7 - temp , 0 , 511 );
934- fill_cube (x , 7 - y , 7 - temp , x , 7 - y , 7 , color_idx [i ], color_ctr [i ]);
935- } else {
936- fill_cube (x , 7 - y , 0 , x , 7 - y , 6 , 0 , 511 );
937- fill_cube (x , 7 - y , 7 , x , 7 - y , 7 , color_idx [i ], color_ctr [i ]);
969+ uint8_t temp = fft_amp [i ] / 81.92 ;
970+
971+ if (temp > 8 ) {
972+ temp = 8 ;
973+ } else if (temp < 1 ) {
974+ temp = 1 ;
938975 }
939976
977+ uint8_t clear_x = x ;
978+ uint8_t clear_cx = 1 ;
979+ uint8_t clear_y = 7 - y ;
980+ uint8_t clear_cy = 1 ;
981+ uint8_t clear_z = 0 ;
982+ uint8_t clear_cz = 8 - temp ;
983+
984+ uint8_t fill_x = x ;
985+ uint8_t fill_cx = 1 ;
986+ uint8_t fill_y = 7 - y ;
987+ uint8_t fill_cy = 1 ;
988+ uint8_t fill_z = 8 - temp ;
989+ uint8_t fill_cz = temp ;
990+
991+ fill_cube (clear_x , clear_y , clear_z ,
992+ clear_cx , clear_cy , clear_cz ,
993+ 0 , 511 );
994+ fill_cube (fill_x , fill_y , fill_z ,
995+ fill_cx , fill_cy , fill_cz ,
996+ color_idx [i ], color_ctr [i ]);
997+
940998 if (color_flg ) {
941999 if (color_idx [i ]-- == 0 ) {
9421000 color_idx [i ] = 511 ;
0 commit comments