ITEAD 2.4E LCD Interface 8 Bit Parallel Mode

Dependencies:   mbed

Committer:
techneo
Date:
Wed Feb 20 15:13:20 2013 +0000
Revision:
0:217105958c2d
working module

Who changed what in which revision?

UserRevisionLine numberNew contents of line
techneo 0:217105958c2d 1 #include "lcd_driver.h"
techneo 0:217105958c2d 2
techneo 0:217105958c2d 3
techneo 0:217105958c2d 4 #define LCD_DRIVER_C
techneo 0:217105958c2d 5
techneo 0:217105958c2d 6 #include "mbed.h"
techneo 0:217105958c2d 7
techneo 0:217105958c2d 8 //lsb .. msb
techneo 0:217105958c2d 9 BusOut LCD_DataBus(p13,p14,p15,p16,p17,p18,p19,p20);
techneo 0:217105958c2d 10
techneo 0:217105958c2d 11
techneo 0:217105958c2d 12 DigitalOut RS(p21);
techneo 0:217105958c2d 13 DigitalOut WR(p22);
techneo 0:217105958c2d 14 DigitalOut RD(p23);
techneo 0:217105958c2d 15 DigitalOut CS(p24);
techneo 0:217105958c2d 16 DigitalOut RST(p25);
techneo 0:217105958c2d 17
techneo 0:217105958c2d 18
techneo 0:217105958c2d 19 void Write_Command(unsigned int c)
techneo 0:217105958c2d 20 {
techneo 0:217105958c2d 21 RS = 0;
techneo 0:217105958c2d 22 Write(c);
techneo 0:217105958c2d 23 }
techneo 0:217105958c2d 24
techneo 0:217105958c2d 25 void Write_Data(unsigned int c)
techneo 0:217105958c2d 26 {
techneo 0:217105958c2d 27 RS = 1;
techneo 0:217105958c2d 28 Write(c);
techneo 0:217105958c2d 29 }
techneo 0:217105958c2d 30
techneo 0:217105958c2d 31 void Write(unsigned int c)
techneo 0:217105958c2d 32 {
techneo 0:217105958c2d 33 LCD_DataBus = c >> 8;
techneo 0:217105958c2d 34 WR = 0;
techneo 0:217105958c2d 35 WR = 1;
techneo 0:217105958c2d 36
techneo 0:217105958c2d 37 LCD_DataBus = c;
techneo 0:217105958c2d 38 WR = 0;
techneo 0:217105958c2d 39 WR = 1;
techneo 0:217105958c2d 40
techneo 0:217105958c2d 41 }
techneo 0:217105958c2d 42
techneo 0:217105958c2d 43 void Write_Command_Data(unsigned int cmd,unsigned int dat)
techneo 0:217105958c2d 44 {
techneo 0:217105958c2d 45 Write_Command(cmd);
techneo 0:217105958c2d 46 Write_Data(dat);
techneo 0:217105958c2d 47 }
techneo 0:217105958c2d 48
techneo 0:217105958c2d 49
techneo 0:217105958c2d 50 void Lcd_Init()
techneo 0:217105958c2d 51 {
techneo 0:217105958c2d 52
techneo 0:217105958c2d 53 digitalWrite(RD,HIGH);
techneo 0:217105958c2d 54 digitalWrite(CS,HIGH);
techneo 0:217105958c2d 55 digitalWrite(WR,HIGH);
techneo 0:217105958c2d 56
techneo 0:217105958c2d 57 digitalWrite(RST,HIGH);
techneo 0:217105958c2d 58 delay(1);
techneo 0:217105958c2d 59 digitalWrite(RST,LOW);
techneo 0:217105958c2d 60 delay(10);
techneo 0:217105958c2d 61 delay(1);
techneo 0:217105958c2d 62 digitalWrite(RST,HIGH);
techneo 0:217105958c2d 63
techneo 0:217105958c2d 64 CS = 0;
techneo 0:217105958c2d 65
techneo 0:217105958c2d 66 Write_Command_Data(0x0011,0x2004);
techneo 0:217105958c2d 67 Write_Command_Data(0x0013,0xCC00);
techneo 0:217105958c2d 68 Write_Command_Data(0x0015,0x2600);
techneo 0:217105958c2d 69 Write_Command_Data(0x0014,0x252A);
techneo 0:217105958c2d 70 // Write_Command_Data(0x14,0x002A);
techneo 0:217105958c2d 71 Write_Command_Data(0x0012,0x0033);
techneo 0:217105958c2d 72 Write_Command_Data(0x0013,0xCC04);
techneo 0:217105958c2d 73 //delayms(1);
techneo 0:217105958c2d 74 Write_Command_Data(0x0013,0xCC06);
techneo 0:217105958c2d 75 //delayms(1);
techneo 0:217105958c2d 76 Write_Command_Data(0x0013,0xCC4F);
techneo 0:217105958c2d 77 //delayms(1);
techneo 0:217105958c2d 78 Write_Command_Data(0x0013,0x674F);
techneo 0:217105958c2d 79 Write_Command_Data(0x0011,0x2003);
techneo 0:217105958c2d 80 //delayms(1);
techneo 0:217105958c2d 81 Write_Command_Data(0x0030,0x2609);
techneo 0:217105958c2d 82 Write_Command_Data(0x0031,0x242C);
techneo 0:217105958c2d 83 Write_Command_Data(0x0032,0x1F23);
techneo 0:217105958c2d 84 Write_Command_Data(0x0033,0x2425);
techneo 0:217105958c2d 85 Write_Command_Data(0x0034,0x2226);
techneo 0:217105958c2d 86 Write_Command_Data(0x0035,0x2523);
techneo 0:217105958c2d 87 Write_Command_Data(0x0036,0x1C1A);
techneo 0:217105958c2d 88 Write_Command_Data(0x0037,0x131D);
techneo 0:217105958c2d 89 Write_Command_Data(0x0038,0x0B11);
techneo 0:217105958c2d 90 Write_Command_Data(0x0039,0x1210);
techneo 0:217105958c2d 91 Write_Command_Data(0x003A,0x1315);
techneo 0:217105958c2d 92 Write_Command_Data(0x003B,0x3619);
techneo 0:217105958c2d 93 Write_Command_Data(0x003C,0x0D00);
techneo 0:217105958c2d 94 Write_Command_Data(0x003D,0x000D);
techneo 0:217105958c2d 95 Write_Command_Data(0x0016,0x0007);
techneo 0:217105958c2d 96 Write_Command_Data(0x0002,0x0013);
techneo 0:217105958c2d 97 Write_Command_Data(0x0003,0x0003);
techneo 0:217105958c2d 98 Write_Command_Data(0x0001,0x0127);
techneo 0:217105958c2d 99 //delayms(1);
techneo 0:217105958c2d 100 Write_Command_Data(0x0008,0x0303);
techneo 0:217105958c2d 101 Write_Command_Data(0x000A,0x000B);
techneo 0:217105958c2d 102 Write_Command_Data(0x000B,0x0003);
techneo 0:217105958c2d 103 Write_Command_Data(0x000C,0x0000);
techneo 0:217105958c2d 104 Write_Command_Data(0x0041,0x0000);
techneo 0:217105958c2d 105 Write_Command_Data(0x0050,0x0000);
techneo 0:217105958c2d 106 Write_Command_Data(0x0060,0x0005);
techneo 0:217105958c2d 107 Write_Command_Data(0x0070,0x000B);
techneo 0:217105958c2d 108 Write_Command_Data(0x0071,0x0000);
techneo 0:217105958c2d 109 Write_Command_Data(0x0078,0x0000);
techneo 0:217105958c2d 110 Write_Command_Data(0x007A,0x0000);
techneo 0:217105958c2d 111 Write_Command_Data(0x0079,0x0007);
techneo 0:217105958c2d 112 Write_Command_Data(0x0007,0x0051);
techneo 0:217105958c2d 113 //delayms(1);
techneo 0:217105958c2d 114 Write_Command_Data(0x0007,0x0053);
techneo 0:217105958c2d 115 Write_Command_Data(0x0079,0x0000);
techneo 0:217105958c2d 116
techneo 0:217105958c2d 117 Write_Command(0x0022);
techneo 0:217105958c2d 118
techneo 0:217105958c2d 119
techneo 0:217105958c2d 120 }
techneo 0:217105958c2d 121
techneo 0:217105958c2d 122 void SetXY(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1)
techneo 0:217105958c2d 123 {
techneo 0:217105958c2d 124 Write_Command_Data(0x0046,(x1 << 8)| x0);
techneo 0:217105958c2d 125 //Write_Command_Data(0x0047,x1);
techneo 0:217105958c2d 126 Write_Command_Data(0x0047,y1);
techneo 0:217105958c2d 127 Write_Command_Data(0x0048,y0);
techneo 0:217105958c2d 128 Write_Command_Data(0x0020,x0);
techneo 0:217105958c2d 129 Write_Command_Data(0x0021,y0);
techneo 0:217105958c2d 130 Write_Command (0x0022);//LCD_WriteCMD(GRAMWR);
techneo 0:217105958c2d 131 }
techneo 0:217105958c2d 132 void Pant(unsigned int color)
techneo 0:217105958c2d 133 {
techneo 0:217105958c2d 134 int i,j;
techneo 0:217105958c2d 135 int color_test;
techneo 0:217105958c2d 136 color_test = 0;
techneo 0:217105958c2d 137 SetXY(0,239,0,319);
techneo 0:217105958c2d 138 //SetXY(0,120,0,120);
techneo 0:217105958c2d 139
techneo 0:217105958c2d 140 for(i=0;i<320;i++)
techneo 0:217105958c2d 141 {
techneo 0:217105958c2d 142 for (j=0;j<240;j++)
techneo 0:217105958c2d 143 {
techneo 0:217105958c2d 144 Write_Data(color_test);
techneo 0:217105958c2d 145 color_test+=10;
techneo 0:217105958c2d 146 }
techneo 0:217105958c2d 147
techneo 0:217105958c2d 148 }
techneo 0:217105958c2d 149 }
techneo 0:217105958c2d 150 void LCD_clear()
techneo 0:217105958c2d 151 {
techneo 0:217105958c2d 152 unsigned int i,j;
techneo 0:217105958c2d 153 SetXY(0,239,0,319);
techneo 0:217105958c2d 154 for(i=0;i<X_CONST;i++)
techneo 0:217105958c2d 155 {
techneo 0:217105958c2d 156 for(j=0;j<Y_CONST;j++)
techneo 0:217105958c2d 157 {
techneo 0:217105958c2d 158 Write_Data(0x0000);
techneo 0:217105958c2d 159 }
techneo 0:217105958c2d 160 }
techneo 0:217105958c2d 161 }
techneo 0:217105958c2d 162
techneo 0:217105958c2d 163
techneo 0:217105958c2d 164 #undef LCD_DRIVER_C