Demo entry 6363553

py

   

Submitted by lu on May 14, 2017 at 04:42
Language: C. Code size: 1.0 kB.

void main() 
{ 

LCD_Init(); 
LCD_Clear();//清屏	



while (1) 
 {  
	 
		ReadyReadTemp_1();     //读温度准备
		TLP1=ReadOneChar_1();    //先读的是温度值低位
		THP1=ReadOneChar_1();    //接着读的是温度值高位
		TNP1=THP1*16+TLP1/16;      //实际温度值=(TH*256+TL)/16,即:TH*16+TL/16									
		TDP1=(TLP1%16)*10/16;    //计算温度的小数部分,将余数乘以10再除以16取整,
	 
		sprintf(str1, "Temp=%d.%dC",TNP1,TDP1);
		LCD_Write_String(0,0,&str1);
	 	sprintf(str2, "Set =%2dC",set);
		LCD_Write_String(0,1,&str2);
	 
		keynum=keyscan(0);
	 
		switch(keynum)
	  {
		case 1:	
							startflag=1;
							break;
		case 2:	
							if(startflag)
							{
								set+=1;
								if(set>=60)
								set=60;
							}
							break;
		case 3:	
							if(startflag)
							{
							set-=1;
							if(set<=0)
							set=0;
							}
							break;
		case 4:	
							startflag=0;
							break;
		
	 }
	 
	
	 if(TNP1>=set)
	 {
				beep=0;
		  	LCD_Write_String(12,1,"OFF");
	 }
	 else
	 {
		  	beep=1;
	    	LCD_Write_String(12,1,"ON ");

		}
			
	}
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).