⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd_chinese.h

📁 TLC549与液晶显示TLC549与液晶显示TLC549与液晶显示TLC549与液晶显示
💻 H
字号:
/************************************
*程序名:lcd_chinese.h
*功  能:清达液晶HG128642C-LY(带中文液晶字库)
		 动程序带字符串显示等基本函数
*
*作  者:       董志峰
*单  位:湖南理工物电系创新基地
*        All rights reseverd
*
*开始时间:2006.11.16
*结束时间:2006.11.20
*版本信息:
*
*注  备:
*************************************/

#ifndef _LCD_CHINESE_
	#define _LCD_CHINESE_

#include <reg52.h>
#include <intrins.h>
#include "delay.h"	

#define NULL ((void *) 0)	
#define DATABUS P2
sbit RS  = P1^0;
sbit RW  = P1^1;
sbit E   = P1^2;
sbit RST = P0^4;
//sbit speaker = P2^1;
void Delay1us(unsigned char);
void Delay1ms(unsigned int);
void Delay1s(unsigned int);

#ifndef _UNCHAR_
	#define _UNCHAR_
	typedef unsigned char unchar;
#endif

#ifndef _UNINT_
	#define _UNINT_
	typedef unsigned int unint;
#endif

/************************************
*函数名:void lcd_writbyte(char data,bit type)
*功  能:向lcd写入一字节
*输  入:
		 data:要写入的数据
		 type:选择方式(1为数据方式,0为命令方式)
*返  回:void
*************************************/
void lcd_writebyte(char dt,bit type)
{
	unsigned char busy;
	unsigned int wait = 0;
	RS = 0;
	RW = 1;
	do
	{
		E = 1;
		busy = DATABUS;
		E = 0;
		if(wait++ >	2500)  
			break;
	}while(busy&0x80);     //如果忙,一直等待
	if(type) 
	{
		RS = 1;			//写数据
		RW = 0;
	} 
    else 
	{
		RS = 0;			//写指令
		RW = 0;
	}    
	DATABUS = dt;
	E  = 1;
	E  = 0;
}

#if 0
/************************************
*函数名:char lcd_read(void)
*功  能:读取lcd
*输  入:void
*返  回:char
*************************************/
/*
char lcd_read(void)
{
	unsigned char dt;
	RS = 1;
	RW = 1;
	dt = DATABUS;
	E  = 1;
	E  = 0;
	RW = 1;
	return dt;
}*/
#endif

/************************************
*函数名:void lcd_init(void)
*功  能:初始化lcd
*输  入:void
*返  回:void
*************************************/
void lcd_init(void)
{
	Delay1ms(100);
	lcd_writebyte(0x30,0);//设定基本指令集
	Delay1us(100);
	lcd_writebyte(0x30,0);//设定基本指令集
	Delay1us(40);
	lcd_writebyte(0x0c,0);//显示开
	Delay1us(100);
	lcd_writebyte(0x01,0);//清除
	Delay1ms(20);
	lcd_writebyte(0x06,0);//设定AC+1
	Delay1us(100);
	lcd_writebyte(0x80,0);//设定起始地址
	Delay1us(100);
}

/************************************
*函数名:void lcd_CN(unsigned char x,unsigned char y,char *)
*功  能:显示汉字
*输  入:char *,unsigned char x,unsigned char y
		 汉字:x范围 0~7 y范围 0~3
		 英文:x范围 0~15 y范围 0~7
*返  回:void
*************************************/
void lcd_CN(unsigned char *buf,unsigned char x,unsigned char y)
{
	unsigned char adr;
	adr = (0x80+x);			
	switch(y)				
	{
		case 2:
			adr = adr+16;break;
		case 3:
			adr = adr+8;break;
		case 4:
			adr = adr+24;break;
		default:
			break;
	}
	lcd_writebyte(adr,0);  //设定DDRAM位址到位址计数器
	Delay1us(100);
	while((*buf)!='\0')		
	{
		lcd_writebyte(*(buf++),1);
		Delay1us(100);
	}
}
		 #if 0
/************************************
*函数名:void lcd_CN2(unsigned char (*buf)[],unsigned char x,unsigned char y)
*功  能:显示汉字
*输  入:char *,unsigned char x,unsigned char y
		 汉字:x范围 0~7 y范围 0~3
		 英文:x范围 0~15 y范围 0~7
*返  回:void
*注  备:用于2维字符数组
*************************************/
/*
void lcd_CN2(unsigned char (*buf)[],unsigned char x,unsigned char y)//看清声明形式!!!
{
	unsigned char adr;
	unchar i=0;
	adr = (0x80+x);			
	switch(y)				
	{
		case 2:
			adr = adr+16;break;
		case 3:
			adr = adr+8;break;
		case 4:
			adr = adr+24;break;
		default:
			break;
	}
	lcd_writebyte(adr,0);  //设定DDRAM位址到位址计数器
	Delay1us(100);
	while(*(*buf+i)!='\0')		
	{
		lcd_writebyte(*(*buf+i),1);
		i++;
		Delay1us(100);
	}
}

	
unsigned char *d = {"董dzf 志"};
unsigned char *z = {"zf"};
unsigned char *f = {"f"};
main()
{
	void (*p)() = &lcd_CN;
	lcd_init();
	lcd_CN(d,1,1);
	lcd_CN(z,2,2);
	lcd_CN(f,3,3);
	for(;;);
} */
	#endif

#endif



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -