您好,欢迎访问三七文档
当前位置:首页 > 行业资料 > 酒店餐饮 > LCD12864温度曲线显示
#includereg51.h#includeLCD12864.hvoidhua_zuobiao(void);//画坐标voiddelay1ms(uintk);//延时间voidTLC2543(void);//2543读数据子函数voidcount_ad(void);//1602的显示ucharcodeshuzi[]={0x00,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};//0--8ucharcodenumber[]={0123456789};uchartab1[]={wendu=+49.99c};//910.1213ucharcodetab2[]={madeofsuwei};unsignedlongintad;///////////////////TLC2543sbitclk=P1^3;//时钟sbitcs=P1^2;//1变0时TLC2543复位sbitadtain=P1^1;//数据输入sbitadtaout=P1^0;//数据输出////////////////voidmain(void){ucharx,y;//x页y列uchari;uintj;ucharwendu=30,dp;//温度//曲线的点///////////1602init_1602();gotoxy(1,0);for(i=0;i16;i++)write_LCD_data(tab1[i]);gotoxy(2,0);for(i=0;i16;i++)write_LCD_data(tab2[i]);///////////////12864LCDiniti_LCD();//hua_zuobiao();//画坐标图y=12;//从12列开始while(1){TLC2543();//2543读数据子函数count_ad();//lcd1602的更新显示delay1ms(1);j++;if(j50){j=0;wendu=ad/100;//取温度的前2位x=(wendu-1)/8;=6-x;dp=(wendu-1)%8+1;if(y64){set_adr(x,y);wdata(shuzi[dp],1,0);}else{set_adr(x,y-64);wdata(shuzi[dp],0,1);}y++;//列if(y==128){y=12;//clear();//清屏hua_zuobiao();//画坐标图}/////////////*i=0;initi_LCD();hua_zuobiao();//画坐标set_adr(3,12);y=3;c=13;while(1){i++;c++;if(i==8){i=0;y=y-1;if(y==0)y=7;temp=0xb8+y;wcode(temp,1,1);}if(c==64)set_adr(temp,0);if(c=127)while(1);if(c=64)wdata(shuzhi[i],0,1);elsewdata(shuzhi[i],1,0);delay1ms(100);}}*////////////////}//}////1602的显示voidcount_ad(void){uchari;uinttemp;temp=ad;tab1[13]=number[temp%10];temp=temp/10;tab1[12]=number[temp%10];temp=temp/10;tab1[10]=number[temp%10];temp=temp/10;tab1[9]=number[temp%10];gotoxy(1,0);for(i=0;i16;i++)write_LCD_data(tab1[i]);}//////////////////////////////////voidTLC2543(void)//2543读数据子函数{uchari;//输入数据为0x00//0x10为第一通道ad=0;clk=0;cs=0;for(i=0;i12;i++){if(adtaout==1)ad=ad|0x01;//读出数据adtain=0;//写入数据clk=1;clk=0;ad=1;//左移一位}cs=1;ad=1;//数据存在ad里ad=(ad*1000)/819;//temp=(ad*5000)/4095;}///////////////////////////voidhua_zuobiao(void)//画坐标{ucharj;inti;for(j=0;j8;j++)//页码{set_adr(j,0);for(i=1;i=64;i++){wdata(zuobiao[i+j*128],1,0);wdata(zuobiao[63+i+j*128],0,1);}}}////////////////////////voiddelay1ms(uintk)//延时间{k=k*125;while(--k);}////////////调用子程序#includereg51.h#define_LCD12864_h#defineucharunsignedchar#defineuintunsignedintvoiddelay(uintk);//延时voidwcode(ucharcom,ucharcs1,ucharcs2);//写指令voidwdata(ucharda,ucharcs1,ucharcs2);//写数据voidset_startline(uchari);//起始行voidset_adr(ucharx,uchary);//voidclear(void);///clear清屏voidiniti_LCD(void);//初始化LCD//////////单片机与液晶显示的引脚连接///////////sbitRST=P2^2;sbitCS2=P2^0;sbitCS1=P2^1;sbitRS=P2^2;//或DIsbitRW=P2^3;sbitE=P2^4;//P0口为数据口//////////////////////////////voidiniti_LCD(void)//初始化LCD{wcode(0x3f,1,1);//显示开//0x3e关set_startline(0);//起始行第0行clear();//清屏}///////////////////////voiddelay(uintk)//延时{while(k--);}////////复位////////////*voidreset(){RST=0;delay(200);RST=1;delay(200);}*/////////writecode写指令///////(ucharcom,ucharcs1,ucharcs2)//写指令{CS1=cs1;CS2=cs2;RW=0;RS=0;P0=com;E=0;delay(10);E=1;delay(10);E=0;}/////////writedata写数据///////////////voidwdata(ucharda,ucharcs1,ucharcs2)//写数据{CS1=cs1;CS2=cs2;RW=0;RS=1;P0=da;E=0;delay(10);E=1;delay(10);E=0;}////////////setstart设置起始行/////////////voidset_startline(uchari)//起始行。11A5A4A3A2A1A0共有64行{//液晶显示器的最底层为第0行i=0xc0+i;//此算法为把最顶层做为第一层wcode(i,1,1);}///////////////////////////////voidset_adr(ucharx,uchary)//{x=x+0xb8;//行//页地址设置。10111A2A1A0DDRAM的8A0~A2LCD为64行8页y=y+0x40;//列地址设置。01A5A4A3A2A1A0两半屏分别有64A0~A5送入列地址计数//Y向下一列DDRAM单元wcode(x,1,1);wcode(y,1,1);}///////////clear清屏///////////////(void)///clear清屏{uchari,loop;for(i=0;i8;i++)///循环页写0/////////{set_adr(i,0);//页码//行for(loop=0;loop64;loop++)wdata(0x00,1,1);//列//左右屏幕同时写//}}调用子程序#includereg51.h#define_zimo_h#defineucharunsignedchar#defineuintunsignedint///////////////////////////////////////////////////////////////////////////汉字字模表////汉字库:宋体16.dot纵向取模下高位,数据排列:从左到右从上到下////字节倒置ucharcodezuobiao[]={/*--C:\DocumentsandSettings\Administrator\桌面\温度坐标.bmp--*//*--宽度x高度=128x64--*/0x00,0x00,0x00,0x70,0x50,0xD0,0x00,0xF0,0x10,0xF0,0x00,0xFF,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC1,0x01,0xC1,0x00,0xC1,0x41,0xC1,0x00,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
本文标题:LCD12864温度曲线显示
链接地址:https://www.777doc.com/doc-1358182 .html