//------------------------------------------------- // Shenzhen TOPWAY Technology Co.,Ltd. // LCD Module: LM12832C // Display Size: 128x32 // Driver/Controller: ST7567 // Interface: 80 mode // by: Dongq // Date: 2014-4-12 //------------------------------------------------- #include #include #include #define uchar unsigned char // 0~255 #define uint unsigned int // 0~65535 #define LCDBus P1 sbit _CS1 = P3^3; sbit _RST = P3^5; sbit RS = P3^6; sbit _WR = P3^1; sbit _RD = P3^7; sbit _KeySel = P3^0; // _KeySel=0, key scanning active sbit _KeyAuto = P1^0; // _KeyAuto=0, key pressed sbit _KeyDarker = P1^1; // _KeyDarker=0, key pressed sbit _KeyLighter = P1^2; // _KeyLighter=0,key pressed sbit _KeyStep = P1^3; // _KeyStep=0, key pressed bit AutoRun; // 1 for auto run, 0 for manual run uchar ContrastLevel; // for contrast setting level //----------------------------------- // dispaly data (128x32) //----------------------------------- uchar code Logo[]={ /*-- invoking topway logo picture??12832c.bmp --*/ /*-- width x height = 128 x 32 --*/ 0x07,0x01,0x01,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x40,0x80,0x40,0x80,0x40,0x80, 0x40,0x80,0x40,0xA0,0x40,0xA0,0x40,0xA0,0x50,0xA0,0x50,0xA0,0x50,0xA8,0x50,0xA8, 0x50,0xA8,0x54,0xA8,0x54,0x28,0x14,0xAA,0x94,0xCA,0xC4,0xEA,0xE4,0xE2,0xF4,0xF2, 0xF8,0xFA,0xF8,0xF8,0xFC,0xFC,0xFC,0xFC,0xFC,0xFC,0x00,0x00,0x00,0x00,0x00,0x40, 0x88,0xD0,0x00,0xB0,0x50,0x30,0x90,0x30,0x50,0xB0,0x00,0x40,0x40,0xF8,0x40,0x40, 0xF8,0x00,0xF0,0x00,0x00,0xF8,0x00,0x20,0x20,0xF8,0x20,0x10,0x90,0x70,0x10,0x10, 0x10,0x10,0x00,0x80,0xB0,0xD0,0x98,0xF0,0x90,0xF0,0x98,0xD0,0xB0,0x80,0x00,0x20, 0x98,0x70,0x40,0x78,0x40,0x70,0x80,0x78,0xC0,0x40,0x00,0x00,0x00,0x01,0x01,0x07, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x80,0x41,0xA8,0x55,0xAA,0x55,0xAA,0x55,0x2A,0x95,0xCA,0xE5,0xF2, 0xF9,0xF8,0xFD,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x08, 0x3F,0x00,0x12,0x0A,0x06,0x02,0x3F,0x06,0x0A,0x12,0x00,0x08,0x08,0x27,0x24,0x10, 0x0F,0x00,0x1F,0x00,0x00,0x3F,0x00,0x22,0x22,0x3F,0x05,0x02,0x3F,0x11,0x11,0x11, 0x3F,0x00,0x00,0x00,0x00,0x3E,0x2A,0x2A,0x2A,0x2A,0x2A,0x3E,0x00,0x00,0x00,0x01, 0x3F,0x21,0x1D,0x05,0x1D,0x29,0x13,0x0C,0x13,0x20,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80, 0x40,0xA8,0x54,0x2A,0x95,0xCA,0xE5,0xF2,0xF9,0xFC,0xFE,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x02,0x02,0x02,0x02,0x02,0xF2, 0x02,0x02,0x02,0x02,0x02,0x02,0xF2,0x62,0x82,0x02,0x02,0x02,0x82,0x62,0xF2,0x02, 0x02,0x42,0x22,0xF2,0x02,0x02,0x02,0x22,0x12,0x12,0x12,0x12,0xE2,0x02,0xE2,0x12, 0x12,0x12,0x12,0xE2,0x02,0x22,0x12,0x12,0x12,0x12,0xE2,0x02,0x22,0x12,0x12,0x12, 0x12,0xE2,0x02,0x02,0xC2,0x22,0x12,0x12,0x12,0x22,0x42,0x02,0x02,0x02,0x00,0x00, 0xE0,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x20,0x94,0xCA, 0xE1,0xF8,0xFC,0xFF,0xFF,0xFB,0xFB,0xC3,0xFB,0xFB,0xFF,0xE7,0xDB,0xDB,0xDB,0xE7, 0xFF,0xC3,0xEB,0xEB,0xEB,0xF7,0xFF,0xE3,0xDF,0xEF,0xDF,0xE3,0xFF,0xCF,0xE7,0xEB, 0xE7,0xCF,0xFF,0xFB,0xF7,0xCF,0xF7,0xFB,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x3F, 0x20,0x20,0x20,0x20,0x20,0x00,0x3F,0x00,0x01,0x0E,0x30,0x0E,0x01,0x00,0x3F,0x00, 0x00,0x00,0x00,0x3F,0x00,0x00,0x00,0x20,0x30,0x28,0x24,0x22,0x21,0x00,0x1E,0x21, 0x21,0x21,0x21,0x1E,0x00,0x10,0x20,0x21,0x21,0x21,0x1E,0x00,0x20,0x30,0x28,0x24, 0x22,0x21,0x00,0x00,0x0F,0x10,0x20,0x20,0x20,0x10,0x08,0x00,0x00,0x80,0x80,0xE0 }; //----------------------------------- // Delay Routine //----------------------------------- void delayms(uint m) // 12MHz Xtal, close to ms value { uint j; uint i; for(i=0; i0x00) { ContrastLevel--; } SdCmd(0x81); // E-Vol setting SdCmd(ContrastLevel); // (2byte command) } //----------------------------------- // Init LCD module //----------------------------------- void initLCDM(void) { _RST=1; // hardware reset LCD module _RST=0; delayms(10); _RST=1; delayms(100); ContrastLevel=0x28; // Default Contrast Level SdCmd(0xaf); // Display on SdCmd(0x40); // Set display Start line=0 SdCmd(0xa0); // ADC =0 :SEG1->SEG128 SdCmd(0xa6); // Normal display SdCmd(0xa4); // Disable display all point SdCmd(0xa3); // Bais = 1/5 (duty=1/33) SdCmd(0xc8); // Common output mode select= reverse:C65->C1 SdCmd(0x2f); // Power control = all on SdCmd(0x23); // RA/RB setting SdCmd(0xf8); // Booster Ratio = 4x SdCmd(0x00); // (two byte command) SdCmd(0x81); // E-Vol setting SdCmd(ContrastLevel); // (two byte command) } //----------------------------------- // Main Program //----------------------------------- void main() { SP=0x60; EA = 0; // disable interrupts AutoRun=0; _CS1 = 1; _RST = 1; RS = 1; _WR = 1; _RD = 1; _KeySel=1; // key not select initLCDM(); while(1) { WriteScreen(Logo); } } //end of program