lcd5110驱动程序代码(avr单片机)

上传人:子 文档编号:43107211 上传时间:2018-06-04 格式:DOC 页数:14 大小:18.46KB
返回 下载 相关 举报
lcd5110驱动程序代码(avr单片机)_第1页
第1页 / 共14页
lcd5110驱动程序代码(avr单片机)_第2页
第2页 / 共14页
lcd5110驱动程序代码(avr单片机)_第3页
第3页 / 共14页
lcd5110驱动程序代码(avr单片机)_第4页
第4页 / 共14页
lcd5110驱动程序代码(avr单片机)_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《lcd5110驱动程序代码(avr单片机)》由会员分享,可在线阅读,更多相关《lcd5110驱动程序代码(avr单片机)(14页珍藏版)》请在金锄头文库上搜索。

1、LCD5110LCD5110 驱动程序代码驱动程序代码(AVR(AVR 单片机单片机) )/*84*48 点阵 X:0-83 点,Y:0-5 行英文字符:全屏显示:6 行*14 列每个字符:宽 6 点*高 8 点中文字符:全屏显示:4 行*7 列每个字符:宽 12 点*高 11 点LCD_init(); /初始化液晶 LCD_clear(); /清屏LCD_set_XY(0,1); /X 行,Y 点,设定坐标LCD_write_char(V); /写字符LCD_write_english_sendbyte(4,3,dingwei); /X 行,Y 点,字符LCD_write_english_s

2、endstr(3,2,“TEST“); /X 行,Y 点,字符串LCD_write_chinese_string(0,5,12,2,0,0); /X 行,Y 列,宽度,个数,点阵数组起始行数,行间距LCD_draw_bmp_pixel(0,32,AVR_bmp,48,24); /X 行,Y 点,位图点阵数据变量,长,宽*/ Define I/O pins #define LCD_PORT PORTC#define LCD_DIR DDRC#define LCD_IN PINC#define CLK PC4 /CLK 串行时钟线#define DIN PC3 /DIN 串行数据线#define

3、DC PC2 /DC 数据/指令选择#define CE PC1 /CE 片选#define RST PC0 /RST 复位#define SCLK BIT(CLK)#define SDIN BIT(DIN)#define LCD_DC BIT(DC)#define LCD_CE BIT(CE)#define LCD_RST BIT(RST)/enable global interrupts#define GIE (SREG |= BIT(7)/disable global interrupts#define GID (SREG void LCD_init(void);void LCD_cle

4、ar(void);void delay_1us(void); void LCD_set_XY(unsigned char x,unsigned char y);void LCD_write_char(unsigned char c);void LCD_write_english_sendstr(unsigned char X,unsigned char Y,char *s);void LCD_write_english_sendbyte(unsigned char X,unsigned char Y,unsigned char dByte);void LCD_write_chinese_str

5、ing(unsigned char X, unsigned char Y,unsigned char ch_with,unsigned char num,unsigned char line,unsigned char row);void LCD_draw_bmp_pixel(unsigned char X,unsigned char Y,unsigned char *map,unsigned char Pix_x,unsigned char Pix_y);void LCD_write_byte(unsigned char dat, unsigned char command);/*/ voi

6、d LCD_init(void)/先设置为输出SETBIT(LCD_DIR,SCLK);SETBIT(LCD_DIR,SDIN);SETBIT(LCD_DIR,LCD_DC);SETBIT(LCD_DIR,LCD_CE);SETBIT(LCD_DIR,LCD_RST);/ 产生一个让 LCD 复位的低电平脉冲CLEARBIT(LCD_PORT,LCD_RST);/LCD_RST = 0;delay_1us();SETBIT(LCD_PORT,LCD_RST);/LCD_RST = 1;/ 关闭 LCDCLEARBIT(LCD_PORT,LCD_CE);/LCD_CE = 0;delay_1us

7、();/ 使能 LCDSETBIT(LCD_PORT,LCD_CE);/LCD_CE = 1;delay_1us();LCD_write_byte(0x21, 0);/ 使用扩展命令设置 LCD 模式LCD_write_byte(0xc8, 0);/ 设置偏置电压LCD_write_byte(0x06, 0);/ 温度校正LCD_write_byte(0x13, 0);/ 1:48LCD_write_byte(0x20, 0);/ 使用基本命令LCD_clear(); / 清屏LCD_write_byte(0x0c, 0);/ 设定显示模式,正常显示/ 关闭 LCDCLEARBIT(LCD_P

8、ORT,LCD_CE); /LCD_CE = 0;/*/void LCD_clear(void)unsigned int i;LCD_write_byte(0x0c, 0);LCD_write_byte(0x80, 0);for (i=0; i504; i+)LCD_write_byte(0, 1);/*/void delay_1us(void) /1us 延时函数unsigned int i;for(i=0;i12000;i+);/*/void LCD_set_XY(unsigned char X, unsigned char Y)LCD_write_byte(0x40 | X, 0);/

9、row 行LCD_write_byte(0x80 | Y, 0);/ column 列/*/void LCD_write_char(unsigned char c)unsigned char line;c -= 32;for (line=0; line6; line+)LCD_write_byte(font6x8cline, 1);/*/*-LCD_write_english_sendstr : 英文字符串显示函数输入参数:*s :英文字符串指针;X、Y : 显示字符串的位置,x 0-5 ,y 0-83-*/void LCD_write_english_sendstr(unsigned cha

10、r X,unsigned char Y,char *s)LCD_set_XY(X,Y);while (*s) LCD_write_char(*s);s+;/*/*-LCD_write_english_sendbyte : 英文字符显示函数输入参数:*s :英文字符串指针;X、Y : 显示字符串的位置,x 0-5 ,y 0-83-*/void LCD_write_english_sendbyte(unsigned char X,unsigned char Y,unsigned char dByte)LCD_set_XY(X,Y);LCD_write_char(dByte);/*/*-LCD_wr

11、ite_chinese_string: 在 LCD 上显示汉字输入参数:X、Y :显示汉字的起始 X、Y 坐标;ch_with :汉字点阵的宽度num :显示汉字的个数; line :汉字点阵数组中的起始行数row :汉字显示的行间距-*/ void LCD_write_chinese_string(unsigned char X, unsigned char Y,unsigned char ch_with,unsigned char num,unsigned char line,unsigned char row)unsigned char i,n;LCD_set_XY(X,Y); /设置初

12、始位置for (i=0;inum;)for (n=0; nch_with*2; n+) /写一个汉字 if (n=ch_with) /写汉字的下半部分if (i=0) LCD_set_XY(X+1,Y);elseLCD_set_XY(X+1,(Y+(ch_with+row)*i);LCD_write_byte(HZKline+in,1);i+;LCD_set_XY(X,(Y+(ch_with+row)*i);/*/*-LCD_draw_map : 位图绘制函数输入参数:X、Y :位图绘制的起始 X、Y 坐标;*map :位图点阵数据;Pix_x :位图像素(长)Pix_y :位图像素(宽)-*/void LCD_draw_bmp_pixel(unsigned char X,unsigned char Y,unsigned char *map,unsigned char Pix_x,unsigned char Pix_y)unsigned int i,n;unsigned char row;if (Pix_y%8=0)row=Pix_y/8

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 科普知识

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号