#include "GUI.h"
#include "stdlib.h"
#include "wm.h"
typedef unsigned int u16;
typedef unsigned char u8;
u8 SPEC[14]={0};
void SPEC_Display(u8 x,u8 y,u8 *p)
{
u8 i=0,x1=0,y1=0;
for(i=0;i<56;i+=4)
{
x1=x+i;
y1=y-*p++;
GUI_DrawLine(x1,y,x1,y1);
x1+=1;
GUI_DrawLine(x1,y,x1,y1);
}
}
static void Mp3_Cb(WM_MESSAGE* pMsg)
{
u8 i=0;
switch (pMsg->MsgId)
{
case WM_PAINT:
GUI_SetBkColor(GUI_GREEN);
GUI_ClearRect(10,10,110,130);
SPEC_Display(20,120,SPEC);
break;
default:
WM_DefaultProc(pMsg);
}
}
void MainTask()
{
u8 i=0;
GUI_HWIN hWnd;
WM_MESSAGE Msg1;
GUI_Init();
GUI_SetBkColor(GUI_RED);
GUI_Clear();
GUI_DispString("Hello world!");
WM_SetCreateFlags(WM_CF_MEMDEV);
WM_EnableMemdev(WM_HBKWIN);
hWnd=WM_CreateWindow(10,10,100,120,WM_CF_SHOW|WM_CF_MEMDEV|WM_CF_HASTRANS,&Mp3_Cb,0);
Msg1.MsgId=WM_PAINT;
while(1)
{
/*这里是用随机数产生的频谱,只需要将vs1003读出的频谱数据送到SPEC数组中就可以实现频谱的显示*/
for(i=0;i<14;i++)
{
SPEC[i]=rand()%100;
}
WM_SendMessage(hWnd,&Msg1);
WM_Exec();
}
}
具体效果过几天试试 先发出来希望大家能分享下自己的想法 |