📄 lmb204bdc.c
字号:
#include "io.h"
#include "LMB204BDC.h"
//#include "key.h"
//#include "interrupt.h"
//
uchar idata tab0[20];
uchar idata tab1[20];
uchar idata tab2[20];
uchar idata tab3[20];
// 1 31 30 36 0%
uchar code tab_phrase1[]={0x31,0x33,0x31,0x33,0x30,0x33,0x36,0x30};//阶段,温度,湿度,时间,风门,排气门
uchar code tab_phrase2[]={0x32,0x33,0x36,0x33,0x33,0x34,0x38,0x32,0x30};
uchar code tab_phrase3[]={0x33,0x34,0x31,0x33,0x35,0x33,0x36,0x34,0x30};
uchar code tab_phrase4[]={0x34,0x34,0x37,0x33,0x36,0x33,0x36,0x36,0x30};
uchar code tab_phrase5[]={0x35,0x35,0x34,0x33,0x37,0x32,0x34,0x36,0x30};
uchar code tab_phrase6[]={0x36,0x36,0x32,0x33,0x39,0x32,0x34,0x31,0x30,0x30};
uchar code tab_phrase7[]={0x37,0x36,0x38,0x34,0x30,0x32,0x34,0x31,0x30,0x30};
uchar lcd_buf[4];
/*=======================================================
显示字符串
=======================================================*/
void ePutstr(uchar x,uchar y, uchar *ptr)
{
uchar i,l=0;
while (ptr[l] >31)
{
l++;
};
for (i=0;i<l;i++)
{
DispOneChar(x++,y,ptr[i]);
if ( x == 20 )
{
x = 0;
if(y<3)
y=y+1;
else
y=0;
}
}
}
/*=======================================================
演示一行连续字符串,配合上位程序演示移动字串
=======================================================*/
void Display(uchar posx,uchar posy, uchar *tab)
{
uchar i;
for (i=0;i<20;i++)
{
DispOneChar(posx++,posy,tab[i]);
}
}
/*=======================================================
显示光标定位
=======================================================*/
void LocateXY( uchar posx,uchar posy)
{
uchar temp;
temp = posx ;//& 0x13;
// posy &= 0x03;
if ( posy==1 )temp += 0x40;
if ( posy==2 )temp += 0x14;
if ( posy==3 )temp += 0x54;
temp |= 0x80;
LcdWriteCommand(temp,0);
}
/*=======================================================
按指定位置显示数出一个字符
=======================================================*/
void DispOneChar(uchar x,uchar y,uchar Wdata)
{
LocateXY( x, y ); // 定位显示地址
LcdWriteData(Wdata); // 写字符
}
/*=======================================================
初始化程序, 必须按照产品资料介绍的初始化过程进行
=======================================================*/
void LcdReset( void )
{
/* LcdWriteCommand( 0x38, 0); // 显示模式设置(不检测忙信号)
Delay5Ms();
LcdWriteCommand( 0x38, 0); // 共三次
Delay5Ms();
LcdWriteCommand( 0x38, 0);
Delay5Ms();*/
delay_ms(200);
LcdWriteCommand( 0x38, 1);
delay_ms(5);
LcdWriteCommand( 0x0c, 1); // 显示开及光标设
delay_ms(5);
LcdWriteCommand( 0x01, 1); // 显示清屏
delay_ms(5);
LcdWriteCommand( 0x06, 1); // 显示光标移动设置
delay_ms(5);
}
/*=======================================================
写控制字符子程序: E=1 RS=0 RW=0
=======================================================*/
void LcdWriteCommand( uchar CMD,uchar AttribC )
{
if (AttribC) WaitForEnable(); // 检测忙信号?
RS = 0;
RW = 0;
// _nop_();
Elcm = 1;
DataPort = CMD;
Elcm = 0;
_nop_(); // 送控制字子程序
_nop_();
_nop_();
// 操作允许脉冲信号
}
/*=======================================================
当前位置写字符子程序: E =1 RS=1 RW=0
=======================================================*/
void LcdWriteData( uchar dataW )
{
WaitForEnable(); // 检测忙信号
RS = 1;
RW = 0;
// _nop_();
Elcm = 1;
DataPort = dataW;
Elcm = 0;
_nop_();
_nop_();
_nop_();
// 操作允许脉冲信号
}
/*=======================================================
正常读写操作之前必须检测LCD控制器状态: CS=1 RS=0 RW=1
DB7: 0 LCD控制器空闲; 1 LCD控制器忙
========================================================*/
void WaitForEnable( void )
{
DataPort = 0xff;
RS =0;
RW = 1;
_nop_();
Elcm = 1;
while( DataPort & Busy );
Elcm = 0;
_nop_();
_nop_();
}
//****************************************************
//function: tu_1
//input :无
//output :无
//modify :2007-11-14
//****************************************************
void tu_1(void)
{
tran_tab0();
tran_tab1();
tran_tab2();
tran_tab3();
Display(0,0,tab0);
Display(0,1,tab1);
Display(0,2,tab2);
Display(0,3,tab3);
}
//****************************************************
//function: 给TAB0赋全值
//input
//output :
//modify :2007-11-14
//****************************************************
void tran_tab0(void)
{
wr_tab0(1,0x20);
wr_tab0(2,0x20);
wr_tab0(3,0x20); //主副模式切换
wr_tab0(4,0x30);
wr_tab0(5,0x30);
wr_tab0(6,0x2e);
wr_tab0(7,0x30);
wr_tab0(8,0xdf);
wr_tab0(9,0x43);
wr_tab0(10,0x20);
wr_tab0(11,0x20);
wr_tab0(12,0x54);
wr_tab0(13,0x30);
wr_tab0(14,0x31);
wr_tab0(15,0x32);
wr_tab0(17,0x33);
wr_tab0(18,0x34);
wr_tab0(16,0x2a); //:
wr_tab0(19,0x20);
}
//****************************************************
//function: 给TAB1赋全值
//input
//output :
//modify :2007-11-14
//****************************************************
void tran_tab1(void)
{
wr_tab1(0,0x49);
wr_tab1(1,0x54);
wr_tab1(2,0x20);
wr_tab1(3,0x20);
wr_tab1(4,0x33); //温度设置
// wr_tab1(4,tab_phrase1[1]);
wr_tab1(5,0x31);
//wr_tab1(5,tab_phrase1[2]);
wr_tab1(6,0x2e);
wr_tab1(7,0x30);
wr_tab1(8,0x20);
wr_tab1(9,0x20);
wr_tab1(10,0x20);
wr_tab1(11,0x20);
wr_tab1(12,0x50);
//wr_tab1(13,tab_phrase1[0]); //阶段号,可改
wr_tab1(13,0x30);
wr_tab1(14,0x20);
wr_tab1(15,0x20);
wr_tab1(16,0x20);
wr_tab1(17,0x20);
wr_tab1(18,0x20);
wr_tab1(19,0x20);
}
//****************************************************
//function: 给TAB0赋全值
//input
//output :
//modify :2007-11-14
//****************************************************
void tran_tab2(void)
{
wr_tab2(0,0x49);
wr_tab2(1,0x48);
wr_tab2(2,0x20); //湿度设置
wr_tab2(3,0x20);
wr_tab2(4,0x33);
wr_tab2(5,0x30);
// wr_tab2(4,tab_phrase1[3]);
//wr_tab2(5,tab_phrase1[4]);
wr_tab2(6,0x2e);
wr_tab2(7,0x30);
wr_tab2(8,0x20);
wr_tab2(9,0x20);
wr_tab2(10,0x20); //时间
wr_tab2(11,0x20);
wr_tab2(12,0x54);
wr_tab2(13,0x4d);
wr_tab2(14,0x35);
wr_tab2(15,0x36);
wr_tab2(16,0x3a);
wr_tab2(17,0x30);
wr_tab2(18,0x30);
wr_tab2(19,0x20);
}
//****************************************************
//function: 给TAB3赋全值
//input
//output :
//modify :2007-11-14
//****************************************************
void tran_tab3(void)
{
wr_tab3(0,0x48);
wr_tab3(1,0x44);
wr_tab3(2,0x20);
wr_tab3(3,0x20);
wr_tab3(4,0x30); //当前湿度值
wr_tab3(5,0x30);
wr_tab3(6,0x2e);
wr_tab3(7,0x30);
wr_tab3(8,0x20);
wr_tab3(9,0x20);
wr_tab3(10,0x20);
wr_tab3(11,0x20);
wr_tab3(12,0x56); //variety
wr_tab3(13,0x20);
wr_tab3(14,0x31);
wr_tab3(15,0x20);
wr_tab3(16,0x50); //part
wr_tab3(17,0x20);
wr_tab3(18,0x3a); //shang
wr_tab3(19,0x20);
}
//****************************************************
//function: write tab0
//input :i,j
//output :无
//modify :2007-11-14
//****************************************************
void wr_tab0(uchar i,uchar j)
{
tab0[i]=j;
}
//****************************************************
//function: write tab1
//input :i,j
//output :无
//modify :2007-11-14
//****************************************************
void wr_tab1(uchar i,uchar j)
{
tab1[i]=j;
}
//****************************************************
//function: write tab2
//input :i,j
//output :无
//modify :2007-11-14
//****************************************************
void wr_tab2(uchar i,uchar j)
{
tab2[i]=j;
}
//****************************************************
//function: write tab3
//input :i,j
//output :无
//modify :2007-11-14
//****************************************************
void wr_tab3(uchar i,uchar j)
{
tab3[i]=j;
}
// 短延时
void Delay5Ms(void)
{
uint i = 5552;
while(i--);
}
//长延时
/*void Delay400Ms(void)
{
uchar i = 5;
uint j;
while(i--)
{
j=7269;
while(j--);
};
}*/
void delay_ms(uint t) //延时T毫秒
{
uint i;
while(t--)
{
for(i=0;i<125;i++)
{;}
};
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -