⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 采样—显示.c

📁 这是将采样得到的数据转换并显示到lcd显示屏的算法程序
💻 C
字号:
for(addr=1;addr<=2;addr++)
{	
	 k=0;
	AUXR=0X00;
	uart();
//显示点数
	AUXR=AUXR|2;
	jis[0]=len/100+0x30;
	jis[1]=(len%100)/10+0x30;
	jis[2]=(len%10)+0x30;
	TextDisp( 5,20, jis );  
	AUXR=0X00;		  						   
	WP=0;  
//	for(i=0;i<len;i++)  //写数据
//	write24c16(i,E2prow[i]); //
 //读写24c16
//	page_wr(0,len,E2prow); // 2*MAX
	AUXR=AUXR|2;
	LcmClear();
	 j=0;
	for(i=0;i<MAX;i++)//读24c16,并将收到的数据还原
	{			
		AUXR=0X00;	
	//	high=read24c16(i);
	//	low=read24c16(i+1);
	//	high=1;
	//	low=0;
 /*   	high=E2prow[i];
    	low=E2prow[i+1];
		temp1=(uint)(high);			
		temp1=temp1<<8;	
		temp2=(uint)(low);
		sum=temp2|temp1; */	   
	 if(i>20&&E2prow[i]<3031)
  	  { 	  
      shu[i%5]=real(E2prow[i-1],E2prow[i]);
	  for(s=0;s<5;s++)
	  	hezhi+=shu[s];
	  	//sumax=hezhi;
	   	if(sumin>=hezhi)
			{sumin=hezhi;
			cunzhu=i;  }
		//if(sumax<hezhi)
		//	sumax=hezhi;	         
	   }  	 
	  
//计算采样电压值 
		advalue=E2prow[i]*5.0/4095;
		y[j]= (uchar)(advalue*30);// 纵坐标增加的格数		
		temp3=advalue*100;
		temp3=temp3*100;
		temp=(uint)temp3;
		dat[0]=temp/10000+0x30;
		temp=temp%10000;
		dat[1]='.';
		dat[2]=temp/1000+0x30;
		temp=temp%1000;	
		dat[3]=temp/100+0x30;
		temp=temp%100;
		dat[4]=temp/10+0x30 ;
		temp=temp%10;
		dat[5]=temp+0x30;
		dat[6]='V';	
		dat[7]='\0';
		AUXR=AUXR|2; //禁用RAM
		//j++;
//文本方式显示数组内容			
		if(i%5==0)	 //一行5个数据
	        k++;
			if(k==30)
			{
				LcmClear();
				k++;	 				
			}	
		TextDisp( 8*(i%5),k%30,dat); //显示数据	
                AUXR=0x00;	 
		j++;
		delayms(200); 
	}	   
	WP=1;count=j;
	delaym(200);
/*	for(i=0;i<2*MAX;i++)  //测试24c16读写是否有误
	shu[i]=read24c16(i);
	TextDisp(0,5, shu );  */   
	AUXR=AUXR|2;
	LcmClear();
	WriteCommand( Ovlay );		// 显示合成方式设置
 	WriteData(0x1c);				// 设置参数:三重叠合成; 显示一,三
	Linexy(  20,	 48,	20,	 	 200 ,1);
	Linexy(  20,	 200,	273,	 200 ,1); 
	Linexy(  20,	 50,	23,	 	 50 ,1);
	Linexy(	 20,	 100,	23,		 100, 1	);
	Linexy(	 20,	 150,	23,		 150,1);
	dprintf(15,10, StrForMixed1,1);	// 图形方式下中英文混合字符串的显示
	dprintf(3,42, "5V",1);
	starx=20;
	stary=200; 
//	WP=0; 
		for(i=0;i<count;i++)//读24c16,并将收到的数据还原
	{ 	  
			  AUXR=0x00; 			 
			  y1=y[i];
			  //y2= y[i+1];
			  AUXR=AUXR|2; 			
			  Point(starx, stary-y1, 1 ) ;
	//	Linexy(  20+starx,	 200-y1,	22+starx,200-y2	  ,1);	
		 starx=starx+1;
	} 
	delaym(300);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -