//---------------------------------------------------- // Shenzhen TOPWAY Technology Co.,Ltd. // LCD Module: LM32019C // Display Size: 320x240 dots // Controller: T8000 // by: GuoQ // Date: 2010-11-3 // note: set RD=1 //---------------------------------------------------- #include #include #include #define uchar unsigned char // 8bit, 0 ~ 255 #define uint unsigned int // 16bit, 0 ~ 65,535 #define ulong unsigned long // 32bit, 0 ~ 4,294,967,295 uchar Picgray; // high 4 bits = Font gray,low 4 bits = Ground gray #define LCDBUS P1 sbit A1 = P3^6; sbit _WR = P3^7; sbit _RD = P3^1; sbit _CS = P3^4; sbit _RES = P3^5; //----------------------------------- // delayms routine //----------------------------------- void delayms(uint m) // 12MHz Xtal, close to ms value { uint j; uint i; for(i=0; i>8; WritePKG(Buffer); Picgray=(Picgray&0x0f)|(color<<4); } //----------------------------------------- void SetFontFgColor(uint color) { uchar Buffer[4]; Buffer[0]=3; Buffer[1]=0x14; Buffer[2]=color; Buffer[3]=color>>8; WritePKG(Buffer); } //--------------------------------------- void SetFontBgColor(uint color) { uchar Buffer[4]; Buffer[0]=3; Buffer[1]=0x15; Buffer[2]=color; Buffer[3]=color>>8; WritePKG(Buffer); Picgray=(Picgray&0xf0)|color; } //----------------------------------- //character write program //----------------------------------- //--------ASCII code write-------------- void PrintASCII(uint X, Y, uchar *pstr) // x value must be the time of 4 { uchar TempData[3], Buffer[6], NoOfChar; TempData[0]=2; // TempData[1]=0x10; TempData[2]=0x00; WritePKG(TempData); Buffer[0]=5; // Buffer[1]=0x12; Buffer[2]=X; Buffer[3]=X>>8; Buffer[4]=Y; Buffer[5]=Y>>8; WritePKG(Buffer); NoOfChar=strlen(pstr); // SdCmd(0x17); // SdCmd(NoOfChar); while(*pstr>0) { SdCmd(*pstr++); } CmdEnd(); } //-----chinese code write ------------------ void PrintGB(uint X, Y, uchar *pstr) // x value must be the time of 4 { uchar Buffer[6]; uint NoOfChar; Buffer[0]=2; // Buffer[1]=0x10; Buffer[2]=0x04; WritePKG(Buffer); Buffer[0]=5; // Buffer[1]=0x12; Buffer[2]=X; Buffer[3]=X>>8; Buffer[4]=Y; Buffer[5]=Y>>8; WritePKG(Buffer); NoOfChar=strlen(pstr); // SdCmd(0x17); // SdCmd(NoOfChar/2); // while(*pstr>0) { SdCmd(*pstr++); } CmdEnd(); delayms(3); // } //--------fill in full screen------------ void Fill_Rect(uint x1, y1, x2, y2) { uchar Buffer[10]; Buffer[0]=9; Buffer[1]=0x27; // Buffer[2]=x1; // Buffer[3]=x1>>8; Buffer[4]=y1; Buffer[5]=y1>>8; Buffer[6]=x2; Buffer[7]=x2>>8; Buffer[8]=y2; Buffer[9]=y2>>8; WritePKG(Buffer); delayms(20); } //----------------------------------- // Display set //----------------------------------- void LogoScreen(void) { SetFgColor(0); Fill_Rect( 0, 0,320,240); //fill the full screen SetFontFgColor(3);SetFontBgColor(0); PrintGB( 48, 16, "????????????????????????"); PrintASCII(40,40, " TOPWAY Technology Co,. Ltd "); SetFontFgColor(2);SetFontBgColor(0); PrintGB( 0, 64, "???????????????????????á???????????"); PrintASCII( 12, 88, " 320 x 240 Pixels T8000 Controller "); SetFgColor(1); Fill_Rect( 45, 100,260,180); delayms(10); SetFontFgColor(3);SetFontBgColor(1); PrintGB( 48, 103, "??????μ?????"); PrintGB( 48, 123, "??????????????"); PrintGB( 48, 143, "??????????????????"); PrintGB( 48, 163, "?????????????????????"); SetFontFgColor(1);SetFontBgColor(2); PrintGB( 0, 207, "?????????????????????????????????"); PrintGB( 0, 223, "????????????????????????????"); } //--------------------------------------------- //inital program //--------------------------------------------- //-----------ROM SET------------------------ uchar code Set_F504[]={4,0x83,0x04,0xf5,0x44}; // uchar code Set_F505[]={4,0x83,0x05,0xf5,0x80}; uchar code Set_F6C4[]={4,0x83,0xc4,0xf6,0x10}; //----------STN SET------------------------- uchar code Set_F08B[]={4,0x83,0x8b,0xf0,0x00};// uchar code Set_F08C[]={4,0x83,0x8c,0xf0,0x00};// uchar code Set_F08D[]={4,0x83,0x8d,0xf0,0x00};// uchar code Set_F08E[]={4,0x83,0x8e,0xf0,0x32}; // uchar code Set_F088[]={4,0x83,0x88,0xf0,0x50}; uchar code Set_F089[]={4,0x83,0x89,0xf0,0xfa}; //---------CLOCK SET---------------------------- uchar code Set_8F[]={7,0x8f,0x69,0x45,0x61,0x67,0x6c,0x65}; //---------------------------------------------- //----inital program------------------------- void initLCDM(void) { //------ ROM SET----------------- WritePKG(Set_F504); WritePKG(Set_F505); WritePKG(Set_F6C4); //------ STN SET----------------- WritePKG(Set_F088); WritePKG(Set_F089); WritePKG(Set_F08E); //------ CLOCK SET--------------- WritePKG(Set_8F); } //----------------------------------- // Main Program //----------------------------------- void main() { // uint i,j; // uchar Buffer[5]; SP=0x60; EA=0; LCDBUS=0xff; // init all the port _CS=1; _RES=1; A1=0; _WR=1; _RD=1; _RES=1; _RES=0; delayms(2); _RES=1; delayms(800); initLCDM(); LogoScreen(); while(1) { } }