新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 單片機GUI編程顯示漢字

單片機GUI編程顯示漢字

作者: 時間:2016-11-26 來源:網(wǎng)絡(luò) 收藏

本文引用地址:http://butianyuan.cn/article/201611/322062.htm

uint8 ReadSdate(void)

{

uint8checkbusy;

//LCD_BUS = 0xff;

OutData(0xff);

//CD1=1;

SCD1();

//RD1=0;

CRD1();

//checkbusy=((IO0PIN&0x00ff0000)>>16);

checkbusy = (GPIOD->IDR&0x00ff);

//RD1=1;

SRD1();

return ( checkbusy );

}

void RWcheck(void)

{

uint8databusy;

do

{

databusy=ReadSdate();

}while( !(databusy&0x03) );

}

void AutoRcheck(void)

{

uint8databusy;

do

{

databusy=ReadSdate();

}while( !(databusy&0x04) );

}

void AutoWcheck(void)

{

uint8databusy;

do

{

databusy=ReadSdate();

}while( !(databusy&0x08) );

}

//寫數(shù)據(jù)

voidWriteData(uint8 dat)

{

RWcheck();

//CD1=0;

CCD1();

//LCD_BUS=dat;

OutData(dat);

//WR1=0;

CWR1();

//WR1=1;

SWR1();

}

//寫指令

voidWriteCmd1(unsigned char cmd)

{

RWcheck();;

//CD1=1;

SCD1();

//LCD_BUS=cmd;

OutData(cmd);

//WR1=0;

CWR1();

//WR1=1;

SWR1();

}

//先寫數(shù)據(jù)再寫指令

voidWriteCmd2(uint8 dat,uint8 cmd)

{

WriteData(dat);

WriteCmd1(cmd);

}

//先寫2組數(shù)據(jù)再寫1組指令

voidWriteCmd3(uint8 dat1,uint8 dat2,uint8 cmd)

{

WriteData(dat1);

WriteData(dat2);;

WriteCmd1(cmd);

}

//數(shù)據(jù)自動寫

voidAutoWriteData( uint8 dat)

{

AutoWcheck();;

//CD1 = 0;

CCD1();

//LCD_BUS= dat;

OutData(dat);

//WR1=0;

CWR1();

//WR1=1;

SWR1();

}

#defineOutData(dat)GPIOD->BRR = 0xff<BSRR = (dat&0xff)<

#defineLCM_WR112

#defineSWR1()GPIOB->BSRR = 1<

#defineCWR1()GPIOB->BRR= 1<

#defineLCM_RD113

#defineSRD1()GPIOB->BSRR = 1<

#defineCRD1()GPIOB->BRR= 1<

#defineLCM_CE114

#defineSCE1()GPIOB->BSRR = 1<

#defineCCE1()GPIOB->BRR= 1<

#defineLCM_CD115

#defineSCD1()GPIOB->BSRR = 1<

#defineCCD1()GPIOB->BRR= 1<

圖形顯示的操作,最根本是對緩存的操作。

從應(yīng)用層到底層的整個過程解析如下:

1、調(diào)用寫字函數(shù)在LCD上顯示一個漢字。

GUI_PutHZ(x1,y1,(uint8*)gb12Dot[GetGB12_Address(ptr)].Msk,12, 12);

l參數(shù)參考上面的函數(shù)說明,其中要顯示的字需要通過一個數(shù)組查找。

l該數(shù)組是一個結(jié)構(gòu)體數(shù)組,每一個結(jié)構(gòu)體中有兩個分量,第一個是要顯示的漢字,第二個是該漢字的字庫。

l把需要寫入的漢字及字庫先存放在數(shù)組中,根據(jù)漢字的內(nèi)容查找到相應(yīng)字庫。

2、在GUI_PutHZ函數(shù)中調(diào)用了GUI_LoadLine(x, y, dat, hno);

字庫的實質(zhì)是點矩陣,寫字的實質(zhì)就是把字庫里安排的點陣寫進緩存里。

這里調(diào)用畫線函數(shù),對矩陣進行操作。

3、在GUI_LoadLine函數(shù)中調(diào)用了GUI_Point(x, y, bakc);

l對畫線的操作,實質(zhì)就是對線上的每一點進行操作。

l對于黑白屏來說,點的操作就是點亮與熄滅。

l對于彩色屏就是對像素位的操作來實現(xiàn)顏色的變化。

l所有的圖案及字,都是不同顏色組合后給人的一種感官視覺。

lgui_disp_buf[y][x>>3] |=DCB_HEX_TAB[x&0x07];改變顯示緩存中的數(shù)據(jù)。

lLCD_UpdatePoint(x, y);調(diào)用更新點函數(shù)實現(xiàn)刷屏。

4、LCD_UpdatePoint函數(shù)中,調(diào)用了WriteCmd3和WriteCmd2函數(shù)

WriteCmd3這兩個函數(shù)是對底層最基本的IO口操作,涉及硬件原理,涉及時序。

GUI的操作原理及程序例子基本完成。操作關(guān)鍵總結(jié)歸納如下:

l如何設(shè)計外圍接口。

l如何編寫底層驅(qū)動函數(shù)。

l如何根據(jù)需求編寫應(yīng)用軟件。


上一頁 1 2 下一頁

關(guān)鍵詞: 單片機GUI編程顯示漢

評論


技術(shù)專區(qū)

關(guān)閉