1.44 tft lcd display
Dependencies: TFT_fonts mbed-os
Fork of newTFTLCD by
Diff: ili9328.cpp
- Revision:
- 25:6cffb758c075
- Parent:
- 24:ac6e35658037
- Child:
- 26:28f64fbcf7df
--- a/ili9328.cpp Sat Jun 15 05:34:53 2013 +0000 +++ b/ili9328.cpp Sun Jun 16 02:53:06 2013 +0000 @@ -52,29 +52,49 @@ wait_ms( 15 ); Activate(); - /* - short payload = 0; + + short drivOut = 0; + short entryMod = 0; + short gateScan = 0x2700; switch ( _orientation ) { + case LANDSCAPE: + drivOut = 0x0100; + entryMod |= 0x0038; + gateScan |= 0x0000; + break; + + case LANDSCAPE_REV: + drivOut = 0x0000; + entryMod |= 0x0038; + gateScan |= 0x8000; + break; + + case PORTRAIT_REV: + drivOut = 0x0000; + entryMod |= 0x0030; + gateScan |= 0x0000; + break; + case PORTRAIT: default: - payload |= 0x0020; + drivOut = 0x0100; + entryMod |= 0x0030; + gateScan |= 0x8000; break; } switch ( _colorDepth ) { case RGB16: default: - payload |= 0x1000; + entryMod |= 0x1000; break; } - //WriteCmdData( REG_ENTRY_MOD, payload ); - */ WriteCmdData( 0xE5, 0x78F0 ); // set SRAM internal timing - WriteCmdData( 0x01, 0x0100 ); // set Driver Output Control + WriteCmdData( 0x01, drivOut ); // set Driver Output Control WriteCmdData( 0x02, 0x0200 ); // set 1 line inversion - WriteCmdData( 0x03, 0x1030 ); // set GRAM write direction and BGR=1. + WriteCmdData( 0x03, entryMod ); // set GRAM write direction and BGR=1. WriteCmdData( 0x04, 0x0000 ); // Resize register WriteCmdData( 0x08, 0x0207 ); // set the back porch and front porch WriteCmdData( 0x09, 0x0000 ); // set non-display area refresh cycle ISC[3:0] @@ -116,7 +136,7 @@ WriteCmdData( 0x51, 0x00EF ); // Horizontal GRAM End Address WriteCmdData( 0x52, 0x0000 ); // Vertical GRAM Start Address WriteCmdData( 0x53, 0x013F ); // Vertical GRAM Start Address - WriteCmdData( 0x60, 0xA700 ); // Gate Scan Line + WriteCmdData( 0x60, gateScan ); // Gate Scan Line (0xA700) WriteCmdData( 0x61, 0x0000 ); // NDL,VLE, REV WriteCmdData( 0x6A, 0x0000 ); // set scrolling line //-------------- Partial Display Control ---------// @@ -136,13 +156,13 @@ void ILI9328_LCD::Sleep( void ) { - //WriteCmdData( 0x10, 0x0001 ); // sleep mode: 0 = exit, 1 = enter + WriteCmdData( 0x10, 0x0001 );//0x1692 ); // enter sleep mode LCD::Sleep(); } void ILI9328_LCD::WakeUp( void ) { - //WriteCmdData( 0x10, 0x0000 ); // sleep mode: 0 = exit, 1 = enter + WriteCmdData( 0x10, 0x0000 );//0x1690 ); // exit sleep mode LCD::WakeUp(); } @@ -162,12 +182,29 @@ void ILI9328_LCD::SetXY( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2 ) { - WriteCmdData( 0x20, x1 ); - WriteCmdData( 0x21, y1 ); - WriteCmdData( 0x50, x1 ); - WriteCmdData( 0x52, y1 ); - WriteCmdData( 0x51, x2 ); - WriteCmdData( 0x53, y2 ); + switch ( _orientation ) + { + case LANDSCAPE: + case LANDSCAPE_REV: + WriteCmdData( 0x20, y1 ); + WriteCmdData( 0x21, x1 ); + WriteCmdData( 0x50, y1 ); + WriteCmdData( 0x52, x1 ); + WriteCmdData( 0x51, y2 ); + WriteCmdData( 0x53, x2 ); + break; + + case PORTRAIT_REV: + case PORTRAIT: + default: + WriteCmdData( 0x20, x1 ); + WriteCmdData( 0x21, y1 ); + WriteCmdData( 0x50, x1 ); + WriteCmdData( 0x52, y1 ); + WriteCmdData( 0x51, x2 ); + WriteCmdData( 0x53, y2 ); + break; + } WriteCmd( 0x22 ); }