#ifndef _LCD12864_INCLUDED_
#define _LCD12864_INCLUDE
#include "common.h"
/**************************************************************
iO口宏定义区
***************************************************************/
sbit CS =P2^2;
sbit SID=P2^3;//r/w
sbit SCK=P2^4;//e
/*******************************************************************
常量声明区
********************************************************************/
unsigned char code AC_TABLE[]={ //坐标编码
0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,
0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,
0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,
0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f,
};
/****************************************************************
声明:建议读者先查阅我们提供的12864word文档资料,理解12864定坐标的
方式。
发送一个字节
*****************************************************************/
void SendByte(unsigned char Dbyte)
{
unsigned char i;
for(i=0;i<8;i++)
{
SCK = 0;
Dbyte=Dbyte<<1;
SID = CY;
SCK = 1;
SCK = 0;
}
}
/**********************************************************
接收一个字节
***********************************************************/
unsigned char ReceiveByte(void)
{
unsigned char i,temp1,temp2;
temp1=temp2=0;
for(i=0;i<8;i++)
{
temp1=temp1<<1;
SCK = 0;
SCK = 1;
SCK = 0;
if(SID) temp1++;
}
for(i=0;i<8;i++)
{
temp2=temp2<<1;
SCK = 0;
SCK = 1;
SCK = 0;
if(SID) temp2++;
}
return ((0xf0&temp1)+(0x0f&temp2));
}
/****************************************************************
检查忙状态
******************************************************************/
void CheckBusy( void )
{
do SendByte(0xfc); //11111,RW(1),RS(0),0
while(0x80&ReceiveByte());
}
/******************************************************************
写一个字节的指令
*******************************************************************/
void WriteCommand( unsigned char Cbyte )
{
CS = 1;
CheckBusy();
SendByte(0xf8); //11111,RW(0),RS(0),0
SendByte(0xf0&Cbyte);
SendByte(0xf0&Cbyte<<4);
CS = 0;
}
/*************************************************************
写一个字节的数据
**************************************************************/
void WriteData( unsigned char Dbyte )
{
CS = 1;
CheckBusy();
SendByte(0xfa); //11111,RW(0),RS(1),0
SendByte(0xf0&Dbyte);
SendByte(0xf0&Dbyte<<4);
CS = 0;
}
/******************************************************************
lcd初始化函数
*******************************************************************/
void LcmInit( void )
{
WriteCommand(0x30);
WriteCommand(0x03);
WriteCommand(0x0c);
WriteCommand(0x01);
WriteCommand(0x06);
}
/*******************************************************************************************************
设定光标函数
********************************************************************************************************/
void Location_xy_12864(unsigned char x,unsigned char y)
{
switch(x)
{
case 0:
x=0x80;break;
case 1:
x=0x90;break;
case 2:
x=0x88;break;
case 3:
x=0x98;break;
default:
x=0x80;
}
y=y&0x07;
WriteCommand(0x30);
WriteCommand(y+x);
WriteCommand(y+x);
}
/***********************************************************************************
清除文本
************************************************************************************/
void LcmClearTXT( void )
{
unsigned char i;
WriteCommand(0x30);
WriteCommand(0x80);
for(i=0;i<64;i++)
WriteData(0x20);
Location_xy_12864(0,0);
}
/**************************************************************************************
清除图片
*****************************************************************************************/
void LcmClearBMP( void )
{
unsigned char i,j;
WriteCommand(0x34);
WriteCommand(0x36);
for(i=0;i<32;i++)
{
WriteCommand(0x80|i);
WriteCommand(0x80);
for(j=0;j<32;j++)
WriteData(0);
}
}
//显示温度
void PutTemp(unsigned char row,unsigned char col)
{
WriteCommand(0x30);
WriteCommand(AC_TABLE[8*row+col]);
WriteData((zhengshu%100)/10+48);
WriteData(zhengshu%10+48);
WriteData('.');
WriteData(xiaoshu1+48);
}
/****************************************************************************************
显示字符串
*****************************************************************************************/
void PutStr(unsigned char row,unsigned char col,unsigned char *puts)
{
WriteCommand(0x30);
WriteCommand(AC_TABLE[8*row+col]);
while(*puts != '\0')
{
if(col==8)
{
col=0;
row++;
}
if(row==4) row=0;
WriteCommand(AC_TABLE[8*row+col]);
WriteData(*puts);
puts++;
if(*puts != '\0')
{
WriteData(*puts);
puts++;
col++;
}
}
}
/*
//显示一个四位的数字
void PutNum(unsigned char row,unsigned char col,unsigned int num)
{
WriteCommand(0x30);
WriteCommand(AC_TABLE[8*row+col]);
WriteData((num/1000)+48);
WriteData(((num%1000)/100)+48);
WriteData(((num%100)/10)+48);
WriteData((num%10)+48);
}*/
//显示一个两位的数字
void PutTime(void)
{
WriteCommand(0x30);
WriteCommand(AC_TABLE[19]);
WriteData(((times[6]%100)/10)+48);
WriteData((times[6]%10)+48);
WriteData('/');
WriteData(((times[4]%100)/10)+48);
WriteData((times[4]%10)+48);
WriteData('/');
WriteData(((times[3]%100)/10)+48);
WriteData((times[3]%10)+48);
WriteCommand(0x30);
WriteCommand(AC_TABLE[27]);
WriteData(((times[2]%100)/10)+48);
WriteData((times[2]%10)+48);
WriteData(':');
WriteData(((times[1]%100)/10)+48);
WriteData((times[1]%10)+48);
WriteData(':');
WriteData(((times[0]%100)/10)+48);
WriteData((times[0]%10)+48);
}
#endif
没有合适的资源?快使用搜索试试~ 我知道了~
单片机做主控检测温度并通过GSM报警
共32个文件
obj:7个
c:7个
lst:7个
需积分: 0 0 下载量 130 浏览量
2023-06-11
22:36:06
上传
评论
收藏 97KB ZIP 举报
温馨提示
单片机做主控,ds18b20采集温度,lcd1602进行显示,GSM进行短信报警
资源推荐
资源详情
资源评论
收起资源包目录
GSM室温监控系统.zip (32个子文件)
GSM室温监控系统
TC35.OBJ 12KB
GSM.hex 11KB
red.c 3KB
GSM.plg 173B
ds1302.LST 7KB
ds1302.OBJ 8KB
ds1302.c 4KB
USART.LST 3KB
main.OBJ 14KB
TC35.LST 7KB
GSM.M51 56KB
ds18b20.OBJ 8KB
GSM_Opt.Bak 2KB
GSM.uvproj 14KB
red.LST 6KB
LCD12864.LST 11KB
GSM.build_log.htm 1KB
USART.c 997B
main.LST 10KB
LCD12864.OBJ 13KB
GSM.uvopt 11KB
red.OBJ 6KB
ds18b20.c 3KB
GSM.lnp 126B
TC35.c 4KB
GSM.uvgui.Liujiaqi 73KB
USART.OBJ 6KB
GSM 57KB
ds18b20.LST 6KB
LCD12864.c 6KB
main.c 6KB
COMMON.h 2KB
共 32 条
- 1
资源评论
复活的世外猫
- 粉丝: 37
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功