步入正题,代码如下:
#include<reg52.h>
#include <stdlib.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define LCD_data P0
sbit col1=P1^7; //列端口定义
sbit col2=P1^6;
sbit col3=P2^0;
sbit col4=P2^1;
sbit LCD_EN=P3^4;
sbit LCD_RS=P3^5;
sbit LCD_RW=P3^6;
sbit LCD_PSB=P3^7;
uchar code dis0[]={"****智能控制****"};
uchar code dis1[]={"当前功能显示区"};
uchar code dis2[]={"当前水温:"};
uchar code dis3[]={"当前水位比: 50%"};
uchar code dis4[]={"按S17 开始上水"};
uchar code dis5[]={"目标水位比: 50%"};
uchar code dis6[]={"按 S5 停止上水"};
uchar code dis7[]={"上水中..."};
uchar code dis8[]={"按S18 开始加热"};
uchar code dis9[]={"目标水温:"};
uchar code dis10[]={"按 S6 停止加热"};
uchar code dis11[]={"加热中..."};
uchar code dis12[][10]={"51%","52%","53%","54%","55%","56%","57%","58%","59%","60%", //0-9
"61%","62%","63%","64%","65%","66%","67%","68%","69%","70%", //10-19
"71%","72%","73%","74%","75%","76%","77%","78%","79%","80%", //20-29
"81%","82%","83%","84%","85%","86%","87%","88%","89%","90%", //30-39
"91%","92%","93%","94%","95%","96%","97%","98%","99%","100%"};//40-49
uchar code dis13[][10]={"49%","48%","47%","46%","45%","44%","43%","42%","41%","40%",//0-9
"39%","38%","37%","36%","35%","34%","33%","32%","31%","30%"};//10-19
/*uchar code dis12[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00};//清行*/
void delay1ms(uint);
void dekay(uchar);
void keyscan();
void write_cmd(uchar cmd);
void write_dat(uchar dat);
void lcd_pos(uchar X,uchar Y);
void lcd_init();
uchar num,i,m,n,temp;
uint counter,a,counter1,b;
uint add0;
void main()//固定界面显示
{
//uint add0,add1,minus0,minus1;
delay1ms(10);
lcd_init();
lcd_pos(0,0);//智能控制
i=0;
while(dis0!='\0')
{
write_dat(dis0);
i++;
}
lcd_pos(1,0);//当前水温
i=0;
while(dis2!='\0')
{
write_dat(dis2);
i++;
}
lcd_pos(2,0);//当前水位比
i=0;
while(dis3!='\0')
{
write_dat(dis3);
i++;
}
lcd_pos(3,0);//当前功能显示区
i=0;
while(dis1!='\0')
{
write_dat(dis1);
i++;
}
delay1ms(10);
while(1)
{
//P1=0xff;
//P2=0xff;
//P3=0xff;
keyscan();
}
}
void delay1ms(uint x)//延时
{
uint i,j;
for(j=0;j<x;j++)
for(i=0;i<110;i++);
}
void delay(uchar i)//延时
{
uchar j,k;
for(j=i;j>0;j--)
for(k=125;k>0;k--);
}
|