像素: 圖像的最小組成單位。
一個彩色像素的信息可以用1個多位二進制數來表示和儲存。用來表示彩色像素的二進制數的位數我們稱為顏色深度或顏色質量。采用1個16位二進制數來表達一個彩色點,黑白是1bit對於LCD一個像素,彩色是多bit對應一個像素,數組中一個字符占了橫8豎16。
Ascii的最末一個為0x7f,因此經常有x<0x80的判斷語句。
紅: 0xf800 黃: 0xffe0 綠: 0x07e0 青: 0x07ff 藍: 0x001f
紫: 0xf81f 黑: 0x0000 白: 0xffff 灰: 0x7bef
函數名:Write_Data_U16 功能:寫16位數據 函數原型:void Write_Data_U16(unsigned int y); 入口參數:unsigned int y 要寫的16位數據 出口參數:無 說明:這個16位數據分成兩個8位數據分兩次寫入 示例代碼: Write_Data_U16(Color);//寫 16 位顏色數據
函數名:Write_Cmd_Data 功能:寫命令、寫數據 函數原型:void Write_Cmd_Data(unsigned char x,unsigned int y); 入口參數:unsigned char x 要寫的8位命令 unsigned int y 出口參數:無 說明:先寫8位命令,后寫16位數據 示例代碼: Write_Cmd_Data(WINDOW_XADDR_START,x0);//寫 X 坐標的起始位置 要寫的 16 位數據
函數名:ILI9325_Initial 功能:液晶初始化函數 函數原型:void ILI9325_Initial(void); 入口參數:無 出口參數:無 說明:廠家提供的液晶初始化代碼 示例代碼: ILI9325_Initial();//初始化 LCD
函數名:LCD_SetPos 功能:定義顯示窗體 函數原型:static void LCD_SetPos (unsigned int x0, unsigned int x1, unsigned int y0, unsigned int y1); 入口參數:x0:窗體中X坐標中較小者 x1:窗體中X坐標中較大者 y0:窗體中Y坐標中較小者 y1:窗體中Y坐標中較大者 出口參數:無 說明:設置顯示區域的大小 示例代碼: LCD_SetPos(0,240,0,320);//設置顯示區域為 320x240
函數名:CLR_Screen 功能:清屏 函數原型:void CLR_Screen(unsigned int bColor); 入口參數:bColor 清除屏幕的的顏色 出口參數:無 說明:使用背景色清除屏上所有內容 示例代碼: CLR_Screen(0xf800);//清屏紅色 CLR_Screen(0xffe0);//清屏黃色 CLR_Screen(BLUE);//清屏藍色
函數名:Put_pixel 功能:在屏幕上畫點 函數原型:void Put_pixel(uchar x,uchar y,unsigned int color); 入口參數:x,y 需要畫點的坐標,color為點的顏色 出口參數:無 說明:在屏幕上指定的坐標畫指定顏色的點 示例代碼: Put_pixel(200,200,RED);//在坐標點(200,200)畫一紅色點
函數名:Line 功能:在屏幕上畫線 函數原型:void Line(uchar X0, uchar Y0, uchar X1, uchar Y1, unsigned int color); 入口參數:起點坐標(X0,Y0),終點坐標(X1,Y1),color為線的顏色 出口參數:無 說明:用指定顏色在屏幕指定坐標畫出線 示例代碼: Line(0,0,200,200,BLUE);//從點(0,0)到點(200,200)畫一條藍色的線
函數名:Rectangle 功能:繪制一個矩形框 函數原型:void Rectangle (uchar left, uchar top, uchar right, uchar bottom, unsigned int color); 入口參數:矩形的起始位置left,top 矩形的結束位置right,bottom 矩形框的顏色color 出口參數:無 說明:用指定顏色在屏幕指定坐標繪制一個矩形框 示例代碼: Rectangle(10,10,118,150,0x0000);//畫一黑色矩形框
函數名:Bar 功能:繪制一個填充的平面矩形 函數原型:void Bar (uchar left, uchar top, uchar right, uchar bottom, unsigned int color); 入口參數:矩形的起始位置left,top 矩形的結束位置right,bottom 矩形填充顏色color 出口參數:無 說明:用指定顏色在屏幕指定坐標繪制一個填充的平面矩形 示例代碼: Bar(0,0,120,160,0x0000);//畫一黑色矩形框
函數名:Show_RGB 功能:繪制一個填充的平面矩形 函數原型:void Show_RGB (unsigned int x0, unsigned int x1, unsigned int y0, unsigned int y1, unsigned int Color); 入口參數:x0,y0 起始坐標 x1,y1 結束坐標 Color 背景顏色 出口參數:無 說明: 用指定顏色在屏幕指定坐標繪制一個填充的平面矩形(速度比Bar函數快) 示例代碼: Show_RGB (0,120,0,160,0x0000);//畫一黑色矩形框
函數名:show_colour_bar 功能:在整個屏幕上繪制橫彩條 函數原型:void show_colour_bar(void); 入口參數:無 出口參數:無 說明:橫彩條從上到下的顏色順序為紅、綠、藍、黃、紫、青、白、黑 示例代碼: show_colour_bar();//顯示彩條
函數名:LCD_PutChar8x16 功能:顯示數字及英文字符 函數原型:void LCD_PutChar8x16 (unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor); 入口參數:x 橫坐標,y 縱坐標 c 需要顯示的字符 fColor 字符顏色 bColor 字符背景顏色 出口參數:無 說明:需包含"8X16.h ",顯示數字、大小寫英文字符和一些符號等 示例代碼: LCD_PutChar8x16(0,0, 'Z',RED,BLUE);//顯示英文字符 Z
!!!!這其中涉及的char m=Font8x16[c*16+i]的問題!!!
unsigned char Font8x16[] = {
s _ _ _ _ _ _ _ _ , //0000 0000
s _ _ _ _ _ _ _ _ ,
s _ X X X X X _ _ , // 0111 1100
s _ X _ _ _ _ X _ , // 0100 0010,
s _ X _ _ _ _ X _ , //每一行依次類推
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X X X X X _ _ ,
s _ X _ X _ _ _ _ ,
s _ X _ _ X _ _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ _ X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ , };
for(i=0; i<16;i++) {
unsigned char m=Font8x16[c*16+i];
for(j=0;j<8;j++) {
if((m&0x80)==0x80) {
write_data_u16(fColor); }
else { write_data_u16(bColor); }
m<<=1;
} }
}
Font8x16[]是與ASSIC碼表對應的一張表,連續16個8位二進制值可成一個字符(8*16),把一個8位二進制值依次循環和0x80(1000 0000)相與(與1000 0000與則只看最高為是0還是1,其他為和0相與都為0,相當於提取了最高位進行判斷是0還是1),為1則表示此個小點應有填充,即輸出字體顏色,為0則輸出背景。如上所示,m=66=0x0100 0010, 最高位與0x80相與,輸出后將其向左移動1位,繼續相與,直到8位輸出完,再進行下一行掃描。
函數名:PutGB1616 功能:顯示16*16漢字 函數原型:void PutGB1616 (unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor, unsigned int bColor); 入口參數:x 橫坐標,y 縱坐標 c 需要顯示的漢字碼 fColor 漢字顏色 bColor 漢字背景顏色 出口參數:無 說明:需包含" GB1616.h ",具體漢字是如何取模的,閱讀16*16漢字取模說明 示例代碼: PutGB1616(0,0, "華",RED,BLUE);//顯示漢字“華”
函數名:LCD_PutString 功能:顯示字符串 函數原型:void LCD_PutString (unsigned short x, unsigned short y, unsigned char *s, unsigned int fColor, unsigned int bColor); 入口參數:x 橫坐標,y 縱坐標 *s 需要顯示的字符串 fColor 字符顏色 bColor 字符背景顏色 出口參數:無 說明:中英文字符、數字和符號可以同時顯示 示例代碼: LCD_PutString(10,80,"電子科技",0x0000,0xf800);//顯示字符串
函數名:LCDShow_uCharNumber 功能:向LCD發送一個0--65535的數值 函數原型:void LCDShow_uCharNumber (uchar x, uchar y, unsigned int uCharNumber, unsigned int forecolor, unsigned int bkcolor); 入口參數:x 橫坐標,y 縱坐標 uCharNumber 需要顯示的一串數字 forecolor 字符顏色 bkcolor 字符背景顏色 出口參數:無 說明:顯示一串數字,數值范圍從0--65535 示例代碼: LCDShow_uCharNumber(10,30,9999,0x0000,0xffff);//顯示一串數字
函數名:PutGB3232 功能:顯示32*32漢字 函數原型:void PutGB3232 (unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor, unsigned int bColor); 入口參數:x 橫坐標,y 縱坐標 c 需要顯示的漢字碼 fColor 漢字顏色 bColor 漢字背景顏色 出口參數:無 說明:需包含" GB3232.h ",具體漢字是如何取模的,閱讀32*32漢字取模說明 示例代碼: PutGB3232(0,200,"我",WHITE,BLUE);//顯示 32*32 漢字
函數名:Show_Color_Bar 功能:在整個屏幕上顯示漸變色橫彩條 函數原型:void Show_Color_Bar(void); 入口參數:無 出口參數:無 說明:在整個屏幕上逐行掃描出漸變顏色橫彩條 示例代碼: Show_Color_Bar();//顯示漸變彩條
16*16漢字取模方式: 16*16字模由軟件取模得到,具體操作如下點擊“參數設置”中的“其它選項” ,設置如下圖然后輸入文字,按“Ctrl+Enter 組合鍵”結束文字輸入點擊“取模方式”選擇“C51 格式” ,此時會在“點陣生成區”輸出取模數據把生成的代碼復制,粘貼到 GB1616.h 中,按已有的格式進行修改修改好 GB1616.h 文件后,還要修改 PutGB1616 函數中的“自建漢字的個數”至此,就可以在程序中自由的調用字庫中已有漢字用於顯示
32*32漢字取模方式:
32*32字模由軟件取模得到,具體操作如下,打開軟件點擊“模式”選擇“字符模式”,設置字寬為 32*32點擊“選項” ,具體設置如下,然后在軟件中間的空白處輸入漢字,點擊“生成字模” ,此時字模代碼產生把生成的代碼復制,粘貼到 GB3232.h 中,按已有的格式進行修改,修改好 GB3232.h 文件后,還要修改 PutGB3232 函數中的“自建漢字的個數”。至此,就可以在程序中自由的調用字庫中已有漢字用於顯示
問1:如果想在LCD上顯示字母'A',怎么顯示?
答:比如LCD分辨率為320*270,這個字母‘A’用8個像素*8個像素的矩陣來顯示。所謂顯示就‘A’邊界的像素值為黑色,其它地方為其它顏色,這樣用戶就行看到了。
問2:那怎么知道哪些地方要顯示成黑色,哪些地方顯示為白色呢?
答:這個由‘A’字母的字模來決定,字模里面包含了字母‘A’的像素值。
問3:字模是什么東西,怎么得到?
答:字模從linux內核中可以找到,程序中是在font_8x8.c文件中,其實就是在一個數組里面設置好了各個字符的像素值,每個字符用8個字節來存儲,8*8=64位像素。我們要顯示時就是在這里面找到對應字符的像素值。
‘A’的ASCII是0x41=65,所以對應的是這個數組是的65個元素fontdata_8x8[65]; 根據這8個字節的值在紙上描一下,就可以看到字母A了,1為畫黑點。
例1:程序對應:24th_lcd_putchar
功能:在串口上輸出字母A,同時在LCD上顯示字母A。
輸出字母的功能主要在framebuffer.c中的lcd_putc()方法中。
單片機顯示程序:復制后用notepad++打開方便查看,keil更佳
#include"reg52.h"
#define WINDOW_XADDR_START 0x0050 // Horizontal Start Address Set
#define WINDOW_XADDR_END 0x0051 // Horizontal End Addr•ess Set
#define WINDOW_YADDR_START 0x0052 // Vertical Start Address Set
#define WINDOW_YADDR_END 0x0053 // Vertical End Address Set
#define GRAM_XADDR 0x0020 // GRAM Horizontal Address Set
#define GRAM_YADDR 0x0021 // GRAM Vertical Address Set
#define GRAMWR 0x0022 // memory write
/* LCD color */
#define White 0xFFFF
#define Black 0x0000
#define Blue 0x001F
#define Blue2 0x051F
#define Red 0xF800
#define Magenta 0xF81F
#define Green 0x07E0
#define Cyan 0x7FFF
#define Yellow 0xFFE0
sbit CS=P2^7; //片選
sbit RES=P2^5; //復位
sbit RS=P2^4; //數據/命令選擇
sbit RW=P2^3;
//注意!!!數據口使用P1
void main (void);
void ILI9325_Initial(void);
void show_colour_bar (void);//顯示橫幅彩條,無意義
void Init_data(unsigned char x, unsigned int y);
void Write_Cmd(unsigned char DH,unsigned char DL);
void Write_Data(unsigned char DH,unsigned char DL);
void delayms(unsigned int tt);
void show_photo(void);//顯示圖片
void Show_RGB (unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1,unsigned int Color);
unsigned char code pic[];
void Write_Data_U16(unsigned int y);
static void LCD_SetPos(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1);
void ClearScreen(unsigned int bColor);
void LCD_PutChar8x16(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor);
void LCD_PutChar8x8(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor);
void LCD_PutChar(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor);
void LCD_PutString(unsigned short x, unsigned short y, char *s, unsigned int fColor, unsigned int bColor);//*s指向的是s[]字符串
void PutGB1616(unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor,unsigned int bColor);//漢字
void PutGB3232(unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor,unsigned int bColor);//漢字
//================================================//
void main(void)
{
CS=1;
delayms(25);
RES=0;
delayms(150);
RES=1;
delayms(25);
ILI9325_Initial();//廠家提供LCD初始源代碼
while(1)
{
ClearScreen(0x0);
//show_colour_bar(); //顯示橫幅彩條,無意義
LCD_PutString(2,40,"hello,this is Sugon ",Red,Blue); ///前景顏色和背景顏色,可以直接//定義,也可以直接填入16進制數字
LCD_PutString(20,160,"abcdefghijklmnopqistuvwxyz",0xF800,Yellow);
LCD_PutString(20,180,"`,./<>';:[]{}\|?)(-=+*&^%$",0xF800,Yellow);
PutGB3232(20,200,"我",Blue,Yellow); //寫入32x32漢字
PutGB3232(60,200,"是",Blue,Red);
PutGB3232(100,200,"曙",Blue,Magenta);
PutGB3232(140,200,"光",Blue,Green);
PutGB3232(180,200,"人",Blue,Cyan);
// show_photo();//無意義
while(1);
}
}
void ClearScreen(unsigned int bColor) //清屏,可以設置顏色
{
unsigned int i,j;
LCD_SetPos(0,240,0,320);//SetPos為選擇區域,320x240為整個屏幕
for (i=0;i<325;i++) //按地址來說只能是從上往下刷屏,循環只是為了計數
{
for (j=0;j<240;j++)
Write_Data_U16(bColor);//寫入背景顏色
}
}
/////////////////////////////////////////////////////////////
#include "8X16.h"
void LCD_PutChar8x16(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor)
{
unsigned int i,j;//有一個疑問,i和j怎么和一個字符的8x16各個位置對應並寫入?即i+1與j+1時,怎么就能使write_data_u16右移?
LCD_SetPos(x,x+8-1,y,y+16-1);
for(i=0; i<16;i++) {
unsigned char m=Font8x16[c*16+i];
for(j=0;j<8;j++) {
if((m&0x80)==0x80) {
Write_Data_U16(fColor);//表示該點填充前景色
}
else {
Write_Data_U16(bColor); //表示該點填充背景色
}
m<<=1;
}
}
}
void LCD_PutChar(unsigned short x, unsigned short y, char c, unsigned int fColor, unsigned int bColor) {
LCD_PutChar8x16( x, y, c, fColor, bColor );//兩個函數一樣,相連
}
#include "GB1616.h" //16*16漢字字模
void PutGB1616(unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor,unsigned int bColor){
unsigned int i,j,k;
LCD_SetPos(x, x+16-1,y, y+16-1);
for (k=0;k<64;k++) { //64標示自建漢字庫中的個數,循環查詢內碼 ?應該是25個吧。。
if ((codeGB_16[k].Index[0]==c[0])&&(codeGB_16[k].Index[1]==c[1])){
for(i=0;i<32;i++) {
unsigned short m=codeGB_16[k].Msk[i];
for(j=0;j<8;j++) {
if((m&0x80)==0x80) {
Write_Data_U16(fColor);
}
else {
Write_Data_U16(bColor);
}
m<<=1;
}
}
}
}
}
#include "GB3232.h" //32*32漢字字模
void PutGB3232(unsigned short x, unsigned short y, unsigned char c[2], unsigned int fColor,unsigned int bColor){
unsigned int i,j,k;
LCD_SetPos(x, x+32-1,y, y+32-1);
for (k=0;k<15;k++) { //15標示自建漢字庫中的個數,循環查詢內碼 這個15倒是對的。。
if ((codeGB_32[k].Index[0]==c[0])&&(codeGB_32[k].Index[1]==c[1])){
for(i=0;i<128;i++) {
unsigned short m=codeGB_32[k].Msk[i];
for(j=0;j<8;j++) {
if((m&0x80)==0x80) {
Write_Data_U16(fColor);
}
else {
Write_Data_U16(bColor);
}
m<<=1;
}
}
}
}
}
void LCD_PutString(unsigned short x, unsigned short y, unsigned char *s, unsigned int fColor, unsigned int bColor) {
unsigned char l=0;
while(*s) {
if( *s < 0x80) //*s指向的是s[]字符串
{
LCD_PutChar(x+l*8,y,*s,fColor,bColor); //橫着寫,縱坐標不變,l*8表示兩個字符間距為8
s++;l++;
}
else
{
PutGB1616(x+l*8,y,(unsigned char*)s,fColor,bColor); //間距16 如果不是ascii所能表示的范圍,則是漢字,那么間距加大為16,s每次+2,1每次+2
s+=2;l+=2;
}
}
}
//==================== 顯示R G B 顔色 ====================//
void Show_RGB (unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1,unsigned int Color)
{ //繪制一個填充的平面矩形
unsigned int i,j;
LCD_SetPos(x0,x1,y0,y1);
for (i=y0;i<=y1;i++)
{
for (j=x0;j<=x1;j++)
Write_Data_U16(Color); //寫像素點
}
}
//====================== 顯示彩條,無意義可不解 ======================//
//void show_colour_bar (void) //和上一個函數沒有本質區別,只是規定了寬度
//{
// int V,H;
// LCD_SetPos(0,240,0,320);//320x240
// for(H=0;H<240;H++)
// {
// for(V=0;V<40;V++)
// Write_Data(0xf8,0x00); //干嘛非要把16位數用兩個8位拼起來,為什么不直接write_data_U16那個函數呢?真蛋疼。。
// }
// for(H=0;H<240;H++)
// {
// for(V=40;V<80;V++)
// Write_Data(0x07,0xe0);
// }
// for(H=0;H<240;H++)
// {
// for(V=80;V<120;V++)
// Write_Data(0x00,0x1f);
// }
// for(H=0;H<240;H++)
// {
// for(V=120;V<160;V++)
// Write_Data(0xff,0xe0);
// }
// for(H=0;H<240;H++)
// {
// for(V=160;V<200;V++)
// Write_Data(0xf8,0x1f);
// }
// for(H=0;H<240;H++)
// {
// for(V=200;V<240;V++)
// Write_Data(0x07,0xff);
// }
// for(H=0;H<240;H++)
// {
// for(V=240;V<280;V++)
// Write_Data(0xff,0xff);
// }
// for(H=0;H<240;H++)
// {
// for(V=280;V<320;V++)
// Write_Data(0x00,0x00);
// }
//}
//====================== 顯示圖片,要用再解 ======================//
//void show_photo(void)
//{
// unsigned char j;
// unsigned int i;
// unsigned long s=0;
// LCD_SetPos(0,240,0,320);//320x240
// for (i=0;i<75;i++)
// {
// for (j=0;j<240;j++)
// Write_Data(0xff,0xff);
//
// }
// for (i=0;i<170;i++)
// {
// for (j=0;j<55;j++)
// Write_Data(0xff,0xff);
// for (j=0;j<130;j++)
// Write_Data(pic[s++],pic[s++]);
//
// for (j=0;j<55;j++)
// Write_Data(0xff,0xff);
// }
// for (i=0;i<75;i++)
// {
// for (j=0;j<240;j++)
// Write_Data(0xff,0xff);
//
// }
// }
//=======================================================//
void Init_data (unsigned char x,unsigned int y)
{
unsigned char m,n;
m=y>>8;
n=y;
Write_Cmd(0x00,x);
Write_Data(m,n);
}
void Write_Data_U16(unsigned int y) //char m,n為8位,y為16位
{
unsigned char m,n;
m=y>>8;
n=y;
Write_Data(m,n);
}
//====================== 寫命令 ==========================//
void Write_Cmd(unsigned char DH,unsigned char DL) //DH/DL為16位數的高低8位
{
CS=0;
RS=0;
P1=DH;
RW=0;
RW=1;
P1=DL;
RW=0;
RW=1;
CS=1;
}
//===================== 寫數據 ===========================//
void Write_Data(unsigned char DH,unsigned char DL)
{
CS=0;
RS=1;
P1=DH;
RW=0;
RW=1;
P1=DL;
RW=0;
RW=1;
CS=1;
}
//=======================================================
void delayms(unsigned int count)
{
int i,j;
for(i=0;i<count;i++)
{
for(j=0;j<260;j++);
}
}
//===================== 初始化代碼 =======================//
void ILI9325_Initial(void)
{
//////////////////////////////////////////////////////////
delayms(150); //根據不同晶振速度可以調整延時,保障穩定顯示
Init_data(0x00E5, 0x8000); // Set the Vcore voltage and this setting is must.
Init_data(0x0000, 0x0001); // Start internal OSC.
Init_data(0x0001, 0x0100); // set SS and SM bit
Init_data(0x0002, 0x0700); // set 1 line inversion
Init_data(0x0003, 0x0030); // set GRAM write direction and BGR=0.
Init_data(0x0004, 0x0000); // Resize register
Init_data(0x0008, 0x0202); // set the back porch and front porch
Init_data(0x0009, 0x0000); // set non-display area refresh cycle ISC[3:0]
Init_data(0x000A, 0x0000); // FMARK function
Init_data(0x000C, 0x0000); // RGB interface setting
Init_data(0x000D, 0x0000); // Frame marker Position
Init_data(0x000F, 0x0000); // RGB interface polarity
//*************Power On sequence ****************//
Init_data(0x0010, 0x0000); // SAP, BT[3:0], AP, DSTB, SLP, STB
Init_data(0x0011, 0x0007); // DC1[2:0], DC0[2:0], VC[2:0]
Init_data(0x0012, 0x0000); // VREG1OUT voltage
Init_data(0x0013, 0x0000); // VDV[4:0] for VCOM amplitude
delayms(200); // Dis-charge capacitor power voltage
Init_data(0x0010, 0x17B0); // SAP, BT[3:0], AP, DSTB, SLP, STB
Init_data(0x0011, 0x0037); // DC1[2:0], DC0[2:0], VC[2:0]
delayms(50); // Delay 50ms
Init_data(0x0012, 0x013E); // VREG1OUT voltage
delayms(50); // Delay 50ms
Init_data(0x0013, 0x1F00); // VDV[4:0] for VCOM amplitude
Init_data(0x0029, 0x0013); // VCM[4:0] for VCOMH
delayms(50);
Init_data(0x0020, 0x0000); // GRAM horizontal Address
Init_data(0x0021, 0x0000); // GRAM Vertical Address
// ----------- Adjust the Gamma Curve ----------//
Init_data(0x0030, 0x0000);
Init_data(0x0031, 0x0404);
Init_data(0x0032, 0x0404);
Init_data(0x0035, 0x0004);
Init_data(0x0036, 0x0404);
Init_data(0x0037, 0x0404);
Init_data(0x0038, 0x0404);
Init_data(0x0039, 0x0707);
Init_data(0x003C, 0x0500);
Init_data(0x003D, 0x0607);
//------------------ Set GRAM area ---------------//
Init_data(0x0050, 0x0000); // Horizontal GRAM Start Address
Init_data(0x0051, 0x00EF); // Horizontal GRAM End Address
Init_data(0x0052, 0x0000); // Vertical GRAM Start Address
Init_data(0x0053, 0x013F); // Vertical GRAM Start Address
Init_data(0x0060, 0x2700); // Gate Scan Line
Init_data(0x0061, 0x0001); // NDL,VLE, REV
Init_data(0x006A, 0x0000); // set scrolling line
//-------------- Partial Display Control ---------//
Init_data(0x0080, 0x0000);
Init_data(0x0081, 0x0000);
Init_data(0x0082, 0x0000);
Init_data(0x0083, 0x0000);
Init_data(0x0084, 0x0000);
Init_data(0x0085, 0x0000);
//-------------- Panel Control -------------------//
Init_data(0x0090, 0x0010);
Init_data(0x0092, 0x0000);
Init_data(0x0093, 0x0003);
Init_data(0x0095, 0x0110);
Init_data(0x0097, 0x0000);
Init_data(0x0098, 0x0000);
Init_data(0x0007, 0x0173); // 262K color and display ON
// Write_Cmd_Data(0x0022);//
}
/*===========================================================*/
/*************************************************************
函數名稱:LCD_DefineDispWindow
功 能:定義顯示窗體
參 數:x0: 窗體中X坐標中較小者
x1: 窗體中X坐標中較大者
y0: 窗體中Y坐標中較小者
y1: 窗體中Y坐標中較大者
返 回 值:無
*************************************************************/
static void LCD_SetPos(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1)
{
Init_data(WINDOW_XADDR_START,x0);
Init_data(WINDOW_XADDR_END,x1);
Init_data(WINDOW_YADDR_START,y0);
Init_data(WINDOW_YADDR_END,y1);
Init_data(GRAM_XADDR,x0);
Init_data(GRAM_YADDR,y0);
Write_Cmd (0x00,0x22);//LCD_WriteCMD(GRAMWR);
}
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,// sp
0x00, 0x00, 0x00, 0x2f, 0x00, 0x00,// !
0x00, 0x00, 0x07, 0x00, 0x07, 0x00,// "
0x00, 0x14, 0x7f, 0x14, 0x7f, 0x14,// #
0x00, 0x24, 0x2a, 0x7f, 0x2a, 0x12,// $
0x00, 0x62, 0x64, 0x08, 0x13, 0x23,// %
0x00, 0x36, 0x49, 0x55, 0x22, 0x50,// &
0x00, 0x00, 0x05, 0x03, 0x00, 0x00,// '
0x00, 0x00, 0x1c, 0x22, 0x41, 0x00,// (
0x00, 0x00, 0x41, 0x22, 0x1c, 0x00,// )
0x00, 0x14, 0x08, 0x3E, 0x08, 0x14,// *
0x00, 0x08, 0x08, 0x3E, 0x08, 0x08,// +
0x00, 0x00, 0x00, 0xA0, 0x60, 0x00,// ,
0x00, 0x08, 0x08, 0x08, 0x08, 0x08,// -
0x00, 0x00, 0x60, 0x60, 0x00, 0x00,// .
0x00, 0x20, 0x10, 0x08, 0x04, 0x02,// /
0x00, 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0
0x00, 0x00, 0x42, 0x7F, 0x40, 0x00,// 1
0x00, 0x42, 0x61, 0x51, 0x49, 0x46,// 2
0x00, 0x21, 0x41, 0x45, 0x4B, 0x31,// 3
0x00, 0x18, 0x14, 0x12, 0x7F, 0x10,// 4
0x00, 0x27, 0x45, 0x45, 0x45, 0x39,// 5
0x00, 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6
0x00, 0x01, 0x71, 0x09, 0x05, 0x03,// 7
0x00, 0x36, 0x49, 0x49, 0x49, 0x36,// 8
0x00, 0x06, 0x49, 0x49, 0x29, 0x1E,// 9
0x00, 0x00, 0x36, 0x36, 0x00, 0x00,// :
0x00, 0x00, 0x56, 0x36, 0x00, 0x00,// ;
0x00, 0x08, 0x14, 0x22, 0x41, 0x00,// <
0x00, 0x14, 0x14, 0x14, 0x14, 0x14,// =
0x00, 0x00, 0x41, 0x22, 0x14, 0x08,// >
0x00, 0x02, 0x01, 0x51, 0x09, 0x06,// ?
0x00, 0x32, 0x49, 0x59, 0x51, 0x3E,// @
0x00, 0x7C, 0x12, 0x11, 0x12, 0x7C,// A
0x00, 0x7F, 0x49, 0x49, 0x49, 0x36,// B
0x00, 0x3E, 0x41, 0x41, 0x41, 0x22,// C
0x00, 0x7F, 0x41, 0x41, 0x22, 0x1C,// D
0x00, 0x7F, 0x49, 0x49, 0x49, 0x41,// E
0x00, 0x7F, 0x09, 0x09, 0x09, 0x01,// F
0x00, 0x3E, 0x41, 0x49, 0x49, 0x7A,// G
0x00, 0x7F, 0x08, 0x08, 0x08, 0x7F,// H
0x00, 0x00, 0x41, 0x7F, 0x41, 0x00,// I
0x00, 0x20, 0x40, 0x41, 0x3F, 0x01,// J
0x00, 0x7F, 0x08, 0x14, 0x22, 0x41,// K
0x00, 0x7F, 0x40, 0x40, 0x40, 0x40,// L
0x00, 0x7F, 0x02, 0x0C, 0x02, 0x7F,// M
0x00, 0x7F, 0x04, 0x08, 0x10, 0x7F,// N
0x00, 0x3E, 0x41, 0x41, 0x41, 0x3E,// O
0x00, 0x7F, 0x09, 0x09, 0x09, 0x06,// P
0x00, 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q
0x00, 0x7F, 0x09, 0x19, 0x29, 0x46,// R
0x00, 0x46, 0x49, 0x49, 0x49, 0x31,// S
0x00, 0x01, 0x01, 0x7F, 0x01, 0x01,// T
0x00, 0x3F, 0x40, 0x40, 0x40, 0x3F,// U
0x00, 0x1F, 0x20, 0x40, 0x20, 0x1F,// V
0x00, 0x3F, 0x40, 0x38, 0x40, 0x3F,// W
0x00, 0x63, 0x14, 0x08, 0x14, 0x63,// X
0x00, 0x07, 0x08, 0x70, 0x08, 0x07,// Y
0x00, 0x61, 0x51, 0x49, 0x45, 0x43,// Z
0x00, 0x00, 0x7F, 0x41, 0x41, 0x00,// [
0x00, 0x55, 0x2A, 0x55, 0x2A, 0x55,// 55
0x00, 0x00, 0x41, 0x41, 0x7F, 0x00,// ]
0x00, 0x04, 0x02, 0x01, 0x02, 0x04,// ^
0x00, 0x40, 0x40, 0x40, 0x40, 0x40,// _
0x00, 0x00, 0x01, 0x02, 0x04, 0x00,// '
0x00, 0x20, 0x54, 0x54, 0x54, 0x78,// a
0x00, 0x7F, 0x48, 0x44, 0x44, 0x38,// b
0x00, 0x38, 0x44, 0x44, 0x44, 0x20,// c
0x00, 0x38, 0x44, 0x44, 0x48, 0x7F,// d
0x00, 0x38, 0x54, 0x54, 0x54, 0x18,// e
0x00, 0x08, 0x7E, 0x09, 0x01, 0x02,// f
0x00, 0x18, 0xA4, 0xA4, 0xA4, 0x7C,// g
0x00, 0x7F, 0x08, 0x04, 0x04, 0x78,// h
0x00, 0x00, 0x44, 0x7D, 0x40, 0x00,// i
0x00, 0x40, 0x80, 0x84, 0x7D, 0x00,// j
0x00, 0x7F, 0x10, 0x28, 0x44, 0x00,// k
0x00, 0x00, 0x41, 0x7F, 0x40, 0x00,// l
0x00, 0x7C, 0x04, 0x18, 0x04, 0x78,// m
0x00, 0x7C, 0x08, 0x04, 0x04, 0x78,// n
0x00, 0x38, 0x44, 0x44, 0x44, 0x38,// o
0x00, 0xFC, 0x24, 0x24, 0x24, 0x18,// p
0x00, 0x18, 0x24, 0x24, 0x18, 0xFC,// q
0x00, 0x7C, 0x08, 0x04, 0x04, 0x08,// r
0x00, 0x48, 0x54, 0x54, 0x54, 0x20,// s
0x00, 0x04, 0x3F, 0x44, 0x40, 0x20,// t
0x00, 0x3C, 0x40, 0x40, 0x20, 0x7C,// u
0x00, 0x1C, 0x20, 0x40, 0x20, 0x1C,// v
0x00, 0x3C, 0x40, 0x30, 0x40, 0x3C,// w
0x00, 0x44, 0x28, 0x10, 0x28, 0x44,// x
0x00, 0x1C, 0xA0, 0xA0, 0xA0, 0x7C,// y
0x00, 0x44, 0x64, 0x54, 0x4C, 0x44,// z
0x14, 0x14, 0x14, 0x14, 0x14, 0x14,// horiz lines