单片机源程序如下:
- #include "stm32f10x.h"
- #include "delay.h"
- #include "led.h"
- #include "usart1.h"
- #include "lcd.h"
- #include "adc.h"
- #include "string.h"
- #include "stdio.h"
- u16 DeviceCode;//LCD_ID型号参数变量
- unsigned int i=0,n=320,Vmun=0,ADV[310];
- char c[5],cc[];
- // ADC1转换的电压值通过MDA方式传到SRAM
- extern __IO uint16_t ADC_ConvertedValue; //动变量
- // 局部变量,用于保存转换计算后的电压值
- float ADC_ConvertedValueLocal; //随着动变量而动
- static u16 voltage_x1=9,voltage_y1=120,voltage_x2=9,voltage_y2=142;
- u16 time=0;
- int flag=0;
- int allnum=0,move_x=10,move_y=120,clr_flag=0,nn=0;
-
- int ad[300],vtime=1500;
- void init_panel(void);//初始化界面
- void refresh_screen();//刷新屏幕
- int main(void)
- {
- ADC1_Init();//ADC初始化
-
- USART1_Config(9600); //串口初始化
- delay_init(72); //系统滴答定时器初始化最大定时1864ms
-
- lcd_init(); //LCD初始化
-
- DeviceCode=LCD_RD_DATA(R0);//LCD的R0寄存器保存着LCD_ID型号数值
-
- printf(" LCD_ID:%x\r\n",DeviceCode); //向串口打印LCD_ID型号
-
- //提取出千位,百位,十位,各位
- c[0]=DeviceCode/4096;c[1]=DeviceCode/256%16;c[2]=DeviceCode/16%16;c[3]=DeviceCode%16;
- c[0]+=0x30; c[1]+=0x30; c[2]+=0x30; c[3]+=0x30;//16进制转成字符型
- init_panel();//初始化界面
-
- delay_ms(50);
- while (1)
- {
- for(allnum=0;allnum<303;allnum++)
- {
-
- /*** 清除原来的电压点痕迹 ****/
- if(clr_flag==1)
- {
- LCD_DrawPoint_3(allnum + move_x ,move_y-ad[allnum],Def_BACK_COLOR);
- if((allnum<=300)&&(ad[allnum+1]>ad[allnum]))
- {
- for(nn=ad[allnum+1]-ad[allnum];nn>0;nn--)
- {
- LCD_DrawPoint_3(allnum+1+ move_x ,move_y-(ad[allnum+1]-nn),Def_BACK_COLOR); //delay_ms(1);
- }
- }
- if((allnum<=300)&&(ad[allnum+1]<ad[allnum]))
- {
- for(nn=ad[allnum]-ad[allnum+1];nn>0;nn--)
- {
- LCD_DrawPoint_3(allnum +1+ move_x ,move_y-(ad[allnum+1]+nn),Def_BACK_COLOR); //delay_ms(1);
- }
- }
- }
-
- /*** 取电压AD值 ****/
- ad[allnum]=ADC_ConvertedValue/90;
- /*** 画电压点 ****/
- LCD_DrawPoint_3(allnum + move_x ,move_y-ad[allnum] ,YELLOW);
- if((allnum>=1)&&(ad[allnum]>ad[allnum-1]))
- {
- for(nn=ad[allnum]-ad[allnum-1];nn>0;nn--)
- {
- LCD_DrawPoint_3(allnum + move_x ,move_y-(ad[allnum]-nn),YELLOW);
- }
- }
- if((allnum>=1)&&(ad[allnum]<ad[allnum-1]))
- {
- for(nn=ad[allnum-1]-ad[allnum];nn>0;nn--)
- {
- LCD_DrawPoint_3(allnum + move_x ,move_y-(ad[allnum]+nn),YELLOW);
- }
- }
- if(allnum==300){clr_flag=1;}
- }
- /*** 刷新屏幕 ****/
- refresh_screen();
-
- }
- }
- void init_panel(void)//初始化界面
- {
- int linenum=0;
-
- LCD_Clear(DARKBLUE);//清屏谈蓝色,示波器常见背景色
- LCD_Fill(8,18,320-8,240-22,Def_BACK_COLOR);//中间一大块黑色背景
-
- /* 上行显示的东东 */
- LCD_ShowString(4,1,"RIGOL",16,Def_POINT_COLOR,DARKBLUE);//左上角显示普源品牌示波器logo
- LCD_ShowString(52,1," AUTO ",16,GREEN,BLACK);
- LCD_ShowString(120,1,"~~~~~~~~~~",16,LGRAYBLUE,BLACK);
- LCD_ShowString(226,1," $ V ",16,YELLOW,BLACK);
- LCD_ShowString(246,1,"1",16,BLACK,YELLOW);
- LCD_ShowString(254,1," 2.00",16,YELLOW,BLACK);
- /************************ 中间显示的东东****************************************/
- /* 横条*/
- for(linenum=5;linenum<300;linenum+=8)
- {LCD_DrawPoint_3(10+linenum,20,GRAY);}
-
- for(linenum=5;linenum<300;linenum+=8)
- {LCD_DrawPoint_3(10+linenum,70,GRAY);}
- for(linenum=5;linenum<300;linenum+=8) //中间横条
- {LCD_DrawPoint_3(10+linenum,120,GRAY);}
- for(linenum=5;linenum<300;linenum+=8)
- {LCD_DrawPoint_3(10+linenum,170,GRAY);}
-
- for(linenum=5;linenum<300;linenum+=8)
- {LCD_DrawPoint_3(10+linenum,218,GRAY);}
-
-
- /*竖条 */
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(10,16+linenum,GRAY);}
-
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(60,16+linenum,GRAY);}
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(110,16+linenum,GRAY);}
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(160,16+linenum,GRAY);}
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(210,16+linenum,GRAY);}
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(260,16+linenum,GRAY);}
-
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(310,16+linenum,GRAY);}
-
- LCD_ShowString(157,20,"T",12,BLACK,BROWN);
- LCD_ShowString(216,20,"t",16,BLACK,BROWN);
- LCD_ShowString(224,20," <5HZ ",16,WHITE,DARKBLUE);
- /************************ 中间显示的东东****************************************/
-
-
-
-
- /* 下行显示的东东 */
- LCD_ShowString(4,240-18," CH1- ",16,BLACK,YELLOW);
- LCD_ShowString(52,240-18," 1.00V ",16,YELLOW,BLACK);//1.00V 这个值要传数据,所以要用指针传参数进去才行
- LCD_ShowString(144,240-18," Time ",16,WHITE,BLACK);
- LCD_ShowString(184,240-18," 500.0",16,WHITE,BLACK);
- LCD_ShowString(232,240-18,"us ",16,WHITE,BLACK);
- LCD_ShowString(254,240-18,"T",16,BLACK,BROWN);
- LCD_ShowString(262,240-18,"->",16,BROWN,BLACK);
- LCD_ShowString(276,240-18,"0.00",16,BROWN,BLACK);
- LCD_ShowString(308,240-18,"s",16,BROWN,BLACK);
- }
- void refresh_screen()//刷新屏幕
- {
- int linenum=0;
-
-
- // LCD_Fill(8,18,320-8,240-22,Def_BACK_COLOR);//中间一大块黑色背景
-
- /************************ 中间显示的东东****************************************/
-
- /* 横条*/
- for(linenum=5;linenum<300;linenum+=8)
- {LCD_DrawPoint_3(10+linenum,20,GRAY);}
-
- for(linenum=5;linenum<300;linenum+=8)
- {LCD_DrawPoint_3(10+linenum,70,GRAY);}
- for(linenum=5;linenum<300;linenum+=8)
- {LCD_DrawPoint_3(10+linenum,120,GRAY);}
- for(linenum=5;linenum<300;linenum+=8)
- {LCD_DrawPoint_3(10+linenum,170,GRAY);}
-
- for(linenum=5;linenum<300;linenum+=8)
- {LCD_DrawPoint_3(10+linenum,218,GRAY);}
-
-
- /*竖条 */
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(10,16+linenum,GRAY);}
-
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(60,16+linenum,GRAY);}
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(110,16+linenum,GRAY);}
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(160,16+linenum,GRAY);}
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(210,16+linenum,GRAY);}
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(260,16+linenum,GRAY);}
-
- for(linenum=5;linenum<200;linenum+=8)
- {LCD_DrawPoint_3(310,16+linenum,GRAY);}
-
- LCD_ShowString(157,20,"T",12,BLACK,BROWN);
- LCD_ShowString(216,20,"t",16,BLACK,BROWN);
- LCD_ShowString(224,20," <5HZ ",16,WHITE,DARKBLUE);
- /************************ 中间显示的东东****************************************/
- }
复制代码
所有资料51hei提供下载:
L001基于F1标准库3.5版本核心源代码.zip
(20.83 KB, 下载次数: 95)
L001型示波器使用说明.doc
(6.76 MB, 下载次数: 62)
L001原理图.pdf
(1.04 MB, 下载次数: 79)
|