/***************** 液晶ocm2x8c的子程序. ***************************/
uchar code HzTab_Array[]={ 0xb1,0xb1,0xbe,0xa9,0xca,0xb1,0xbc,0xe4, //cod=0;
0x20,0x20,0x32,0x30,0x20,0x20,0xc4,0xea, //北京时间:————年
0x20,0x20,0xd4,0xc2,0x20,0x20,0xc8,0xd5, //——月——日
0x20,0x20,0xca,0xb1,0x20,0x20,0xb7,0xd6, //--时--分
//cod=0x20;
// 0xb5,0xda,0x20,0x20,0xb1,0xed,0x3a,0x20, //第--表: -
// 0xb5,0xe7,0xc1,0xf7,0x20,0x20,0x20,0x20, //电流--ma
// 0xce,0xc2,0xb6,0xc8,0x20,0x20,0x63,0x20, //温度--c-
// 0xca,0xaa,0xb6,0xc8,0x20,0x20,0x25,0x20, //湿度--%-
// cod =0x20
0xb5,0xda,0x20,0x20,0xb1,0xed,0x20,0x20, // xx 表 I= 0x xx
0x49,0x3d,0x20,0x20,0x20,0x6d,0x41,0x20,
0x54,0x3d,0x20,0x20,0x43,0x20,0x48,0x3d, // T= xxc H= xx% -- --
0x20,0x20,0x25,0x20,0x5b,0x20,0x20,0x5d,
//cod=0x40;
0xb2,0xc9,0xbc,0xaf,0xc6,0xf7,0xc3,0xbb, //采集器没有应答
0xd3,0xd0,0xd3,0xa6,0xb4,0xf0,0x20,0x20,
//cod=0x50;
0xb4,0xab,0xca,0xe4,0xb3,0xc9,0xb9,0xa6, // 传输完成
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
//cod=0x60
0xb4,0xab,0xca,0xe4,0xca,0xa7,0xb0,0xdc, //传输失 0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
//cod=0x70
0xca,0xfd,0xbe,0xdd,0xb4,0xab,0xca,0xe4, // 数据传输中。。。
0xd6,0xd0,0x2e,0x2e,0x2e,0x20,0x20,0x20,
//cod=0x80;
0xd2,0xaa,0xc8,0xab,0xb2,0xbf,0xc7,0xe5, //要全部清除?
0xb3,0xfd,0x3f,0x20,0x20,0x20,0x20,0x20,
//cod=0x90;
0xc7,0xe5,0xb3,0xfd,0xcd,0xea,0xb3,0xc9, // 清除完成.
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
//cod =0xa0; 正在擦除中
0xd5,0xfd,0xd4,0xda,0xb2,0xc1,0xb3,0xfd,
0xd6,0xd0,0x2e,0x2e,0x2e,0x20,0x20,0x20,
//COD =0XB0; 擦除结束
0xb2,0xc1,0xb3,0xfd,0xbd,0xe1,0xca,0xf8,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
//cod=0xc0 传输超时.
0xb4,0xab,0xca,0xe4,0xb3,0xac,0xca,0xb1,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
//cod=0xd0 传输中有错误.
0xb4,0xab,0xca,0xe4,0xd6,0xd0,0xd3,0xd0,
0xb4,0xed,0xce,0xf3,0x20,0x20,0x20,0x20
};
//***********************************************
//;判断lcm是否忙。 ;读忙状态子程序
void Chk_Busy(void)
{
RS="0";
RW="1";
LCM_E=1;
while (P07==1);
LCM_E=0;
}
//**************************************************
//;write a byte to Lcm ;写数据子程序
void Displ(uchar i)
{
Chk_Busy(); //check the lcm busy
RS="1"; // data register
RW="0";
_nop_();
_nop_();
LCM_E=1;
P0=i;
i="1";delay_ms(i);
LCM_E=0;
P0=0xFF;
}
/*----------------------------------------------------
;写指令子程序
;----------------------------------------------------*/
void Input (uchar i)
{
Chk_Busy(); //check the lcm busy ;以确保上一指令/数据模块已经接收处理完
RS="0"; // data register
RW="0";
_nop_();
_nop_();
LCM_E=1;
P0=i;
i="3";
delay_ms(i);
LCM_E=0;
P0=0xFF;
}
/**************光标左移i bit ***********************/
void Sub_CursorLeftShift(uchar i)
{ uchar a;
// a="0x0f";
// Input(a);
do
{ a="0x10";
Input(a);
a="0x20";delay_ms(a);
i--;
}while(i!=0);
}
/*************光标右移 i bit************************/
void Sub_CursorRightShift(uchar i)
{ uchar a;
do
{a=0x14;
Input(a);
a="0x20";delay_ms(a);
i--;
}while(i!=0);
}
//****************************************************************************//
void Word_Disp1(uchar ah,uchar f_lin,uchar f_add) // 第几行,第几列,一行显示几个汉字,一共几行。
{uchar s_add; // value 在汉字数组中的起始位置。
uchar data w_wid;
s_add=0;
w_wid=0x08;
if (f_lin==1)
{s_add=0x80;
s_add=s_add+f_add;
Input(s_add);
}
if (f_lin==2)
{s_add=f_add+0x90;
Input(s_add);
}
do
{
Displ(HzTab_Array[ah]);
ah++;
Displ(HzTab_Array[ah]);
ah++;
w_wid--;
}while(w_wid!=0);
}
//********************************************************************
void Lcm_Initil(void)
{
uchar i;
i="5";
delay_ms(i);
i="0x30";
Input(i); // ;首先选择基本指令集
i="4";
delay_ms(i);
i="0x30";
Input(i);
i="3";
delay_ms(i);
i="0x30";
Input(i);
i="0x01";
Input(i); //;指令#01H为:清除屏幕文字,把地址指针指向00H单元
i="0x03";
delay_ms(i);
i="0x06"; // 整体显示不移动
Input(i);
i="0x03";
delay_ms(i); //;指定在资料写入或读取时,设定游标的移动方向及指定显示的移位
}
//********************************************************/
文章评论(0条评论)
登录后参与讨论