第一范文网 - 专业文章范例文档资料分享平台

电信学院 - GSM自控与报警系统 - 研究报告 - 图文

来源:用户分享 时间:2026/1/10 0:43:37 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

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((zhengshu0)/10+48); WriteData(zhengshu+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]);

电信学院 - GSM自控与报警系统 - 研究报告 - 图文.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c90t4a7ud544m0xd0pdw7_6.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top