/************************************************* *原型:void write_lcdbit(unsigned char bit) *功能:LCD送数 *说明:LCD-HT1622 数据在高锁存 *参数:bit *返回:无 **************************************************/ void write_lcdbit(unsigned char bit) { CLR_LCDWD; if(!bit) CLR_LCDDATA; SET_LCDWD; //数据在高锁存 SET_LCDDATA; } /************************************************* *原型:void write_lcdbyte(unsigned char addr,unsigned char data) *功能:LCD送数 *说明:LCD-HT1622 命令:101 100100 0101 *参数:addr 地址,data 数据 *返回:无 **************************************************/ void write_lcdbyte(unsigned char addr,unsigned char data) {//命令:101? //地址:000111 //数据:0001 unsigned char i; CLR_LCDCS; write_lcdbit(1); write_lcdbit(0); write_lcdbit(1); for(i=0;i<6;i++)//送地址 { write_lcdbit(addr&0x20); addr<<=1; } for(i=0;i<4;i++)//送数 { write_lcdbit(data&0x01); data>>=1; } SET_LCDCS; } /************************************************* *原型:void write_lcdcmd(unsigned char cmd) *功能:LCD送命令 *说明:LCD-HT1622 命令:101 10010 0101 *参数:unsigned char cmd *返回:无 **************************************************/ void write_lcdcmd(unsigned char cmd) { unsigned char i; CLR_LCDCS; write_lcdbit(1); write_lcdbit(0); write_lcdbit(0); for(i=0;i<8;i++) { write_lcdbit(cmd&0x80); cmd<<=1; } write_lcdbit(1); SET_LCDCS; } /************************************************* *原型:void update_lcd(unsigned char *p,unsigned char length) *功能:将显示缓冲区数据写入LCD ,长度为length *说明:LCD-HT1622 *参数:*p 指向显示缓冲区,length 显示缓冲区长度 *返回:无 **************************************************/ void update_lcd(unsigned char *p,unsigned char length) { unsigned char i,j; CLR_LCDCS; write_lcdbit(1); write_lcdbit(0); write_lcdbit(1); for(i=0;i<6;i++) { write_lcdbit(0); } for(i=0;i<length;i++) { for(j=0;j<8;j++) { write_lcdbit((*p)&0x01); (*p)>>=1; } p++; } SET_LCDCS; } |