文档详情

【2017年整理】诺基亚5110显示屏51单片机驱动程序2.doc

发布:2017-01-26约2.32万字共9页下载文档
文本预览下载声明
诺基亚5110显示屏51单片机驱动程序 #include stc.h #include intrins.h //_nop_();延时函数用 #include dmb.h //字符代码表 #define uchar unsigned char #define uint unsigned int sbit sce = P3^4; //片选 sbit res = P0^0; //复位,0复位 sbit dc = P3^5; //1写数据,0写指令 sbit sdin = P3^7; //数据 sbit sclk = P3^6; //时钟 uint data temp_data[2]={0x00,0x00}; //读出温度暂放 //================18b20数据口定义=============== sbit DQ=P0^0; //温度输入口 uint h; uint temp; unsigned char presence,flash=0; /*****************延时函数*************************/ void delay(uint t) { for (;t0;t--); } //================延时函数===================== void delay_1ms(void)//1ms延时函数 { unsigned int i; for (i=0;i500;i++); } /*lcd显示函数开始 LCD_write_byte: 使用SPI接口写数据到LCD 输入参数:dt:写入的数据; command :写数据/命令选择; 编写日期*/ void LCD_write_byte(unsigned char dt, unsigned char command) { unsigned char i; sce=0; dc=command; for(i=0;i8;i++) { if(dt0x80) sdin=1; else sdin=0; dt=dt1; sclk=0; sclk=1; } dc=1; sce=1; sdin=1; } /* LCD_init: 5110LCD初始化 编写日期 */ void LCD_init(void) { res=0; delay_1ms(); res=1; LCD_write_byte(0x21,0);//初始化Lcd,功能设定使用扩充指令 LCD_write_byte(0xd0,0);//设定液晶偏置电压 LCD_write_byte(0x20,0);//使用基本指令 LCD_write_byte(0x0C,0);//设定显示模式,正常显示 } /* LCD_set_XY: 设置LCD坐标函数 输入参数:X:0-83 Y:0-5 编写日期*/ void LCD_set_XY(unsigned char X, unsigned char Y) { LCD_write_byte(0x40 | Y, 0);// column LCD_write_byte(0x80 | X, 0);// row } /* LCD_clear: LCD清屏函数 编写日期*/ void LCD_clear(void) { unsigned char t; unsigned char k; LCD_set_XY(0,0); for(t=0;t6;t++) { for(k=0;k84;k++) { LCD_write_byte(0x00,1); } } } /* LCD_write_shu: 显示8(宽)*16(高)点阵列数字字母符号等半角类 输入参数:c:显示的字符; 编写日期*/ void LCD_write_shu(unsigned char row, unsigned char page,unsigned char c) //row:列 page:页 dd:字符 { unsigned char i; LCD_set_XY(row*8, page);// 列,页 for(i=0; i8;i++) { LCD_write_byte(shuzi[c*16+i],1); } LCD_set_XY(row*8,
显示全部
相似文档