test
Dependencies: mbed-STM32F103C8T6 SHT21_ncleee
Diff: lcd_driver.cpp
- Revision:
- 0:217105958c2d
--- /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