Surendrakumar Paulraj
/
itead_lcd1
ITEAD 2.4E LCD Interface 8 Bit Parallel Mode
Revision 0:217105958c2d, committed 2013-02-20
- Comitter:
- techneo
- Date:
- Wed Feb 20 15:13:20 2013 +0000
- Commit message:
- working module
Changed in this revision
diff -r 000000000000 -r 217105958c2d lcd_driver.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lcd_driver.cpp Wed Feb 20 15:13:20 2013 +0000 @@ -0,0 +1,164 @@ +#include "lcd_driver.h" + + +#define LCD_DRIVER_C + +#include "mbed.h" + +//lsb .. msb +BusOut LCD_DataBus(p13,p14,p15,p16,p17,p18,p19,p20); + + +DigitalOut RS(p21); +DigitalOut WR(p22); +DigitalOut RD(p23); +DigitalOut CS(p24); +DigitalOut RST(p25); + + +void Write_Command(unsigned int c) +{ + RS = 0; + Write(c); +} + +void Write_Data(unsigned int c) +{ + RS = 1; + Write(c); +} + +void Write(unsigned int c) +{ + LCD_DataBus = c >> 8; + WR = 0; + WR = 1; + + LCD_DataBus = c; + WR = 0; + WR = 1; + +} + +void Write_Command_Data(unsigned int cmd,unsigned int dat) +{ + Write_Command(cmd); + Write_Data(dat); +} + + +void Lcd_Init() +{ + + digitalWrite(RD,HIGH); + digitalWrite(CS,HIGH); + digitalWrite(WR,HIGH); + + digitalWrite(RST,HIGH); + delay(1); + digitalWrite(RST,LOW); + delay(10); + delay(1); + digitalWrite(RST,HIGH); + + CS = 0; + + Write_Command_Data(0x0011,0x2004); + Write_Command_Data(0x0013,0xCC00); + Write_Command_Data(0x0015,0x2600); + Write_Command_Data(0x0014,0x252A); +// Write_Command_Data(0x14,0x002A); + Write_Command_Data(0x0012,0x0033); + Write_Command_Data(0x0013,0xCC04); + //delayms(1); + Write_Command_Data(0x0013,0xCC06); + //delayms(1); + Write_Command_Data(0x0013,0xCC4F); + //delayms(1); + Write_Command_Data(0x0013,0x674F); + Write_Command_Data(0x0011,0x2003); + //delayms(1); + Write_Command_Data(0x0030,0x2609); + Write_Command_Data(0x0031,0x242C); + Write_Command_Data(0x0032,0x1F23); + Write_Command_Data(0x0033,0x2425); + Write_Command_Data(0x0034,0x2226); + Write_Command_Data(0x0035,0x2523); + Write_Command_Data(0x0036,0x1C1A); + Write_Command_Data(0x0037,0x131D); + Write_Command_Data(0x0038,0x0B11); + Write_Command_Data(0x0039,0x1210); + Write_Command_Data(0x003A,0x1315); + Write_Command_Data(0x003B,0x3619); + Write_Command_Data(0x003C,0x0D00); + Write_Command_Data(0x003D,0x000D); + Write_Command_Data(0x0016,0x0007); + Write_Command_Data(0x0002,0x0013); + Write_Command_Data(0x0003,0x0003); + Write_Command_Data(0x0001,0x0127); + //delayms(1); + Write_Command_Data(0x0008,0x0303); + Write_Command_Data(0x000A,0x000B); + Write_Command_Data(0x000B,0x0003); + Write_Command_Data(0x000C,0x0000); + Write_Command_Data(0x0041,0x0000); + Write_Command_Data(0x0050,0x0000); + Write_Command_Data(0x0060,0x0005); + Write_Command_Data(0x0070,0x000B); + Write_Command_Data(0x0071,0x0000); + Write_Command_Data(0x0078,0x0000); + Write_Command_Data(0x007A,0x0000); + Write_Command_Data(0x0079,0x0007); + Write_Command_Data(0x0007,0x0051); + //delayms(1); + Write_Command_Data(0x0007,0x0053); + Write_Command_Data(0x0079,0x0000); + + Write_Command(0x0022); + + +} + +void SetXY(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1) +{ + Write_Command_Data(0x0046,(x1 << 8)| x0); + //Write_Command_Data(0x0047,x1); + Write_Command_Data(0x0047,y1); + Write_Command_Data(0x0048,y0); + Write_Command_Data(0x0020,x0); + Write_Command_Data(0x0021,y0); + Write_Command (0x0022);//LCD_WriteCMD(GRAMWR); +} +void Pant(unsigned int color) +{ + int i,j; + int color_test; + color_test = 0; + SetXY(0,239,0,319); + //SetXY(0,120,0,120); + + for(i=0;i<320;i++) + { + for (j=0;j<240;j++) + { + Write_Data(color_test); + color_test+=10; + } + + } +} +void LCD_clear() +{ + unsigned int i,j; + SetXY(0,239,0,319); + for(i=0;i<X_CONST;i++) + { + for(j=0;j<Y_CONST;j++) + { + Write_Data(0x0000); + } + } +} + + +#undef LCD_DRIVER_C
diff -r 000000000000 -r 217105958c2d lcd_driver.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lcd_driver.h Wed Feb 20 15:13:20 2013 +0000 @@ -0,0 +1,41 @@ +#ifndef LCD_DRIVER_H +#define LCD_DRIVER_H + +//#include "mbed.h" + + +#ifdef LCD_DRIVER_C + #define EXTERN_PFX +#else + #define EXTERN_PFX extern +#endif + +#define HIGH 1 +#define LOW 0 + +#define digitalWrite(x,y) x=y + +#define delay(x) wait_ms(x) + +#define X_CONST 240 +#define Y_CONST 320 + + + + +EXTERN_PFX void Write(unsigned int c); +EXTERN_PFX void Write_Command(unsigned int c); +EXTERN_PFX void Write_Data(unsigned int c); +EXTERN_PFX void Write_Command_Data(unsigned int cmd,unsigned int dat); + + +EXTERN_PFX void Lcd_Init(); +EXTERN_PFX void LCD_clear(); +EXTERN_PFX void SetXY(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int y1); +EXTERN_PFX void Pant(unsigned int color); + + + + + +#endif
diff -r 000000000000 -r 217105958c2d main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Feb 20 15:13:20 2013 +0000 @@ -0,0 +1,37 @@ +#include "mbed.h" +#include "lcd_driver.h" + +DigitalOut myled(LED1); + + +int main() { + + Serial pc(USBTX, USBRX); // tx, rx + + Lcd_Init(); + pc.printf("Hello mbed\n"); + LCD_clear(); + pc.printf("clear \n"); + Pant(0xf800); + Pant(0x07e0); + Pant(0x001f); + Pant(0xffff); + Pant(0x0000); + + while(1) { + Pant(0xf800); + Pant(0x07e0); + Pant(0x001f); + Pant(0xffff); + Pant(0x0000); +#if 0 + myled = 1; + wait(0.5); + myled = 0; + wait(0.5); +#endif + } +} + + +
diff -r 000000000000 -r 217105958c2d mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Feb 20 15:13:20 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/3d0ef94e36ec \ No newline at end of file