|
楼主 |
发表于 2008-10-13 09:29:42
|
显示全部楼层
"示波器"源码:
void Show_Wave_Window(void)
{
int a;
GUI_ClrScreen(RGB565(0,0,0));
GUI_FillRectangle(0,0,240,160,RGB565(0,0,0));
GUI_FillRectangle(0,160,240,160,RGB565(16,40,0));
GUI_Rectangle(0,160,240,160,RGB_Black);
for(a=0;a<160;a+=32)
{
GUI_DotLine(0,a,240,a,RGB565(16,32,16)); //Hor Line
}
////
for(a=0;a<240;a+=20)
{
GUI_DotLine(a,0,a,160,RGB565(16,32,16)); //Ver Line
}
GUI_DotLine(239,0,239,160,RGB565(16,32,16)); //Ver Line
////////
a=1;
GUI_Printf(1,a,RGB_Green(58),RGB_Tran,Font_ASC_5_8,"%.2f",3.0*(float)(5.0/5));
a+=32;
GUI_Printf(1,a,RGB_Green(58),RGB_Tran,Font_ASC_5_8,"%.2f",3.0*(float)(4.0/5));
a+=32;
GUI_Printf(1,a,RGB_Green(58),RGB_Tran,Font_ASC_5_8,"%.2f",3.0*(float)(3.0/5));
a+=32;
GUI_Printf(1,a,RGB_Green(58),RGB_Tran,Font_ASC_5_8,"%.2f",3.0*(float)(2.0/5));
a+=32;
GUI_Printf(1,a,RGB_Green(58),RGB_Tran,Font_ASC_5_8,"%.2f",3.0*(float)(1.0/5));
////
a=20+1;
GUI_Printf(a,160-8,RGB_Blue(31),RGB_Tran,Font_ASC_5_8,"5");
a+=20;
GUI_Printf(a,160-8,RGB_Blue(31),RGB_Tran,Font_ASC_5_8,"10");
a+=20;
GUI_Printf(a,160-8,RGB_Blue(31),RGB_Tran,Font_ASC_5_8,"15");
a+=20;
GUI_Printf(a,160-8,RGB_Blue(31),RGB_Tran,Font_ASC_5_8,"20");
a+=20;
GUI_Printf(a,160-8,RGB_Blue(31),RGB_Tran,Font_ASC_5_8,"25");
a+=20;
GUI_Printf(a,160-8,RGB_Blue(31),RGB_Tran,Font_ASC_5_8,"30");
a+=20;
GUI_Printf(a,160-8,RGB_Blue(31),RGB_Tran,Font_ASC_5_8,"35");
a+=20;
GUI_Printf(a,160-8,RGB_Blue(31),RGB_Tran,Font_ASC_5_8,"40");
a+=20;
GUI_Printf(a,160-8,RGB_Blue(31),RGB_Tran,Font_ASC_5_8,"45");
a+=20;
GUI_Printf(a,160-8,RGB_Blue(31),RGB_Tran,Font_ASC_5_8,"50");
a+=20;
GUI_Printf(a,160-8,RGB_Blue(31),RGB_Tran,Font_ASC_5_8,"55");
////
GUI_Label(0,160,240,32,RGB_Green(56),RGB565(20,20,0),RGB_Black,Center,Font_ASC_8_16,"Sensor Test");
ALCO_2Button_Below(GUI_MSG_CANCEL,GUI_MSG_NEXT,"Exit","ReStart");
////
}
/*============================================================================*/
/*============================================================================*/
void Wave_Sample(void)
{
#define Wave_XSIZE 240
#define Wave_YSIZE 160
#define RGB_LINE RGB565(31,0,0)
#define AD_Vref 3.0
#define AD_MAX 0x0fff
////
float x,faddata,voltage,time;
float x0,y0,x1,y1;
U8 Uart_Key;
U16 addata;
int ii;
U16 i;
int val;
////
////
////
/////////////
Wave_ST:
TS_Scan_Clr_Stop();
// Key_Scan_Clr_Stop();
ALCO_Heat_ON();
time=0;
GUI_MemdevEnable();
Show_Wave_Window();
GUI_DisplayUpdata(0,0,LCD_XSIZE,LCD_YSIZE);
GUI_MemdevDisable();
x0=0;
addata=Get_ALCO_Addata();
faddata=addata;
voltage=faddata*(AD_Vref/AD_MAX);
y0=Wave_YSIZE-(voltage/(AD_Vref/Wave_YSIZE));
for(x=0;x<Wave_XSIZE;x++)
{
//Reset_LCD_Backlight_Time_Count();
addata=Get_ALCO_Addata();
faddata=addata;
voltage=faddata*(AD_Vref/AD_MAX);
y1=Wave_YSIZE-(voltage/(AD_Vref/Wave_YSIZE));
Tick15msDecCnt=(250/15); //Delay250ms.
while(Tick15msDecCnt>0)
{
Uart_Key=Uart_GetKey(0);
if(ALCO_Cancel_Key_Pressed()) return;
val=TS_GetButtonValue(ALCO_2Button,&i);
if(val==GUI_MSG_CANCEL)
{
ALCO_Heat_OFF();
return;
}
////
if(val==GUI_MSG_NEXT) goto Wave_ST;
}
time+=0.25;
////
x0=x;
x1=x+1;
GUI_Line(x0,y0,x1,y1,RGB_LINE);
//GUI_Wave(0,0,RGB_Blue(31),240,160,1,x,x1,y1);
////
ii=200;
GUI_Printf(4,ii,RGB_Blue(20),RGB_Gray,Font_ASC_8_16," Time=%.2fS ",time);
ii+=20;
GUI_HorVernier(4,ii,240-4-4,16,8,RGB565(10,20,31),RGB565(20,40,50),RGB_Black,60,time);
////
ii+=20;
GUI_Printf(4,ii,RGB_Red(20),RGB_Gray,Font_ASC_8_16," Voltage=%04XH / %.4fV ",addata,voltage);
ii+=20;
GUI_ShadeHorProgress(4,ii,240-4-4,16,RGB565(31,56,28),RGB_Red(24),RGB565(20,40,50),RGB_Black,AD_MAX,addata);
x0=x1;
y0=y1;
}
////
ALCO_Heat_OFF();
Uart_Puts(0," Sensor Test Stop!\n");
while(1)
{
//Reset_LCD_Backlight_Time_Count();
Uart_Key=Uart_GetKey(0);
if(ALCO_Cancel_Key_Pressed()) return;
if(ALCO_Enter_Key_Pressed()) goto Wave_ST;
////
val=TS_GetButtonValue(ALCO_2Button,&i);
if(val==GUI_MSG_CANCEL)
{
ALCO_Heat_OFF();
return;
}
////
if(val==GUI_MSG_NEXT) goto Wave_ST;
}
} |
|