/*----------------------------------------------------------------------------------------------------*/
//反显一个8*8字块
//lin:行(0-3), column: 列(0-7)
void ReverseShow88(unsigned char lin,unsigned char column)
{ unsigned char i;
unsigned char tab[8];
if(column<8) SelectScreen(1); //如果列数<4(0,1,2,3),则写在第一屏上
else SelectScreen(2); //否则 (4,5,6,7), 写在第二屏上
//读上部8列
column=column<<3; //每个方块8*8大小
SetLine(lin);
SetColumn(column);
tab[0]=ReadByte(); //空读!!!!! //?
for(i=0;i<8;i++) tab[i]=~ReadByte();
//写回
SetLine(lin);
SetColumn(column);
for(i=0;i<8;i++) WriteByte(tab[i]);
}
/*----------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------------------------------*/
//反显一个字符
//lin:行(0-4), column: 列(0-15)
void ReverseShowChar(unsigned char lin,unsigned char column)
{ lin=lin<<1;
ReverseShow88(lin ,column);
ReverseShow88(lin+1,column);
}
/*----------------------------------------------------------------------------------------------------*/
//反显一个汉字
//lin:行(0-3), column: 列(0-7)
ReverseShowHz(unsigned char lin,unsigned char column)
{
lin=lin<<1;
column=column<<1;
ReverseShow88(lin ,column );
ReverseShow88(lin ,column+1);
ReverseShow88(lin+1,column );
ReverseShow88(lin+1,column+1);
}
/*----------------------------------------------------------------------------------------------------*/
//反显一行汉字
//lin:行
ReverseShow(unsigned char lin)
{ unsigned char i;
for(i=0;i<8;i++) ReverseShowHZ(lin,i);
}
/*----------------------------------------------------------------------------------------------------*/
void InitLCD() //初始化LCD
{ unsigned char i=250; //延时
while(i--);
//reset=0;//复位
//reset=1;
SelectScreen(0);
SetOnOff(0); //关显示
ClearScreen(1);//清屏
ClearScreen(2);
SelectScreen(0);
SetOnOff(1); //开显示
SelectScreen(0);
SetStartLine(0); //开始行:0
}
/*----------------------------------------------------------------------------------------------------*/
void Reset() //液晶复位
{
//reset 低复位 _|-
reset=0;
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
reset=1;
//全屏
cs1=0;
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
cs2=0;
_nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_();
SendCommandToLCD(0x3F);
}
本文关键字:程序 51单片机,单片机-工控设备 - 51单片机