不卡手机高清av中文字幕 - 正在观看欲求不满中文无码 - 91国内揄拍国内精品对白 - 欧美特黄A级高清免费大片A片 - 欧美牲交a欧美牲交aⅴ久久

深圳市佳顯電子技術(shù)有限公司

10年專注LCD、LCM中文字庫液晶研發(fā)生產(chǎn)

全國咨詢服務(wù)熱線: 0760-85884496

聯(lián)系方式
LCM中文字庫液晶聯(lián)系我們

投訴熱線:13148701893 

聯(lián)系人:鄧小姐

傳真:0755-27315661
         0760-85884496

座機(jī):0755-29769890-0
         0760-85884486

郵箱:jxdlx107@goodview-lcd.com

辦公地址:深圳市寶安區(qū)福永塘尾富華工業(yè)區(qū)11棟3樓
工廠地址:廣東省中山市三鄉(xiāng)鎮(zhèn)萬里路1號(hào)平鋪工業(yè)區(qū)B棟三樓







12864中文字庫液晶基本操作函數(shù)庫

來源:LCD液晶模塊廠家   發(fā)布時(shí)間:2018-01-15   點(diǎn)擊量:2718

module_12864.h

#include

#define IO_12864 P0 //定義12864的數(shù)據(jù)端口

sbit RS_12864 = P2^5; //定義命令數(shù)據(jù)寄存器選擇端

sbit RW_12864 = P2^6; //定義定義讀寫控制端

sbit E_12864 = P2^7; //定義使能端

sbit RST_12864 = P2^2; //定義復(fù)位端

void delay_12864(unsigned int ); //延時(shí)子函數(shù)原型

void busychk_12864(void); //忙檢測子函數(shù)原型

void wrtcom_12864(unsigned char); //寫命令子函數(shù)原型

unsigned char reddat_12864(void); //讀數(shù)據(jù)子函數(shù)原型

void wrtdat_12864(unsigned char); //寫數(shù)據(jù)子函數(shù)原型

void drawpic_12864( unsigned char*); //繪圖子函數(shù)原型

void drawdot_12864(unsigned char,unsigned char,unsigned char);//畫點(diǎn)子函數(shù)原型

//畫矩形子函數(shù)原型

void drawrec_12864(unsigned char,unsigned char,

unsigned char,unsigned char,unsigned char);

void clnGDR_12864(void); //清空GDRAM子函數(shù)原型

//輸入短字符串子函數(shù)原型

void inputchars_12864(unsigned char,unsigned char,unsigned char*);

void scroll_12864(unsigned char*); //輸入長字符串卷動(dòng)子函數(shù)原型

void initial_12864(void); //12864初始化子函數(shù)原型

modlule_12864.c

//*延時(shí)子程序,最大延遲時(shí)間為65ms

void delay_12864(unsigned int del){

unsigned int i;

for(i = 0; i < del; i++){;}

}

//*忙檢測,若忙則等待,最長等待時(shí)間為60ms

void busychk_12864(void){

unsigned int timeout = 0;

E_12864 = 0;

RS_12864 = 0;

RW_12864 = 1;

E_12864 = 1;

while((IO_12864 & 0x80) && ++timeout != 0); //忙狀態(tài)檢測,等待超時(shí)時(shí)間為60ms

E_12864 = 0;

}

//寫命令子程序

void wrtcom_12864(unsigned char com){

busychk_12864();

E_12864 = 0;

RS_12864 = 0;

RW_12864 = 0;

IO_12864 = com;

E_12864 = 1;

delay_12864(50); //使能延時(shí)50us!!!注意這里,如果是較快的CPU應(yīng)該延時(shí)久一些

E_12864 = 0;

}

//讀數(shù)據(jù)子程序,返回一個(gè)字節(jié)的數(shù)據(jù)

unsigned char reddat_12864(void){

unsigned char temp;

busychk_12864();

E_12864 = 0;

IO_12864 = 0xff; //IO口置高電平,讀引腳

RS_12864 = 1;

RW_12864 = 1;

E_12864 = 1;

delay_12864(50); //使能延時(shí)50us!!!注意這里,如果是較快的CPU應(yīng)該延時(shí)久一些

temp = IO_12864;

return temp;

}

//寫數(shù)據(jù)子程序

void wrtdat_12864(unsigned char dat){

busychk_12864();

E_12864 = 0;

RS_12864 = 1;

RW_12864 = 0;

E_12864 = 1;

IO_12864 = dat;

delay_12864(50); //使能延時(shí)50us!!!注意這里,如果是較快的CPU應(yīng)該延時(shí)久一些

E_12864 = 0;

}

//顯示圖片函數(shù),參數(shù)時(shí)圖片的地址,圖片必須是128*64像素的逐行逐行的點(diǎn)陣信息。

void drawpic_12864( unsigned char *pPicture ){

unsigned char j, k ;

wrtcom_12864(0x34); //在寫GDRAM的地址之前一定要打開擴(kuò)充指令集,否則地址寫不進(jìn)去!!

for( j = 0 ; j < 32 ; j++ )

{

wrtcom_12864(0x80 + j) ; //寫Y 坐標(biāo)

wrtcom_12864(0x80) ; //寫X 坐標(biāo)

for( k = 0 ; k < 16 ; k++ ) //寫一整行數(shù)據(jù)

{

wrtdat_12864( *pPicture++ );

}

}

for( j = 0 ; j < 32 ; j++ )

{

wrtcom_12864(0x80 + j) ; //寫Y 坐標(biāo)

wrtcom_12864(0x88) ; //寫X 坐標(biāo)

for( k = 0 ; k < 16 ; k++ ) //寫一整行數(shù)據(jù)

{

wrtdat_12864( *pPicture++ ) ;

}

}

wrtcom_12864(0x36); //打開繪圖顯示

wrtcom_12864(0x30); //返回基本指令集

}

//畫點(diǎn)函數(shù),左上角為參考點(diǎn)(0,0)

//右下角為(127,63),點(diǎn)坐標(biāo)形式為(行坐標(biāo),列坐標(biāo))

//參數(shù)type用于設(shè)置畫黑點(diǎn)、白點(diǎn)或取反(黑變白,白變黑)

//type = 0為白色,1 為黑色,2為取反

//畫完點(diǎn)不開啟顯示,需要自行開啟繪圖顯示

void drawdot_12864(unsigned char y,unsigned char x,unsigned char type){

unsigned char X,Y,k; //X存儲(chǔ)行地址,Y存儲(chǔ)列地址,k存儲(chǔ)點(diǎn)在字中的位置(0~15從左至右)

unsigned char DH,DL;

if(y >= 0 && y <= 63 && x >= 0 && x <= 127) {

if(y < 32){ //確定所畫點(diǎn)的地址行與列地址

X = 0x80 + (x >> 4);

Y = 0x80 + y;

}else{

X = 0x88 + (x >> 4);

Y = 0x80 + (y - 32);

}

wrtcom_12864(0x34); //開啟擴(kuò)展指令,關(guān)閉繪圖顯示

wrtcom_12864(Y); //寫行位地址

wrtcom_12864(X); //寫列字地址

DH = reddat_12864(); //假讀

DH = reddat_12864(); //讀高字節(jié)

DL = reddat_12864(); //讀低字節(jié)

k = x % 16;

switch(type){ //判斷類型,是黑點(diǎn)還是白點(diǎn)還是取反

case 0: //畫白點(diǎn)

if(k < 8){

DH &= ~(0x01 << (7 - k));

}else{

DL &= ~(0x01 << (7 - (k % 8)));

}

break;

case 1: //畫黑點(diǎn)

if(k < 8){

DH |= (0x01 << (7 - k));

}else{

DL |= (0x01 << (7 - (k % 8)));

}

break;

case 2: //對點(diǎn)取反

if(k < 8){

DH ^= (0x01 << (7 - k));

}else{

DL ^= (0x01 << (7 - (k % 8)));

}

break;

default:

break;

}

wrtcom_12864(Y); //寫行位地址

wrtcom_12864(X); //寫列字地址

wrtdat_12864(DH); //回寫高字節(jié)

wrtdat_12864(DL); //回寫低字節(jié)

wrtcom_12864(0x36); //開啟繪圖顯示

wrtcom_12864(0x30); //轉(zhuǎn)回普通指令

}

}

//畫矩形子函數(shù),參數(shù)為(點(diǎn)1行坐標(biāo),點(diǎn)1列坐標(biāo),點(diǎn)2行坐標(biāo),點(diǎn)2列坐標(biāo),

//線條顏色(0為白,1為黑,2對原色取反))

void drawrec_12864(unsigned char y1,unsigned char x1,unsigned char y2,unsigned char x2,unsigned char type){

unsigned char largex,largey,smallx,smally;

unsigned char i;

if(x1 > x2){

largex = x1;

smallx = x2;

}else{

largex = x2;

smallx = x1;

}

if(y1 > y2){

largey = y1;

smally = y2;

}else{

largey = y2;

smally = y1;

}

//畫4條矩形邊框

for(i = smallx; i < largex; i++){

drawdot_12864(largey,i,type);

}

for(i = largey; i > smally; i--){

drawdot_12864(i,largex,type);

}

for(i = largex; i > smallx; i--){

drawdot_12864(smally,i,type);

}

for(i = smally; i < largey; i++){

drawdot_12864(i,smallx,type);

}

wrtcom_12864(0x30); //返回普通指令

}

//清空GDRAM,往GDRAM內(nèi)部寫滿0x00

void clnGDR_12864(void){

unsigned char j,k;

wrtcom_12864(0x34);//在寫GDRAM的地址之前一定要打開擴(kuò)充指令集,否則地址寫不進(jìn)去!!

for( j = 0 ; j < 32 ; j++ )

{

wrtcom_12864(0x80 + j) ; //寫Y 坐標(biāo)

wrtcom_12864(0x80) ; //寫X 坐標(biāo)

for( k = 0 ; k < 32 ; k++ ) //寫一整行數(shù)據(jù)

{

wrtdat_12864( 0x00 );

}

}

wrtcom_12864(0x30); //返回基本指令集

}

//寫入短字符串函數(shù),參數(shù)分別為顯示行(0~3),顯示列(0~7),字符串首地址

//字符串只會(huì)在一行顯示,超過的不顯示

void inputchars_12864(unsigned char y,unsigned char x,unsigned char *dataaddr){

unsigned char i,address;

switch (y){ //設(shè)置字符顯示起始地址

case 0: address = 0x80 + x;

break;

case 1: address = 0x90 + x;

break;

case 2: address = 0x88 + x;

break;

case 3: address = 0x98 + x;

break;

default: break;

}

wrtcom_12864(0x30);

wrtcom_12864(address);

for(i = x;i < 8; i++){

if(*dataaddr != '\0'){

wrtdat_12864(*dataaddr++);

}

}

}

//長字符串顯示卷屏函數(shù)

void scroll_12864(unsigned char *ser){

//addr存儲(chǔ)地址的中間變量,flag卷屏地址,hang要寫數(shù)據(jù)的行,

//over寫完字符串后繼續(xù)寫的空字符計(jì)數(shù)

unsigned char i,addr,flag,hang,over,*ptdat;

ptdat = ser; //獲得字符串首地址

over = 0; //寫入空字符串(寫完字符串后)數(shù)目初始化為0

wrtcom_12864(0x80); //寫第一行字符

for(i = 0; i < 16; i++){

if(*ptdat != '\0'){

wrtdat_12864(*ptdat++);

}else{

wrtdat_12864(0x20);

over++;

}

}

wrtcom_12864(0x90); //寫第二行字符

for(i = 0; i < 16; i++){

if(*ptdat != '\0'){

wrtdat_12864(*ptdat++);

}else{

wrtdat_12864(0x20);

over++;

}

}

wrtcom_12864(0x88); //寫第三行字符

for(i = 0; i < 16; i++){

if(*ptdat != '\0'){

wrtdat_12864(*ptdat++);

}else{

wrtdat_12864(0x20);

over++;

}

}

wrtcom_12864(0x98); //寫第四行字符

for(i = 0; i < 16; i++){

if(*ptdat != '\0'){

wrtdat_12864(*ptdat++);

}else{

wrtdat_12864(0x20);

over++;

}

}

ptdat = ptdat - 32;

wrtcom_12864(0xa0); //寫第三行DDRAM,寫入內(nèi)容為第三行字符串和第五行字符串

for(i = 0; i < 16; i++){ //寫第三行字符串

if(*ptdat != '\0'){

wrtdat_12864(*ptdat++);

}else{

wrtdat_12864(0x20);

over++;

}

}

ptdat = ptdat + 16;

for(i = 0; i < 16; i++){ //寫第五行字符串

if(*ptdat != '\0'){

wrtdat_12864(*ptdat++);

}else{

wrtdat_12864(0x20);

over++;

}

}

wrtcom_12864(0x0c); //開顯示

if(over > 15){;} //顯示字符不足4行,不卷動(dòng)

else //顯示字符大于4行,繼續(xù)寫字符,同時(shí)開啟卷動(dòng)

{

hang = 4;

flag = 0x01;

while(1){

switch(hang){ //設(shè)置寫入DDRAM的地址

case 1: addr = 0x80; break;

case 2: addr = 0x90; break;

case 3: addr = 0xa0; break;

case 4: addr = 0xb0; break;

}

switch(hang){ //設(shè)置要寫數(shù)據(jù)的下一行

case 1: hang = 2; break;

case 2: hang = 3; break;

case 3: hang = 4; break;

case 4: hang = 1; break;

}

ptdat = ptdat - 32;

for(i = 0; i < 8; i++){

wrtcom_12864(0x34); //打開擴(kuò)展指令

wrtcom_12864(0x03); //允許輸入卷動(dòng)地址

wrtcom_12864(0x40 + flag++); //設(shè)置卷動(dòng)地址

wrtcom_12864(0x30); //回到基本指令

wrtcom_12864(addr + i);

delay_12864(20000);

if(*ptdat != '\0'){

wrtdat_12864(*ptdat++); //連續(xù)寫入兩個(gè)字節(jié)之高字節(jié)

}else{

wrtdat_12864(0x20);

}

if(*ptdat != '\0'){

wrtdat_12864(*ptdat++); //連續(xù)寫入兩個(gè)字節(jié)之低字節(jié)

}else{

wrtdat_12864(0x20);

}

}

ptdat = ptdat + 16;

for(i = 8; i < 16; i++){

wrtcom_12864(0x34); //打開擴(kuò)展指令

wrtcom_12864(0x03); //允許輸入卷動(dòng)地址

if(flag == 64){flag = 0;}

wrtcom_12864(0x40 + flag); //設(shè)置卷動(dòng)地址

flag++;

wrtcom_12864(0x30); //回到基本指令

wrtcom_12864(addr + i);

delay_12864(20000);

if(*ptdat != '\0'){

wrtdat_12864(*ptdat++); //連續(xù)寫入兩個(gè)字節(jié)之高字節(jié)

}else{

over++; //寫完最后一行字符,需要再卷動(dòng)16次才能顯示出來。

wrtdat_12864(0x20);

}

if(*ptdat != '\0'){

wrtdat_12864(*ptdat++); /連續(xù)寫入兩個(gè)字節(jié)之低字節(jié)

}else{

wrtdat_12864(0x20);

}

}

if(over < 8){;} //最后一行顯示完畢則停止卷動(dòng)

else {break;}

}

}

}

//初始化12864子函數(shù)

void initial_12864(void){

delay_12864(40000);

RST_12864 = 1;

RST_12864 = 0; //復(fù)位

delay_12864(500);

RST_12864 = 1;

wrtcom_12864(0x30); //設(shè)置為基本指令集動(dòng)作

delay_12864(100);

wrtcom_12864(0x30); //設(shè)置為基本指令集動(dòng)作

delay_12864(37);

wrtcom_12864(0x08); //設(shè)置顯示、光標(biāo)、閃爍全關(guān)。

delay_12864(100);

wrtcom_12864(0x01); //清屏,并且DDRAM數(shù)據(jù)指針清零

delay_12864(100000);

wrtcom_12864(0x06); //進(jìn)入模式設(shè)置

wrtcom_12864(0x0c); //開顯示

}

深圳佳顯電子技術(shù)有限公司10年專注LCD液晶模塊,LCM中文字庫液晶批發(fā),12864中文字庫液晶,lcd液晶模組,lcd液晶顯示屏批發(fā)等以及其他lcd液晶產(chǎn)品,lcd液晶模塊價(jià)格全國最優(yōu)惠!



熱門標(biāo)簽:12864中文字庫液晶,中文字庫液晶廠家,深圳lcd液晶模塊廠家,lcd液晶模塊定制

傳真:  0755-27315661    0760-85884496
座機(jī):  0755-29769890-0  0760-85884486

郵箱:jxdlx107@goodview-lcd.com

辦公地址:深圳市寶安區(qū)福永塘尾富華工業(yè)區(qū)11棟3樓

工廠地址:廣東省中山市三鄉(xiāng)鎮(zhèn)萬里路1號(hào)平鋪工業(yè)區(qū)B棟三樓

Copyrights©2017 深圳市佳顯電子技術(shù)有限公司 All Rights Reserved
備案號(hào): 粵ICP備17051216號(hào)

阿里巴巴二維碼

阿里巴巴二維碼

網(wǎng)站二維碼

網(wǎng)站二維碼