[STM32F7] 基于STM32F4/F7的图形应用演示方案

[复制链接]
 楼主| Plantt 发表于 2019-11-8 22:10 | 显示全部楼层 |阅读模式
基于STM32F4/F7的图形应用演示方案


1、STM32F769 图形能力及网络功能演示

该演示方案基于STM32F7高性能系列单片机评估板,展示STM32F7芯片出众的图形处理能力。全新的STM32F76X系列支持JPEG硬件编解码,可播放MoTIon JPEG格式视频,可通过MIPI接口向800*480的屏幕输出。其强大的网络功能可以实现基于以太网的VNC客户端。

该方案可应用于智能家居、工业控制等人机界面场合。

2、STM32F746虚拟3D图形演示

在STM32F746开发套件上运行TouchGFX图形引擎,结合STM32 内置的CHROM ART图形加速器实现透明效果和模拟3D动画效果。直接驱动480*272的4.3” TFT屏。

该方案可以为2D图形界面带来平滑过渡和3D动态立体切换效果。

3、STM32F746 WIN10 风格工控界面演示

采用Embedded Wizard提供的图形库,仅占用片上较少的资源就可以制作出类似Win10风格的用户界面,直接驱动板载的480*272的4.3” TFT屏。

该方案可应用于简单明了的图形人机界面场景,如智能手表及其它控制设备。

4、STM32F746多图形功能演示

在STM32F746开发板上运行TouchGFX图形引擎,结合STM32 内置的CHROM ART图形加速器实现多图形、多功能且具有透明效果的动画演示,并直接驱动480*272的4.3” TFT屏。

该方案同样可应用于智能家居、工业控制等人机界面场合。

5、STM32F469运动计步应用图形方案

采用Embedded Wizard提供的图形库,在STM32F469 上设计出适合运用于运动手表的用户界面,便于客户二次开发。界面最终可以通过MIPI接口显示在800*480的TFT屏上。

6、基于STM32F429探索套件的STemWin图形方案

运用ST免费提供的STemWin GUI 在STM32F429探索套件上开发基本的人机图形界面,并直接驱动QVGA屏,具有占用资源少,功耗低等特点。

该方案很适合于智能穿戴产品。

7、基于STM32F429探索套件的TouchGFX图形方案

采用DRAUPNER提供的TouchGFX GUI在STM32F429探索套件上开发基本的人机图形界面,同时结合STM32 内置的CHROM ART图形加速器,从而降低CPU负荷,提高MCU的计算处理能力。该方案适合于对图像质量要求较高的智能穿戴产品及其它人机交互场合。



mmuuss586 发表于 2019-11-25 09:38 | 显示全部楼层
感谢分享
zjq985062714 发表于 2019-11-29 11:30 | 显示全部楼层
没有附件吗?
hanzhen654 发表于 2019-11-29 12:15 | 显示全部楼层
请问有参考代码吗?
hanzhen654 发表于 2019-11-29 12:15 | 显示全部楼层
现在MCU 使用的GUI一般都用哪些?
hanzhen654 发表于 2019-11-29 15:02 | 显示全部楼层
本次我们来自己封装一个FFT函数,进行简单的测试。
fft.c
  1. #include "math.h"
  2. #include "fft.h"
  3. //精度0.0001弧度
  4. //复数的交换
  5. void conjugate_complex(int n,complex in[],complex out[])
  6. {
  7.   int i = 0;
  8.   for(i=0;i<n;i++)
  9.   {
  10.     out[i].imag = -in[i].imag;
  11.     out[i].real = in[i].real;
  12.   }       
  13. }
  14. //求所有复数的模
  15. void c_abs(complex f[],float out[],int n)
  16. {
  17.   int i = 0;
  18.   float t;
  19.   for(i=0;i<n;i++)
  20.   {
  21.     t = f[i].real * f[i].real + f[i].imag * f[i].imag;
  22.     out[i] = sqrt(t);
  23.   }       
  24. }

  25. //求复数的和
  26. void c_plus(complex a,complex b,complex *c)
  27. {
  28.   c->real = a.real + b.real;
  29.   c->imag = a.imag + b.imag;
  30. }
  31. //求复数的差  
  32. void c_sub(complex a,complex b,complex *c)
  33. {
  34.   c->real = a.real - b.real;
  35.   c->imag = a.imag - b.imag;       
  36. }
  37. //求复数的积
  38. void c_mul(complex a,complex b,complex *c)
  39. {
  40.   c->real = a.real * b.real - a.imag * b.imag;
  41.   c->imag = a.real * b.imag + a.imag * b.real;       
  42. }
  43. //求复数的商
  44. void c_div(complex a,complex b,complex *c)
  45. {
  46.   c->real = (a.real * b.real + a.imag * b.imag)/(b.real * b.real +b.imag * b.imag);
  47.   c->imag = (a.imag * b.real - a.real * b.imag)/(b.real * b.real +b.imag * b.imag);
  48. }
  49. #define SWAP(a,b)  tempr=(a);(a)=(b);(b)=tempr
  50. void Wn_i(int n,int i,complex *Wn,char flag)
  51. {
  52.   Wn->real = cos(2*PI*i/n);
  53.   if(flag == 1)
  54.   Wn->imag = -sin(2*PI*i/n);
  55.   else if(flag == 0)
  56.   Wn->imag = -sin(2*PI*i/n);
  57. }
  58. //傅里叶变化
  59. void fft(int N,complex f[])
  60. {
  61.   complex t,wn;//中间变量
  62.   int i,j,k,m,n,l,r,M;
  63.   int la,lb,lc;
  64.   /*----计算分解的级数M=log2(N)----*/
  65.   for(i=N,M=1;(i=i/2)!=1;M++);
  66.   /*----按照倒位序重新排列原信号----*/
  67.   for(i=1,j=N/2;i<=N-2;i++)
  68.   {
  69.     if(i<j)
  70.     {
  71.       t=f[j];
  72.       f[j]=f[i];
  73.       f[i]=t;
  74.     }
  75.     k=N/2;
  76.     while(k<=j)
  77.     {
  78.       j=j-k;
  79.       k=k/2;
  80.     }
  81.     j=j+k;
  82.   }

  83.   /*----FFT算法----*/
  84.   for(m=1;m<=M;m++)
  85.   {
  86.     la=pow(2,m); //la=2^m代表第m级每个分组所含节点数               
  87.     lb=la/2;    //lb代表第m级每个分组所含碟形单元数
  88.                  //同时它也表示每个碟形单元上下节点之间的距离
  89.     /*----碟形运算----*/
  90.     for(l=1;l<=lb;l++)
  91.     {
  92.       r=(l-1)*pow(2,M-m);       
  93.       for(n=l-1;n<N-1;n=n+la) //遍历每个分组,分组总数为N/la
  94.       {
  95.         lc=n+lb;  //n,lc分别代表一个碟形单元的上、下节点编号     
  96.         Wn_i(N,r,&wn,1);//wn=Wnr
  97.         c_mul(f[lc],wn,&t);//t = f[lc] * wn复数运算
  98.         c_sub(f[n],t,&(f[lc]));//f[lc] = f[n] - f[lc] * Wnr
  99.         c_plus(f[n],t,&(f[n]));//f[n] = f[n] + f[lc] * Wnr
  100.       }
  101.     }
  102.   }
  103. }
  104. //傅里叶逆变换
  105. void ifft(int N,complex f[])
  106. {
  107.   int i=0;
  108.   conjugate_complex(N,f,f);
  109.   fft(N,f);
  110.   conjugate_complex(N,f,f);
  111.   for(i=0;i<N;i++)
  112.   {
  113.     f[i].imag = (f[i].imag)/N;
  114.     f[i].real = (f[i].real)/N;
  115.   }
  116. }


hanzhen654 发表于 2019-11-29 15:03 | 显示全部楼层
fft.h
  1. #ifndef __FFT_H__
  2. #define __FFT_H__

  3. typedef struct complex //复数类型
  4. {
  5.   float real;                //实部
  6.   float imag;                //虚部
  7. }complex;

  8. #define PI 3.1415926535897932384626433832795028841971
  9. ///////////////////////////////////////////
  10. void conjugate_complex(int n,complex in[],complex out[]);
  11. void c_plus(complex a,complex b,complex *c);//复数加
  12. void c_mul(complex a,complex b,complex *c) ;//复数乘
  13. void c_sub(complex a,complex b,complex *c);        //复数减法
  14. void c_div(complex a,complex b,complex *c);        //复数除法
  15. void fft(int N,complex f[]);//傅立叶变换 输出也存在数组f中
  16. void ifft(int N,complex f[]); // 傅里叶逆变换
  17. void c_abs(complex f[],float out[],int n);//复数数组取模
  18. ////////////////////////////////////////////
  19. #endif


hanzhen654 发表于 2019-11-29 15:04 | 显示全部楼层
测试代码部分
  1. #include "sys.h"
  2. #include "delay.h"
  3. #include "usart.h"
  4. #include "led.h"
  5. #include "math.h"
  6. #include "fft.h"
  7. #define  N    256          //采样点数
  8. #define  Fs   44800        //采样频率
  9. #define  F    175          //分辨率
  10. #define  P1   30           //测试相位
  11. #define  P2   60
  12. #define  P3   90

  13. //FFT测试数据集 输入数组
  14. complex  FFT_256PointIn[N];
  15. //FFT测试数据集 输出数组
  16. float   FFT_256PointOut[N/2];                                                                               
  17. //填入数组                                                                                                                               
  18. void InitBufInArray()
  19. {
  20. unsigned short i;
  21. for(i=0; i<N; i++)   
  22.         {
  23.        FFT_256PointIn[i].real  = 1500 * sin(2*PI * i * 350.0 / Fs+(PI*P1/180))
  24.                                              +2700 * sin(2*PI * i * 8400.0 / Fs+(PI*P2/180))
  25.                                              +4000 * sin(2*PI * i * 18725.0 / Fs+(PI*P3/180));
  26.                    FFT_256PointIn[i].imag = 0;
  27.     }       
  28. }

  29. /******************************************************************
  30. 函数名称:GetPowerMag()
  31. 函数功能:计算各次谐波幅值
  32. 参数说明:
  33. 备  注:先将FFT_256PointIn分解成实部(X)和虚部(Y),
  34.          然后计算幅值:(sqrt(X*X+Y*Y)*2/N
  35.          然后计算相位:atan2(Y/X)
  36. 作  者:土耳其冰激凌
  37. *******************************************************************/
  38. void GetPowerMag()
  39. {
  40.     unsigned short i;
  41.           float  X,Y,P,Mag;
  42.                  c_abs(FFT_256PointIn,FFT_256PointOut,N/2);
  43.     for(i=0; i<N/2; i++)
  44.     {
  45.                           X = FFT_256PointIn[i].real/N;    //计算实部
  46.                           Y = FFT_256PointIn[i].imag/N;    //计算虚部
  47.                           Mag = FFT_256PointOut[i]*2/N;    //计算幅值
  48.                           P = atan2(Y,X)*180/PI;           //计算相位
  49.                                 printf("%d      ",i);
  50.                                 printf("%d      ",F*i);
  51.                                 printf("%f      ",Mag);
  52.                           printf("%f      ",P);
  53.                                 printf("%f      ",X);
  54.                                 printf("%f      \r\n",Y);                       
  55.     }
  56. }
  57. int main(void)
  58. {       
  59.         delay_init();            //延时函数初始化          
  60.         LED_Init();                          //初始化与LED连接的硬件接口
  61.         uart_init(9600);  //初始化串口 9600波特率
  62.         printf("这是一个FFT 测试实验\r\n");  
  63.   InitBufInArray();
  64.         fft(N,FFT_256PointIn);
  65.         printf("点数   频率  幅值   实部  虚部\n");
  66.         GetPowerMag();
  67.         while(1)
  68.                  {
  69.                                 LED0=0;
  70.                                 LED1=1;
  71.                                 delay_ms(300);         //延时300ms
  72.                                 LED0=1;
  73.                                 LED1=0;
  74.                                 delay_ms(300);        //延时300ms
  75.                         }
  76. }


hanzhen654 发表于 2019-11-29 15:12 | 显示全部楼层
输出打印结果:
点数   频率   幅值         相位           实部          虚部
0      0      0.000031      0.000000      0.000015      0.000000      
1      175      0.000025      36.658634      0.000010      0.000008      
2      350      1500.000000      -60.000000      374.999969      -649.519043      
3      525      0.000020      52.221466      0.000006      0.000008      
4      700      0.000014      -28.152960      0.000006      -0.000003      
5      875      0.000060      -17.167744      0.000029      -0.000009      
6      1050      0.000012      -4.051142      0.000006      -0.000000      
7      1225      0.000028      27.618505      0.000013      0.000007      
8      1400      0.000036      56.088974      0.000010      0.000015      
9      1575      0.000013      85.033867      0.000001      0.000007      
10      1750      0.000019      -126.592506      -0.000006      -0.000008      
11      1925      0.000099      155.458847      -0.000045      0.000021      
12      2100      0.000021      -158.704437      -0.000010      -0.000004      
13      2275      0.000018      -89.424667      0.000000      -0.000009      
14      2450      0.000015      -87.367409      0.000000      -0.000007      
15      2625      0.000019      -84.178368      0.000001      -0.000010      
16      2800      0.000086      112.500000      -0.000017      0.000040      
17      2975      0.000008      -30.908798      0.000003      -0.000002      
18      3150      0.000028      -93.026222      -0.000001      -0.000014      
19      3325      0.000032      -100.869904      -0.000003      -0.000016      
20      3500      0.000028      -35.795570      0.000012      -0.000008      
21      3675      0.000248      -9.752425      0.000122      -0.000021      
22      3850      0.000036      -59.215248      0.000009      -0.000015      
23      4025      0.000010      -76.748405      0.000001      -0.000005      
24      4200      0.000050      154.164047      -0.000023      0.000011      
25      4375      0.000015      -60.317295      0.000004      -0.000006      
26      4550      0.000014      108.588715      -0.000002      0.000006      
27      4725      0.000029      98.175682      -0.000002      0.000014      
28      4900      0.000016      -124.238319      -0.000004      -0.000007      
29      5075      0.000048      108.763763      -0.000008      0.000023      
30      5250      0.000047      -21.094650      0.000022      -0.000008      
31      5425      0.000009      -38.687473      0.000003      -0.000003      
32      5600      0.000113      -87.260597      0.000003      -0.000056      
33      5775      0.000016      -63.487057      0.000004      -0.000007      
34      5950      0.000022      7.387201      0.000011      0.000001      
35      6125      0.000027      63.663502      0.000006      0.000012      
36      6300      0.000032      62.835876      0.000007      0.000014      
37      6475      0.000076      -38.793385      0.000030      -0.000024      
38      6650      0.000009      16.024696      0.000004      0.000001      
39      6825      0.000012      -110.747261      -0.000002      -0.000006      
40      7000      0.000028      82.453056      0.000002      0.000014      
41      7175      0.000016      -27.415680      0.000007      -0.000004      
42      7350      0.000027      160.582352      -0.000013      0.000004      
43      7525      0.000087      -87.681641      0.000002      -0.000044      
44      7700      0.000022      -135.357925      -0.000008      -0.000008      
45      7875      0.000014      -169.563293      -0.000007      -0.000001      
46      8050      0.000009      1.227116      0.000004      0.000000      
47      8225      0.000016      42.631676      0.000006      0.000006      
48      8400      2700.000000      -30.000000      1169.134277      -675.000000      
49      8575      0.000008      175.232651      -0.000004      0.000000      
50      8750      0.000017      147.675629      -0.000007      0.000005      
51      8925      0.000056      179.124176      -0.000028      0.000000      
52      9100      0.000021      126.577728      -0.000006      0.000008      
53      9275      0.000040      28.367682      0.000018      0.000010      
54      9450      0.000011      -37.718578      0.000004      -0.000003      
55      9625      0.000010      131.671509      -0.000003      0.000004      
56      9800      0.000026      172.892471      -0.000013      0.000002      
57      9975      0.000018      -143.289139      -0.000007      -0.000005      
58      10150      0.000012      -115.207047      -0.000003      -0.000006      
59      10325      0.000008      -87.947166      0.000000      -0.000004      
60      10500      0.000016      -127.038078      -0.000005      -0.000006      
61      10675      0.000024      35.620342      0.000010      0.000007      
62      10850      0.000000      0.000000      0.000000      0.000000      
63      11025      0.000030      167.302933      -0.000015      0.000003      
64      11200      0.000087      -37.874985      0.000034      -0.000027      
65      11375      0.000009      -56.846428      0.000002      -0.000004      
66      11550      0.000000      0.000000      0.000000      0.000000      
67      11725      0.000016      65.517853      0.000003      0.000007      
68      11900      0.000020      -62.873825      0.000005      -0.000009      
69      12075      0.000049      146.105896      -0.000021      0.000014      
70      12250      0.000025      144.522079      -0.000010      0.000007      
71      12425      0.000022      83.036545      0.000001      0.000011      
72      12600      0.000024      124.945473      -0.000007      0.000010      
73      12775      0.000017      150.301559      -0.000008      0.000004      
74      12950      0.000006      73.393593      0.000001      0.000003      
75      13125      0.000064      101.329811      -0.000006      0.000031      
76      13300      0.000022      21.395346      0.000010      0.000004      
77      13475      0.000044      -22.719753      0.000020      -0.000008      
78      13650      0.000002      67.932175      0.000000      0.000001      
79      13825      0.000015      36.952290      0.000006      0.000004      
80      14000      0.000061      -90.000000      0.000000      -0.000031      
81      14175      0.000024      4.587837      0.000012      0.000001      
82      14350      0.000027      -164.107590      -0.000013      -0.000004      
83      14525      0.000026      94.922646      -0.000001      0.000013      
84      14700      0.000017      113.708290      -0.000003      0.000008      
85      14875      0.000049      -94.115646      -0.000002      -0.000025      
86      15050      0.000020      3.759978      0.000010      0.000001      
87      15225      0.000019      -4.117675      0.000010      -0.000001      
88      15400      0.000017      -42.499950      0.000006      -0.000006      
89      15575      0.000017      -79.784363      0.000002      -0.000009      
90      15750      0.000016      -98.852882      -0.000001      -0.000008      
91      15925      0.000054      139.931839      -0.000021      0.000017      
92      16100      0.000026      165.618698      -0.000013      0.000003      
93      16275      0.000015      -164.399490      -0.000007      -0.000002      
94      16450      0.000016      -51.657200      0.000005      -0.000006      
95      16625      0.000035      167.911438      -0.000017      0.000004      
96      16800      0.000008      -132.260605      -0.000003      -0.000003      
97      16975      0.000021      94.842651      -0.000001      0.000011      
98      17150      0.000035      -114.642807      -0.000007      -0.000016      
99      17325      0.000037      34.428101      0.000015      0.000011      
100      17500      0.000016      -93.046417      -0.000000      -0.000008      
101      17675      0.000022      32.025196      0.000009      0.000006      
102      17850      0.000022      159.313171      -0.000010      0.000004      
103      18025      0.000012      137.351868      -0.000005      0.000004      
104      18200      0.000034      -31.864140      0.000014      -0.000009      
105      18375      0.000028      -157.610428      -0.000013      -0.000005      
106      18550      0.000020      56.170975      0.000006      0.000008      
107      18725      3999.999756      -0.000001      1999.999878      -0.000040      
108      18900      0.000024      70.995369      0.000004      0.000011      
109      19075      0.000075      44.852394      0.000026      0.000026      
110      19250      0.000026      -126.419708      -0.000008      -0.000010      
111      19425      0.000031      -90.581345      -0.000000      -0.000016      
112      19600      0.000086      67.500000      0.000017      0.000040      
113      19775      0.000032      117.184265      -0.000007      0.000014      
114      19950      0.000016      -152.757553      -0.000007      -0.000004      
115      20125      0.000047      -12.603742      0.000023      -0.000005      
116      20300      0.000009      -68.715248      0.000002      -0.000004      
117      20475      0.000067      144.246552      -0.000027      0.000020      
118      20650      0.000014      8.900421      0.000007      0.000001      
119      20825      0.000013      150.707443      -0.000006      0.000003      
120      21000      0.000051      67.017677      0.000010      0.000023      
121      21175      0.000016      8.680163      0.000008      0.000001      
122      21350      0.000013      -115.376968      -0.000003      -0.000006      
123      21525      0.000073      7.219605      0.000036      0.000005      
124      21700      0.000011      45.488987      0.000004      0.000004      
125      21875      0.000051      79.440254      0.000005      0.000025      
126      22050      0.000061      0.000000      0.000031      0.000000      
127      22225      0.000012      -156.431137      -0.000006      -0.000002

hanzhen654 发表于 2019-11-29 15:13 | 显示全部楼层
本次所测得结果更加接近matlab 所测量的结果,而且还加入了相位角,后续的FFT音乐频谱制作,我会使用C语言的FFT来进行操作。
磨砂 发表于 2019-12-9 15:25 | 显示全部楼层
非常感谢楼主分享
晓伍 发表于 2019-12-9 15:36 | 显示全部楼层
非常感谢楼主分享
八层楼 发表于 2019-12-9 15:42 | 显示全部楼层
非常感谢楼主分享
您需要登录后才可以回帖 登录 | 注册

本版积分规则

637

主题

901

帖子

5

粉丝
快速回复 在线客服 返回列表 返回顶部