附件为:LCD12864显示汉字和数字的程序与电路 /* 自定义延时子函数 */ void delayms(uchar z) { int x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } /* 判断LCD忙信号状态 */ void buys() { int dat; RW=1; RS=0; do { P0=0x00; E=1; dat=P0; E=0; dat=0x80 & dat; } while(!(dat==0x00)); } /* LCD写指令函数 */ void w_com(uchar com) { //buys(); RW=0; RS=0; E=1; P0=com; E=0; } /* LCD写数据函数 */ void w_date(uchar date) { //buys(); RW=0; RS=1; E=1; P0=date; E=0; } /* LCD选屏函数 */ void select_screen(uchar screen) { switch(screen) { case 0: //选择全屏 CS1=0; CS2=0; break; case 1: //选择左屏 CS1=0; CS2=1; break; case 2: //选择右屏 CS1=1; CS2=0; break; /* case 3: //选择右屏 CS1=1; CS2=1; break; */ } } /* LCDx向上滚屏显示 */ void lcd_rol() { int x; for(x=0;x<64;x++) { select_screen(0); w_com(0xc0+x); delayms(500); } } /* LCD清屏函数:清屏从第一页的第一列开始,总共8页,64列 */ void clear_screen(screen) { int x,y; select_screen(screen); //screen:0-选择全屏,1-选择左半屏,2-选择右半屏 for(x=0xb8;x<0xc0;x++) //从0xb8-0xbf,共8页 { w_com(x); w_com(0x40); //列的初始地址是0x40 for(y=0;y<64;y++) { w_date(0x00); } } } /* LCD显示汉字字库函数 */ void lcd_display_hanzi(uchar screen,uchar page,uchar col,uint mun) { //screen:选择屏幕参数,page:选择页参数0-3,col:选择列参数0-3,mun:显示第几个汉字的参数 int a; mun=mun*32; select_screen(screen); w_com(0xb8+(page*2)); w_com(0x40+(col*16)); for ( a=0;a<16;a++) { w_date(hanzi[mun++]); } w_com(0xb8+(page*2)+1); w_com(0x40+(col*16)); for ( a=0;a<16;a++) { w_date(hanzi[mun++]); } } /* LCD显示字符字库函数 */ void lcd_display_zifuk(uchar screen,uchar page,uchar col,uchar mun) { //screen:选择屏幕参数,page:选择页参数0-3,col:选择列参数0-7,mun:显示第几个汉字的参数 int a; mun=mun*16; select_screen(screen); w_com(0xb8+(page*2)); w_com(0x40+(col*8)); for ( a=0;a<8;a++) { w_date(zifu[mun++]); } w_com(0xb8+(page*2)+1); w_com(0x40+(col*8)); for ( a=0;a<8;a++) { w_date(zifu[mun++]); } } /* LCD显示数字字库函数 */ void lcd_display_shuzi(uchar screen,uchar page,uchar col,uchar mun) { //screen:选择屏幕参数,page:选择页参数0-3,col:选择列参数0-7,mun:显示第几个汉字的参数 int a; mun=mun*16; select_screen(screen); w_com(0xb8+(page*2)); w_com(0x40+(col*8)); for ( a=0;a<8;a++) { w_date(shuzi[mun++]); } w_com(0xb8+(page*2)+1); w_com(0x40+(col*8)); for ( a=0;a<8;a++) { w_date(shuzi[mun++]); } } /* LCD初始化函数 */ void lcd_init() { w_com(0x3f); //LCD开显示 w_com(0xc0); //LCD行初始地址,共64行 w_com(0xb8); //LCD页初始地址,共8页 w_com(0x40); //LCD列初始地址,共64列 } /* LCD显示主函数 */ void main() { //第一行 int x; lcd_init(); //LCD初始化 clear_screen(0); //LCD清屏幕 lcd_display_shuzi(1,0,4,5); //LCD显示数字 lcd_display_shuzi(1,0,5,1); //LCD显示数字 lcd_display_hanzi(1,0,3,0); //LCD显示汉字 lcd_display_hanzi(2,0,0,1); //LCD显示汉字 //LCD字符汉字 lcd_display_hanzi(2,0,1,2); //LCD显示汉字 //第二行 lcd_display_zifuk(1,1,2,0); //LCD显示字符 lcd_display_zifuk(1,1,3,0); //LCD显示字符 lcd_display_zifuk(1,1,4,0); //LCD显示字符 lcd_display_zifuk(1,1,5,4); //LCD显示字符 lcd_display_shuzi(1,1,6,8); //LCD显示字符 lcd_display_shuzi(1,1,7,9); //LCD显示字符 lcd_display_shuzi(2,1,0,5); //LCD显示字符 lcd_display_shuzi(2,1,1,1); //LCD显示字符 lcd_display_zifuk(2,1,2,4); lcd_display_zifuk(2,1,3,1); lcd_display_zifuk(2,1,4,2); lcd_display_zifuk(2,1,5,3); //第三行 for(x=0;x<4;x++) { lcd_display_hanzi(1,2,x,3+x); //LCD显示汉字 } for(x=0;x<4;x++) { lcd_display_hanzi(2,2,x,7+x); //LCD显示汉字 } //第四行 for(x=0;x<4;x++) { lcd_display_zifuk(1,3,x,5+x); //LCD显示汉字 } lcd_display_shuzi(1,3,4,7); lcd_display_shuzi(1,3,5,5); lcd_display_shuzi(1,3,6,5); lcd_display_zifuk(1,3,7,9); lcd_display_shuzi(2,3,0,8); lcd_display_shuzi(2,3,1,9); lcd_display_shuzi(2,3,2,9); lcd_display_shuzi(2,3,3,5); lcd_display_shuzi(2,3,4,6); lcd_display_shuzi(2,3,5,8); lcd_display_shuzi(2,3,6,9); lcd_display_shuzi(2,3,7,2); while(1); /* while(1) { // LCD向上滚屏显示 lcd_rol(); } */ }
上传时间: 2013-11-08
上传用户:aeiouetla
The PCA9541 is a 2-to-1 I2C-bus master selector designed for high reliability dual masterI2C-bus applications where system operation is required, even when one master fails orthe controller card is removed for maintenance. The two masters (for example, primaryand back-up) are located on separate I2C-buses that connect to the same downstreamI2C-bus slave devices. I2C-bus commands are sent by either I2C-bus master and are usedto select one master at a time. Either master at any time can gain control of the slavedevices if the other master is disabled or removed from the system. The failed master isisolated from the system and will not affect communication between the on-line masterand the slave devices on the downstream I2C-bus.
上传时间: 2013-10-09
上传用户:3294322651
MSP40-V1.2-CHS[1]微硅压力传感器。
上传时间: 2013-11-13
上传用户:ddddddd
Multisim.V10.0.1.汉化破解版图解
上传时间: 2013-11-02
上传用户:ArmKing88
Multisim.V10.0.1.汉化破解版图解
上传时间: 2014-03-31
上传用户:zcs023047
linux最原始的版本0.0.1版的源码
上传时间: 2014-01-19
上传用户:lanhuaying
cgal 3.0.1 的文挡
标签: cgal
上传时间: 2014-12-04
上传用户:qq21508895
用GAlib库实现的解决0/1背包问题的遗传算法程序源代码。
上传时间: 2014-03-02
上传用户:yangbo69
ARMBOOT源码1.0.1 ARM嵌入式开发启动通用代码.
上传时间: 2015-01-13
上传用户:坏坏的华仔
//产生0-1之间均匀分布一个随机数// /////////////////////////////////////////////////////////////// //传入参数:r--双精度实型变量指针,指向的单元存放随机数种子值//// //传出参数:p:产生0-1之间均匀分布一个随机数
上传时间: 2015-01-16
上传用户:cuiyashuo