液晶显示温度控制系统.doc
- 文档编号:2494723
- 上传时间:2022-10-30
- 格式:DOC
- 页数:16
- 大小:91KB
液晶显示温度控制系统.doc
《液晶显示温度控制系统.doc》由会员分享,可在线阅读,更多相关《液晶显示温度控制系统.doc(16页珍藏版)》请在冰豆网上搜索。
/*****************************************************************************
系统名称:
液晶显示温度控制
设计者:
6月xin情
设计时间:
2011.04.29
版本:
versionV1.4
QQ:
454665741(欢迎交流学习)
版权所有,翻版必究
*********************************************************************************/
Main.c
#include"main.h"
#include"DS18B20.H"
#include"LCD1602.H"
#include"delay.h"
/***********************************宏定义***定义屏号*****************************/
#defineScreenTemperDisp1 //温度显示
#defineScreenMaxTemperSet2 //最大温度设定
#defineScreenMinTemperSet3 //最小温度设定
#defineScreenAddAlarm4 //加警显示
#defineScreenCancelAlarm5 //解警显示
#defineScreenAbnormalTemper6 //温度异常显示
#defineON1
#defineOFF0
/***********************************************************************************/
ucharScreenCode=ScreenTemperDisp; //当前屏号
ucharScreenCodeOld=ScreenMaxTemperSet; //旧屏号
ucharKeyCode=0;
ucharAlarmModeClose[]={"Close"};
ucharAlarmModeOpen[]={"Open"};
ucharAlarmFlag=OFF; //警报标志
ucharAbnormalFlag=OFF; //异常标志
signedintMaxTemperatureNew; //新最大温度
ucharMaxTemperNew[2];
signedintMaxTemperature=30;
ucharMaxTemper[2];
signedintMinTemperatureNew; //新最小温度
ucharMinTemperNew[2];
signedintMinTemperature=10;
ucharMinTemper[2];
floatRealTemper=0.0; //实时温度
sbitkey1=P2^0; //按键解码
sbitkey2=P2^1;
sbitkey3=P2^2;
sbitkey4=P2^3;
sbitkey5=P2^4;
sbitkey6=P2^5;
sbitkey7=P2^6;
sbitkey8=P2^7;
ucharKeyPress() //按键扫描
{
if(key1==0)
{
delay_ms
(1);
while(!
key1);
KeyCode=1;
}
if(key2==0)
{
delay_ms
(1);
while(!
key2);
KeyCode=2;
}
if(key3==0)
{
delay_ms
(1);
while(!
key3);
KeyCode=3;
}
if(key4==0)
{
delay_ms
(1);
while(!
key4);
KeyCode=4;
}
if(key5==0)
{
delay_ms
(1);
while(!
key5);
KeyCode=5;
}
if(key6==0)
{
delay_ms
(1);
while(!
key6);
KeyCode=6;
}
if(key7==0)
{
delay_ms
(1);
while(!
key7);
KeyCode=7;
}
if(key8==0)
{
delay_ms
(1);
while(!
key8);
KeyCode=8;
}
return(KeyCode);
}
voidKeyAsciii() //按键处理
{
switch(KeyCode)
{
case1:
{ScreenCode=ScreenTemperDisp;KeyCode=0;break;}
case2:
{ScreenCode=ScreenMaxTemperSet;KeyCode=0;break;}
case3:
{ScreenCode=ScreenMinTemperSet;KeyCode=0;break;}
case4:
{ScreenCode=ScreenAddAlarm;KeyCode=0;break;}
case5:
{ScreenCode=ScreenCancelAlarm;KeyCode=0;break;}
//case6:
ScreenCode=ScreenMaxTemperSet;break;
//case7:
ScreenCode=ScreenMaxTemperSet;break;
//case8:
ScreenCode=ScreenMaxTemperSet;break;
default:
KeyCode=0;break;
}
}
/***************************************最大温度设定****************************************/
voidMaxTemperSetScreen()
{
if(ScreenCode!
=ScreenCodeOld)
{
ScreenCodeOld=ScreenCode;
write_com(0X01);
DisplayString(0x00,0,"MaxTemperature");
DisplayString(0x04,1,"Set:
");
DisplaySingleChar(0x0a,1,'C');
//write_com(0x10);
write_com(0X0f); //光标闪烁
}
MaxTemper[0]=MaxTemperature/10;
MaxTemper[1]=MaxTemperature%10;
DisplaySingleChar(0x08,1,MaxTemper[0]+0X30); //动态显示
DisplaySingleChar(0x09,1,MaxTemper[1]+0X30);
write_com(0x10);
if(key6==0)
{
delay_ms
(1);
while(!
key6);
MaxTemperature+=1; //温度增加
if(MaxTemperature>99)
{
MaxTemperature=99; //最高99度
}
}
if(key7==0)
{
delay_ms
(1);
while(!
key7);
MaxTemperature-=1; //温度递减
if(MaxTemperature<=0)
{
MaxTemperature=0; //最低0度
}
}
if(key8==0) //设置温度
{
delay_ms
(1);
while(!
key8);
write_com(0X01); //清屏
delay_ms
(1);
write_com(0X0c); //无光标,不闪烁
delay_ms
(1);
write_com(0X0c); //无光标,不闪烁
DisplayString(0x00,0,"SetSuccessfully");
DisplayString(0x00,1,"MaxTemp:
");
MaxTemperatureNew=MaxTemperature; //设置新最大温度
MaxTemperNew[0]=MaxTemperatureNew/10;
MaxTemperNew[1]=MaxTemperatureNew%10;
DisplaySingleChar(0x0a,1,MaxTemperNew[0]+0X30); //显示新最大温度
DisplaySingleChar(0x0b,1,MaxTemperNew[1]+0X30);
DisplaySingleChar(0x0c,1,'C');
delay_ms(4000);
ScreenCode=ScreenTemperDisp;
}
}
/***********************************最小温度设定**************************************************/
voidMinTemperSetScreen() ///最小温度设定
{
if(ScreenCode!
=ScreenCodeOld)
{
ScreenCodeOld=ScreenCode;
write_com(0X01);
DisplayString(0x00,0,"MinTemperature");
DisplayString(0x04,1,"Set:
");
DisplaySingleChar(0x0a,1,'C');
//write_com(0x10);
write_com(0X0f);//光标显示
}
MinTemper[0]=MinTemperature/10;
MinTemper[1]=MinTemperature%10;
DisplaySingleChar(0x08,1,MinTemper[0]+0X30); //动态显示
DisplaySingleChar(0x09,1,MinTemper[1]+0X30);
write_com(0x10);
if(key6==0)
{
delay_ms
(1);
while(!
key6);
MinTemperature+=1; //温度增加
if(MinTemperature>99)
{
MinTemperature=99; //最高99度
}
}
if(key7==0)
{
delay_ms
(1);
while(!
key7);
MinTemperature-=1; //温度递减
if(MinTemperature<=0)
{
MinTemperature=0; //最低0度
}
}
if(ke
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 液晶显示 温度 控制系统