//------------------------------------------------------------------- // Shenzhen TOPWAY Technology Co.,Ltd. // LCD Module: LMT024ENHFWL // Display Size: 320*240(RGB) dots // Driver/Controller: ST7789VI // Interface: 4-SPI MODE // System: AT89s52 12MHz // Rev 00 : by Dong 2017-09-25 // note: -new; //------------------------------------------------------------------ #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 #define RED 0xf800 #define GREEN 0x07e0 #define BLUE 0x001f #define YELLOW 0xffe0 #define CYAN 0x07ff #define MAGENTA 0xf81f #define BLACK 0x0000 #define WHITE 0xffff #define GRAY 0x8410 #define hi_re 0xf800 #define hi_or 0xfc00 #define hi_ye 0xffb0 #define hi_yg 0x87e0 #define hi_gr 0x07e0 #define hi_gc 0x07f0 #define hi_cy 0x07ff #define hi_cb 0x041f #define hi_bl 0x001f #define hi_bm 0x801f #define hi_ma 0xf8f1 #define hi_mr 0xf810 #define mid_re 0x8000 #define mid_or 0x8200 #define mid_ye 0x8400 #define mid_yg 0x4400 #define mid_gr 0x0400 #define mid_gc 0x0408 #define mid_cy 0x0410 #define mid_cb 0x0210 #define mid_bl 0x0010 #define mid_bm 0x4010 #define mid_ma 0x8010 #define mid_mr 0x8008 #define GRAY00 0x0000 #define GRAY01 0x1082 #define GRAY02 0x2104 #define GRAY03 0x3186 #define GRAY04 0x4208 #define GRAY05 0x528a #define GRAY06 0x630c #define GRAY07 0x738e #define GRAY08 0x8410 #define GRAY09 0x9492 #define GRAY10 0xa514 #define GRAY11 0xb596 #define GRAY12 0xc618 #define GRAY13 0xd69a #define GRAY14 0xe71c #define GRAY15 0xffff sbit BLEN = P1^7; sbit _CS = P3^5; sbit RS = P3^3; sbit SID = P3^1; sbit SCLK = P3^2; sbit _RES = P3^4; uchar bdata transdata; // this variable could be bits variable sbit transbit = transdata^7; uchar bdata btemp; // create a bit accessable byte sbit btemp_b0 = btemp^0; sbit btemp_b1 = btemp^1; sbit btemp_b2 = btemp^2; sbit btemp_b3 = btemp^3; sbit btemp_b4 = btemp^4; sbit btemp_b5 = btemp^5; sbit btemp_b6 = btemp^6; sbit btemp_b7 = btemp^7; uint code GRAY_64[]={ 0x0000,0x0020,0x0841,0x0861, 0x1082,0x10A2,0x18C3,0x18E3, 0x2104,0x2124,0x2945,0x2965, 0x3186,0x31A6,0x39C7,0x39E7, 0x4208,0x4228,0x4A49,0x4A69, 0x528A,0x52AA,0x5ACB,0x5AEB, 0x630C,0x632C,0x6B4D,0x6B6D, 0x738E,0x73AE,0x7BCF,0x7BEF, 0x8410,0x8430,0x8C51,0x8C71, 0x9492,0x94B2,0x9CD3,0x9CF3, 0xA514,0xA534,0xAD55,0xAD75, 0xB596,0xB5B6,0xBDD7,0xBDF7, 0xC618,0xC638,0xCE59,0xCE79, 0xD69A,0xD6BA,0xDEDB,0xDEFB, 0xE71C,0xE73C,0xEF5D,0xEF7D, 0xF79E,0xF7BE,0xFFDF,0xFFFF }; uint code GRAY_16[]={ 0x0000,0x0000,0x0000,0x0000, 0x1082,0x1082,0x1082,0x1082, 0x2104,0x2104,0x2104,0x2104, 0x3186,0x3186,0x3186,0x3186, 0x4208,0x4208,0x4208,0x4208, 0x528a,0x528a,0x528a,0x528a, 0x630c,0x630c,0x630c,0x630c, 0x738e,0x738e,0x738e,0x738e, 0x8410,0x8410,0x8410,0x8410, 0x9492,0x9492,0x9492,0x9492, 0xa514,0xa514,0xa514,0xa514, 0xb596,0xb596,0xb596,0xb596, 0xc618,0xc618,0xc618,0xc618, 0xd69a,0xd69a,0xd69a,0xd69a, 0xe71c,0xe71c,0xe71c,0xe71c, 0xffff,0xffff,0xffff,0xffff }; uint code RED_64[]={ 0x0000,0x0000,0x0800,0x0800, 0x1000,0x1000,0x1800,0x1800, 0x2000,0x2000,0x2800,0x2800, 0x3000,0x3000,0x3800,0x3800, 0x4000,0x4000,0x4800,0x4800, 0x5000,0x5000,0x5800,0x5800, 0x6000,0x6000,0x6800,0x6800, 0x7000,0x7000,0x7800,0x7800, 0x8000,0x8000,0x8800,0x8800, 0x9000,0x9000,0x9800,0x9800, 0xA000,0xA000,0xA800,0xA800, 0xB000,0xB000,0xB800,0xB800, 0xC000,0xC000,0xC800,0xC800, 0xD000,0xD000,0xD800,0xD800, 0xE000,0xE000,0xE800,0xE800, 0xF000,0xF000,0xF800,0xF800 }; uint code GREEN_64[]={ 0x0000,0x0020,0x0040,0x0060, 0x0080,0x00A0,0x00C0,0x00E0, 0x0100,0x0120,0x0140,0x0160, 0x0180,0x01A0,0x01C0,0x01E0, 0x0200,0x0220,0x0240,0x0260, 0x0280,0x02A0,0x02C0,0x02E0, 0x0300,0x0320,0x0340,0x0360, 0x0380,0x03A0,0x03C0,0x03E0, 0x0400,0x0420,0x0440,0x0460, 0x0480,0x04A0,0x04C0,0x04E0, 0x0500,0x0520,0x0540,0x0560, 0x0580,0x05A0,0x05C0,0x05E0, 0x0600,0x0620,0x0640,0x0660, 0x0680,0x06A0,0x06C0,0x06E0, 0x0700,0x0720,0x0740,0x0760, 0x0780,0x07A0,0x07C0,0x07E0 }; uint code BLUE_64[]={ 0x0000,0x0000,0x0001,0x0001, 0x0002,0x0002,0x0003,0x0003, 0x0004,0x0004,0x0005,0x0005, 0x0006,0x0006,0x0007,0x0007, 0x0008,0x0008,0x0009,0x0009, 0x000A,0x000A,0x000B,0x000B, 0x000C,0x000C,0x000D,0x000D, 0x000E,0x000E,0x000F,0x000F, 0x0010,0x0010,0x0011,0x0011, 0x0012,0x0012,0x0013,0x0013, 0x0014,0x0014,0x0015,0x0015, 0x0016,0x0016,0x0017,0x0017, 0x0018,0x0018,0x0019,0x0019, 0x001A,0x001A,0x001B,0x001B, 0x001C,0x001C,0x001D,0x001D, 0x001E,0x001E,0x001F,0x001F }; uchar code monoLOGO[]={ /*-- 240x24, 1bpp --*/ 0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0xFF,0xE0,0x7F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E,0x07,0xFF,0xC0,0x01,0xFF,0xF0, 0x07,0xFF,0xC0,0x00,0x00,0x0F,0xFF,0x00,0x00,0x07,0xFF,0xFF,0xF0,0x01,0xFF,0xF0, 0x00,0x00,0x00,0xFF,0xFC,0x00,0x7F,0xFE,0x07,0xFF,0xC0,0x01,0xFF,0xF0,0x07,0xFF, 0xC0,0x00,0x00,0x0F,0xFF,0x00,0x00,0x00,0xFF,0xFF,0x80,0x01,0xFF,0xF0,0x00,0x00, 0x00,0x7F,0xF8,0x00,0x3F,0xFC,0x0F,0xFF,0x80,0x00,0xFF,0xF8,0x07,0xFF,0xC0,0x00}; uchar code monoTITLE[]={ /*-- 240x24, 1bpp --*/ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x00, 0x7C,0x1F,0x7F,0xFF,0x1F,0xFC,0x0F,0xFE,0x00,0x7C,0x7F,0xF8,0x78,0x1F,0x7C,0x1F, 0x7F,0xFF,0x7C,0x1F,0x7C,0x00,0x00,0x00,0x00,0x07,0x00,0x00,0x44,0x00,0x42,0x21, 0x40,0x01,0x20,0x02,0x10,0x01,0x00,0x84,0x40,0x04,0x44,0x11,0x44,0x11,0x40,0x01, 0x44,0x11,0x44,0x00,0x00,0x00,0x00,0x08,0x80,0x00,0x44,0x00,0x41,0x41,0x40,0x01, 0x40,0x01,0x20,0x00,0x80,0x84,0x40,0x02,0x42,0x11,0x44,0x11,0x40,0x01,0x44,0x11, 0x44,0x00,0x00,0x00,0x00,0x10,0x40,0x00,0x44,0x00,0x40,0x81,0x46,0x31,0x43,0xE1, 0x23,0xF0,0x81,0x04,0x47,0xC1,0x41,0x11,0x44,0x11,0x47,0xF1,0x44,0x11,0x44,0x00, 0x00,0x00,0x00,0x20,0x20,0x00,0x44,0x00,0x40,0x01,0x7A,0x2F,0x44,0x41,0x3C,0x08, 0x82,0x44,0x44,0x21,0x40,0x91,0x44,0x11,0x44,0x1F,0x44,0x11,0x44,0x00,0x00,0x00, 0x00,0x42,0x10,0x00,0x44,0x00,0x44,0x11,0x02,0x20,0x44,0x81,0x00,0x08,0x84,0xC4, 0x44,0x11,0x40,0x51,0x47,0xF1,0x44,0x00,0x44,0x11,0x44,0x00,0x7F,0xF8,0x00,0x85, 0x08,0x00,0x44,0x00,0x46,0x31,0x02,0x20,0x45,0x11,0x03,0xF0,0x85,0x44,0x44,0x11, 0x40,0x31,0x40,0x01,0x47,0xE0,0x44,0x91,0x44,0x00,0x40,0x08,0x01,0x08,0x84,0x00, 0x44,0x00,0x45,0x51,0x02,0x20,0x46,0x31,0x04,0x00,0x89,0x44,0x44,0x11,0x44,0x11, 0x40,0x01,0x40,0x20,0x45,0x51,0x44,0x00,0x40,0x08,0x01,0x10,0x44,0x00,0x44,0x00, 0x44,0x91,0x02,0x20,0x44,0x51,0x08,0x01,0x12,0x44,0x44,0x11,0x46,0x01,0x47,0xF1, 0x40,0x20,0x46,0x31,0x44,0x00,0x40,0x08,0x01,0x1F,0xC4,0x00,0x44,0x00,0x44,0x11, 0x02,0x20,0x40,0x91,0x11,0xFE,0x24,0x44,0x44,0x11,0x45,0x01,0x44,0x11,0x47,0xE0, 0x44,0x11,0x44,0x00,0x7F,0xF8,0x01,0x00,0x04,0x00,0x44,0x1F,0x44,0x11,0x02,0x20, 0x41,0x11,0x22,0x00,0x27,0xC6,0x44,0x21,0x44,0x81,0x44,0x11,0x44,0x00,0x40,0x01, 0x44,0x1F,0x00,0x01,0xF1,0x00,0x04,0x7C,0x47,0xF1,0x44,0x11,0x0E,0x38,0x43,0xE1, 0x23,0xFF,0xA0,0x02,0x47,0xC1,0x44,0x41,0x44,0x11,0x44,0x00,0x40,0x81,0x47,0xF1, 0x00,0x01,0x11,0x1F,0xC4,0x44,0x40,0x01,0x44,0x11,0x08,0x08,0x40,0x01,0x20,0x00, 0xA0,0x02,0x40,0x02,0x44,0x21,0x44,0x11,0x44,0x00,0x41,0x41,0x40,0x01,0x00,0x01, 0x11,0x10,0x44,0x44,0x40,0x01,0x44,0x11,0x08,0x08,0x20,0x02,0x20,0x00,0xBF,0xC6, 0x40,0x04,0x44,0x11,0x44,0x11,0x44,0x00,0x42,0x21,0x40,0x01,0x00,0x01,0x11,0x10, 0x44,0x44,0x7F,0xFF,0x7C,0x1F,0x0F,0xF8,0x1F,0xFC,0x3F,0xFF,0x80,0x7C,0x7F,0xF8, 0x7C,0x0F,0x7C,0x1F,0x7C,0x00,0x7C,0x1F,0x7F,0xFF,0x00,0x01,0xF1,0xF0,0x7C,0x7C, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0xC3,0x0E,0x00,0xE0,0x8E,0x00,0x00,0x00,0x00,0xC0,0x00,0xFB,0xEF,0x80, 0x21,0xC8,0x08,0x20,0x00,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01, 0x24,0x91,0x01,0x11,0x91,0x00,0x00,0x00,0x00,0x40,0x00,0x22,0x02,0x00,0x62,0x08, 0x00,0x20,0x00,0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x24,0x91, 0x44,0x12,0x91,0x01,0xE3,0x11,0x38,0x47,0x00,0x22,0x02,0x00,0x22,0x0F,0x18,0xF8, 0x07,0x9C,0x21,0xC5,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x41,0x11,0x28,0x24, 0x91,0x01,0x11,0x0A,0x44,0x48,0x00,0x23,0xC2,0x00,0x23,0xC8,0x88,0x20,0x08,0x22, 0x22,0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x22,0x11,0x10,0x47,0xD1,0x01, 0xE1,0x04,0x7C,0x47,0x00,0x22,0x02,0x00,0x22,0x28,0x88,0x20,0x08,0x22,0x22,0x24, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x24,0x11,0x28,0x80,0x91,0x01,0x01,0x0A, 0x40,0x40,0x80,0x22,0x02,0x00,0x22,0x28,0x88,0x20,0x08,0x22,0x22,0x24,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0xC7,0x8E,0x45,0xF0,0x8E,0x01,0x03,0x91,0x38,0xEF, 0x00,0x22,0x02,0x00,0x71,0xCF,0x1C,0x18,0x07,0x9C,0x71,0xC4,0x00,0x00,0x00,0x00 }; //----------------------------------- // delayms routine //----------------------------------- void delayms(uint m) // 12MHz Xtal, close to ms value { uint j; uint i; for(i=0; i>8; temp2=Ddata; _CS = 1; SCLK = 1; RS = 1; SID = 1; for (i=0;i<19200;i++) { SdData(temp1); SdData(temp2); SdData(temp1); SdData(temp2); SdData(temp1); SdData(temp2); SdData(temp1); SdData(temp2); } } //=========填充块2,半色块===================== void ColorBOX2() { uint i; uchar temp1,temp2; _CS = 1; SCLK = 1; RS = 1; SID = 1; SdCmd(0x2a);SdData(0x00);SdData(0x00);SdData(0x00);SdData(0x37); SdCmd(0x2b);SdData(0x00);SdData(0x12);SdData(0x00);SdData(0x49); SdCmd(0x2c); temp1=mid_re>>8;temp2=mid_re; for (i=0;i<3360;i++) { SdData(temp1); SdData(temp2); } SdCmd(0x2a);SdData(0x00);SdData(0x41);SdData(0x00);SdData(0x7c); SdCmd(0x2b);SdData(0x00);SdData(0x12);SdData(0x00);SdData(0x49); SdCmd(0x2c); temp1=mid_or>>8;temp2=mid_or; for (i=0;i<3360;i++) { SdData(temp1); SdData(temp2); } SdCmd(0x2a);SdData(0x00);SdData(0x82);SdData(0x00);SdData(0xbd); SdCmd(0x2b);SdData(0x00);SdData(0x12);SdData(0x00);SdData(0x49); SdCmd(0x2c); temp1=mid_ye>>8;temp2=mid_ye; for (i=0;i<3360;i++) { SdData(temp1); SdData(temp2); } SdCmd(0x2a);SdData(0x00);SdData(0xc3);SdData(0x00);SdData(0xfe); SdCmd(0x2b);SdData(0x00);SdData(0x12);SdData(0x00);SdData(0x49); SdCmd(0x2c); temp1=mid_yg>>8;temp2=mid_yg; for (i=0;i<3360;i++) { SdData(temp1); SdData(temp2); } SdCmd(0x2a);SdData(0x01);SdData(0x04);SdData(0x01);SdData(0x3f); SdCmd(0x2b);SdData(0x00);SdData(0x12);SdData(0x01);SdData(0x49); SdCmd(0x2c); temp1=mid_gr>>8;temp2=mid_gr; for (i=0;i<3360;i++) { SdData(temp1); SdData(temp2); } //------------------------------------------------------------------ SdCmd(0x2a);SdData(0x00);SdData(0x00);SdData(0x00);SdData(0x37); SdCmd(0x2b);SdData(0x00);SdData(0x5c);SdData(0x00);SdData(0x93); SdCmd(0x2c); temp1=mid_gc>>8;temp2=mid_gc; for (i=0;i<3360;i++) { SdData(temp1); SdData(temp2); } SdCmd(0x2a);SdData(0x01);SdData(0x04);SdData(0x01);SdData(0x3f); SdCmd(0x2b);SdData(0x00);SdData(0x5c);SdData(0x00);SdData(0x93); SdCmd(0x2c); temp1=mid_cy>>8;temp2=mid_cy; for (i=0;i<3360;i++) { SdData(temp1); SdData(temp2); } //----------------------------------------------------------------- SdCmd(0x2a);SdData(0x00);SdData(0x00);SdData(0x00);SdData(0x37); SdCmd(0x2b);SdData(0x00);SdData(0xa6);SdData(0x00);SdData(0xdd); SdCmd(0x2c); temp1=mid_cb>>8;temp2=mid_cb; for (i=0;i<3360;i++) { SdData(temp1); SdData(temp2); } SdCmd(0x2a);SdData(0x00);SdData(0x41);SdData(0x00);SdData(0x7c); SdCmd(0x2b);SdData(0x00);SdData(0xa6);SdData(0x00);SdData(0xdd); SdCmd(0x2c); temp1=mid_bl>>8;temp2=mid_bl; for (i=0;i<3360;i++) { SdData(temp1); SdData(temp2); } SdCmd(0x2a);SdData(0x00);SdData(0x82);SdData(0x00);SdData(0xbd); SdCmd(0x2b);SdData(0x00);SdData(0xa6);SdData(0x00);SdData(0xdd); SdCmd(0x2c); temp1=mid_bm>>8;temp2=mid_bm; for (i=0;i<3360;i++) { SdData(temp1); SdData(temp2); } SdCmd(0x2a);SdData(0x00);SdData(0xc3);SdData(0x00);SdData(0xfe); SdCmd(0x2b);SdData(0x00);SdData(0xa6);SdData(0x00);SdData(0xdd); SdCmd(0x2c); temp1=mid_ma>>8;temp2=mid_ma; for (i=0;i<3360;i++) { SdData(temp1); SdData(temp2); } SdCmd(0x2a);SdData(0x01);SdData(0x04);SdData(0x01);SdData(0x3f); SdCmd(0x2b);SdData(0x00);SdData(0xa6);SdData(0x00);SdData(0xdd); SdCmd(0x2c); temp1=mid_mr>>8;temp2=mid_mr; for (i=0;i<3360;i++) { SdData(temp1); SdData(temp2); } } void monoFill240x24(uint X, uint Y, fg_color, bg_color, uchar *Data ) // show mono data on display with 1=fg_color & 0=bg_color { uchar temp1, temp2; uchar fg_hi, fg_lo; uchar bg_hi, bg_lo; uint i; #define Mbox_w 240 #define Mbox_h 24 SdCmd(0x2a); // set_column_address temp1 = X>>8; temp2 = X; // mask the upper byte SdData(temp1); SdData(temp2); X=X+Mbox_w-1; temp1 = X>>8; // move the upper byte to low byte temp2 = X; // mask the upper byte SdData(temp1); SdData(temp2); SdCmd(0x2b); // set_page_address temp1 = Y>>8; // move the upper byte to low byte temp2 = Y; // mask the upper byte SdData(temp1); SdData(temp2); Y=Y+Mbox_h-1; temp1 = Y>>8; // move the upper byte to low byte temp2 = Y; // mask the upper byte SdData(temp1); SdData(temp2); fg_hi=fg_color>>8; fg_lo=fg_color; bg_hi=bg_color>>8; bg_lo=bg_color; SdCmd(0x2c);// write_memory_start _CS=0; for (i=0; i<(Mbox_w*Mbox_h/8); i++) { btemp=*(Data+i); if (btemp_b7) {SdData(fg_hi); SdData(fg_lo);} else {SdData(bg_hi); SdData(bg_lo);} if (btemp_b6) {SdData(fg_hi); SdData(fg_lo);} else {SdData(bg_hi); SdData(bg_lo);} if (btemp_b5) {SdData(fg_hi); SdData(fg_lo);} else {SdData(bg_hi); SdData(bg_lo);} if (btemp_b4) {SdData(fg_hi); SdData(fg_lo);} else {SdData(bg_hi); SdData(bg_lo);} if (btemp_b3) {SdData(fg_hi); SdData(fg_lo);} else {SdData(bg_hi); SdData(bg_lo);} if (btemp_b2) {SdData(fg_hi); SdData(fg_lo);} else {SdData(bg_hi); SdData(bg_lo);} if (btemp_b1) {SdData(fg_hi); SdData(fg_lo);} else {SdData(bg_hi); SdData(bg_lo);} if (btemp_b0) {SdData(fg_hi); SdData(fg_lo);} else {SdData(bg_hi); SdData(bg_lo);} } _CS=1; } //--IC intialize------------------------ void initLCDM(void) { _RES=1; delayms(10); _RES=0; delayms(10); _RES=1; delayms(800); _CS = 1; SCLK = 1; RS = 1; SID = 1; SdCmd(0x11); //Sleep mode out delayms(120); // delya /****************************************************/ SdCmd(0x36); //Memory data access Control SdData(0x60); // MY = 0: Page address TOP to Bottom;MX=1:column address right to Left;RGB mode SdCmd(0x3a); SdData(0x55); // TFT RGB = 565 ;MCU = 16 bit SdCmd(0xb2); SdData(0x0c); SdData(0x0c); SdData(0x00); SdData(0x33); SdData(0x33); SdCmd(0xb7); SdData(0x35); SdCmd(0xbb); SdData(0x20); //35 SdCmd(0xc0); SdData(0x2c); SdCmd(0xc2); SdData(0x01); SdCmd(0xc3); SdData(0x0B); //11 SdCmd(0xc4); SdData(0x20); SdCmd(0xc6); SdData(0x0f); SdCmd(0xd0); SdData(0xa4); SdData(0xa1); SdCmd(0xe0); SdData(0xd0); SdData(0x00); SdData(0x03); SdData(0x08); SdData(0x0A); SdData(0x17); SdData(0x2E); SdData(0x44); SdData(0x3F); SdData(0x29); SdData(0x10); SdData(0x0E); SdData(0x14); SdData(0x18); SdCmd(0xe1); SdData(0xd0); SdData(0x00); SdData(0x03); SdData(0x08); SdData(0x07); SdData(0x27); SdData(0x2B); SdData(0x44); SdData(0x41); SdData(0x3C); SdData(0x1B); SdData(0x1D); SdData(0x14); SdData(0x18); SdCmd(0x55); // 色彩增强 SdCmd(0x29); //Display on } //----------------------------------- // Main Program //----------------------------------- void main() { SP=0x60; EA=0; BLEN = 0; // close Backlight _CS = 1; SCLK = 1; RS = 1; SID = 1; initLCDM(); BLEN = 0; // open Backlight FillFullScn(BLACK); // Clear screen ColorBOX2(); monoFill240x24(40, 98, GRAY04, BLACK, monoLOGO); monoFill240x24(40, 124, GRAY04, BLACK, monoTITLE); while(1); }