51單片機(jī)總線驅(qū)動(dòng) 作者: 時(shí)間:2016-11-29 來(lái)源:網(wǎng)絡(luò) 加入技術(shù)交流群 掃碼加入和技術(shù)大咖面對(duì)面交流海量資料庫(kù)查詢 收藏 /************************************************發(fā)出命令控制 參數(shù) 低onedat 高twodat 命令com*************************************************/void lcd_writecom_two(uchar onedat,uchar twodat,uchar com){lcd_writedat(onedat);lcd_writedat(twodat);lcd_writecom(com);}/**********************************************一次寫(xiě)一個(gè)數(shù)據(jù) 對(duì)應(yīng)地址指針位置**********************************************/void lcd_writedat_onebyte(uchar onedat,uchar com){lcd_writedat(onedat);lcd_writecom(com);}/**********************************************一次讀一個(gè)數(shù)據(jù) 對(duì)應(yīng)地址指針位置**********************************************/uchar lcd_readdat_onebyte(uchar com){uchar dat;lcd_writecom(com);dat=lcd_readdat();return dat;}/****************************************一次寫(xiě)n個(gè)數(shù)據(jù) 對(duì)應(yīng)地址指針位置****************************************/void lcd_writedat_nbyte(uchar *dat,uchar len){lcd_writecom(0xb0);check_auto_write_busy();while(len){lcd_writedat(*dat);dat++;len--;}lcd_writecom(0xb2);}/****************************************一次讀n個(gè)數(shù)據(jù) 對(duì)應(yīng)地址指針位置****************************************/void lcd_readdat_nbyte(uchar *dat ,uchar len){lcd_writecom(0xb1);check_auto_read_busy();while(len){*dat=lcd_readdat();dat++;len--;}lcd_writecom(0xb2);}/************************************************清除一個(gè)點(diǎn)坐標(biāo) X,Y 左上角第一個(gè)點(diǎn)為0,0************************************************/void clear_point(uchar x,uchar y){uint addr;uchar temp1,temp2;addr=(y<<5)+(y<<3)+(x>>3);//32+8temp1=addr;//&0x00ff;temp2=addr>>8;lcd_writecom_two(temp1,temp2,0x24);lcd_writecom(0xf7-(x&0x07));}/************************************************點(diǎn)亮一個(gè)點(diǎn) 坐標(biāo) X,Y 左上角第一個(gè)點(diǎn)為0,0************************************************/void sel_point(uchar x,uchar y){uint addr;uchar temp1,temp2;addr=(y<<5)+(y<<3)+(x>>3);//32+8temp1=addr;//&0x00ff;temp2=addr>>8;lcd_writecom_two(temp1,temp2,0x24);lcd_writecom(0xff-(x&0x07));}/*************************************************畫(huà)中等大小的點(diǎn) 4*4(用畫(huà)點(diǎn)方法 效率低)*************************************************//*sel_middling(uchar x,uchar y){uint addr;uchar temp1,temp2,n;addr=y*160+(x>>1);//x/8*4;for(n=0;n<4;n++){temp1=addr%6;temp2=addr>>8;lcd_writecom_two(temp1,temp2,0x24);if(x%2){lcd_writecom(0xfb);lcd_writecom(0xfa);lcd_writecom(0xf9);lcd_writecom(0xf8);}else{lcd_writecom(0xff);lcd_writecom(0xfe);lcd_writecom(0xfd);lcd_writecom(0xfc);}addr+=40;}}*//*************************************************畫(huà)中等大小的點(diǎn) 4*4(用讀修改寫(xiě) 效率高)*************************************************/void sel_rmiddling(uchar x,uchar y){uint addr;uchar temp1,temp2,n,dat;addr=(y<<7)+(y<<5)+(x>>1);//x/8*4;//128+32for(n=0;n<4;n++){temp1=addr;//&0x0ff;temp2=addr>>8;lcd_writecom_two(temp1,temp2,0x24);if(x&0x01)//x%2{dat=(lcd_readdat_onebyte(0xc5))|0x0f;lcd_writedat_onebyte(dat,0xc4);}else{dat=(lcd_readdat_onebyte(0xc5))|0xf0;lcd_writedat_onebyte(dat,0xc4);}addr+=40;}}/*************************************************清楚中等大小的點(diǎn) 4*4(用清點(diǎn)方式 效率底)*************************************************//*clr_middling(uchar x,uchar y){uint addr;uchar temp1,temp2,n;addr=y*160+(x>>1);//x/8*4;for(n=0;n<4;n++){temp1=addr%6;temp2=addr>>8;lcd_writecom_two(temp1,temp2,0x24);if(x%2){lcd_writecom(0xf3);lcd_writecom(0xf2);lcd_writecom(0xf1);lcd_writecom(0xf0);}else{lcd_writecom(0xf7);lcd_writecom(0xf6);lcd_writecom(0xf5);lcd_writecom(0xf4);}addr+=40;}}*//*************************************************清楚中等大小的點(diǎn) 4*4(用讀修改寫(xiě) 效率高)*************************************************/void clr_rmiddling(uchar x,uchar y){uint addr;uchar temp1,temp2,n,dat;addr=(y<<7)+(y<<5)+(x>>1);//x/8*4;//128+32for(n=0;n<4;n++){temp1=addr;//&0xff;temp2=addr>>8;lcd_writecom_two(temp1,temp2,0x24);if(x&0x01){dat=(lcd_readdat_onebyte(0xc5))&0xf0;lcd_writedat_onebyte(dat,0xc4);}else{dat=(lcd_readdat_onebyte(0xc5))&0x0f;lcd_writedat_onebyte(dat,0xc4);}addr+=40;}}/*********************************************************畫(huà)8*8的大點(diǎn)(用畫(huà)點(diǎn)方式 速度慢)*********************************************************//*void sel_big(uchar x,uchar y){uint addr;uchar temp1,temp2,n;addr=(y<<8)+(y<<6)+(x);//x/8*4;y*320=y*(256+64)=(y<<8)+(y<<6)for(n=0;n<8;n++){temp1=addr&0x00ff;//addr%6temp2=addr>>8;lcd_writecom_two(temp1,temp2,0x24);lcd_writecom(0xfb);lcd_writecom(0xfa);lcd_writecom(0xf9);lcd_writecom(0xf8);lcd_writecom(0xff);lcd_writecom(0xfe);lcd_writecom(0xfd);lcd_writecom(0xfc);addr+=40;}}*//*********************************************************畫(huà)8*8的大點(diǎn)(用讀改寫(xiě)方式 速度快)*********************************************************/void sel_rbig(uchar x,uchar y){uint addr;uchar temp1,temp2,n,dat;addr=(y<<8)+(y<<6)+(x);//x/8*4;y*320=y*(256+64)=(y<<8)+(y<<6)for(n=0;n<8;n++){temp1=addr;//&0x00ff;//addr%6temp2=addr>>8;lcd_writecom_two(temp1,temp2,0x24);//dat=(lcd_readdat_onebyte(0xc5))|0xff;dat=0xff;lcd_writedat_onebyte(dat,0xc4);addr+=40;}} 上一頁(yè) 1 2 3 4 下一頁(yè)
評(píng)論