Code to run the cheap 2.4" TFT made by mcufriend.com on the STM nucleo. No modifications required, this plugs into the arduino header.
Dependents: ST7735_V2_STM32F407
Fork of TFTLCD_8bit by
Revision 29:060b167a46ba, committed 2014-06-30
- Comitter:
- cdtsilva
- Date:
- Mon Jun 30 17:29:42 2014 +0000
- Parent:
- 28:8808898a7f0c
- Commit message:
- This is a modified Library to work with the ST Nucleo and the Cheap Red PCB 2.4" TFT displays from china.
; No modifications required, just plug the shield into the arduino header.
Changed in this revision
ili9325.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/ili9325.cpp Sun Apr 06 15:07:50 2014 +0000 +++ b/ili9325.cpp Mon Jun 30 17:29:42 2014 +0000 @@ -36,11 +36,11 @@ _colorDepth = colors; _lcd_pin_reset = HIGH; - wait_ms( 50 ); + wait_ms( 10 ); _lcd_pin_reset = LOW; - wait_ms( 100 ); + wait_ms( 10 ); _lcd_pin_reset = HIGH; - wait_ms( 1000 ); + wait_ms( 10 ); _lcd_pin_cs = HIGH; if ( _lcd_pin_bl != 0 ) *_lcd_pin_bl = HIGH; @@ -49,7 +49,7 @@ if ( _lcd_pin_rd != 0 ) *_lcd_pin_rd = HIGH; _lcd_pin_wr = HIGH; - wait_ms( 15 ); + wait_ms( 5 ); Activate(); @@ -91,69 +91,69 @@ case RGB16: default: - entryMod |= 0x1000; + entryMod |= 0x1030; break; } - WriteCmdData( 0xE5, 0x78F0 ); // set SRAM internal timing - WriteCmdData( 0x01, drivOut ); // set Driver Output Control - WriteCmdData( 0x02, 0x0200 ); // set 1 line inversion - 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] - WriteCmdData( 0x0A, 0x0000 ); // FMARK function - WriteCmdData( 0x0C, 0x0000 ); // RGB interface setting - WriteCmdData( 0x0D, 0x0000 ); // Frame marker Position - WriteCmdData( 0x0F, 0x0000 ); // RGB interface polarity + //WriteCmdData( 0xE5, 0xFFFF ); // set SRAM internal timing + WriteCmdData( 0x0001,0x0100);//0x01, drivOut ); // set Driver Output Control + WriteCmdData( 0x0002,0x0700 ); // set 1 line inversion + WriteCmdData( 0x0003,entryMod );//0x03, entryMod ); // set GRAM write direction and BGR=1. + //WriteCmdData( 0x04, 0x0000 ); // Resize register + WriteCmdData( 0x0008,0x0302 ); // set the back porch and front porch + WriteCmdData( 0x0009,0x0000 ); // set non-display area refresh cycle ISC[3:0] + WriteCmdData( 0x000A,0x0008 ); // FMARK function + //WriteCmdData( 0x0C, 0x0000 ); // RGB interface setting + //WriteCmdData( 0x0D, 0x0000 ); // Frame marker Position + //WriteCmdData( 0x0F, 0x0000 ); // RGB interface polarity // ----------- Power On sequence ----------- // - WriteCmdData( 0x10, 0x0000 ); // SAP, BT[3:0], AP, DSTB, SLP, STB - WriteCmdData( 0x11, 0x0007 ); // DC1[2:0], DC0[2:0], VC[2:0] - WriteCmdData( 0x12, 0x0000 ); // VREG1OUT voltage - WriteCmdData( 0x13, 0x0000 ); // VDV[4:0] for VCOM amplitude - WriteCmdData( 0x07, 0x0001 ); - wait_ms( 200 ); // Dis-charge capacitor power voltage - WriteCmdData( 0x10, 0x1690 ); // SAP, BT[3:0], AP, DSTB, SLP, STB - WriteCmdData( 0x11, 0x0227 ); // Set DC1[2:0], DC0[2:0], VC[2:0] - wait_ms( 50 ); // Delay 50ms - WriteCmdData( 0x12, 0x000D ); // 0012 - wait_ms( 50 ); // Delay 50ms - WriteCmdData( 0x13, 0x1200 ); // VDV[4:0] for VCOM amplitude - WriteCmdData( 0x29, 0x000A ); // 04 VCM[5:0] for VCOMH - WriteCmdData( 0x2B, 0x000D ); // Set Frame Rate - wait_ms( 50 ); // Delay 50ms - WriteCmdData( 0x20, 0x0000 ); // GRAM horizontal Address - WriteCmdData( 0x21, 0x0000 ); // GRAM Vertical Address + WriteCmdData( 0x0010,0x0790 ); // SAP, BT[3:0], AP, DSTB, SLP, STB + WriteCmdData( 0x0011,0x0005 ); // DC1[2:0], DC0[2:0], VC[2:0] + WriteCmdData( 0x0012,0x0000 ); // VREG1OUT voltage + WriteCmdData( 0x0013,0x000 ); // VDV[4:0] for VCOM amplitude + //WriteCmdData( 0x07, 0x0001 ); + //wait_ms( 50 ); // Dis-charge capacitor power voltage + WriteCmdData( 0x0010,0x12B0 ); // SAP, BT[3:0], AP, DSTB, SLP, STB + WriteCmdData( 0x0011,0x0007 ); // Set DC1[2:0], DC0[2:0], VC[2:0] + //wait_ms( 50 ); // Delay 50ms + WriteCmdData( 0x0012,0x008C ); // 0012 + //wait_ms( 50 ); // Delay 50ms + WriteCmdData( 0x0013,0x1700 ); // VDV[4:0] for VCOM amplitude + WriteCmdData( 0x0029,0x0022 ); // 04 VCM[5:0] for VCOMH + //WriteCmdData( 0x2B, 0x00FD ); // Set Frame Rate + //wait_ms( 50 ); // Delay 50ms + //WriteCmdData( 0x20, 0x0000 ); // GRAM horizontal Address + //WriteCmdData( 0x21, 0x0000 ); // GRAM Vertical Address // ----------- Adjust the Gamma Curve ----------// - WriteCmdData( 0x30, 0x0000 ); - WriteCmdData( 0x31, 0x0404 ); - WriteCmdData( 0x32, 0x0003 ); - WriteCmdData( 0x35, 0x0405 ); - WriteCmdData( 0x36, 0x0808 ); - WriteCmdData( 0x37, 0x0407 ); - WriteCmdData( 0x38, 0x0303 ); - WriteCmdData( 0x39, 0x0707 ); - WriteCmdData( 0x3C, 0x0504 ); - WriteCmdData( 0x3D, 0x0808 ); + WriteCmdData( 0x0030,0x0000 ); + WriteCmdData( 0x0031,0x0505 ); + WriteCmdData( 0x0032,0x0205 ); + WriteCmdData( 0x0035,0x0206 ); + WriteCmdData( 0x0036,0x0408 ); + WriteCmdData( 0x0037,0x0000 ); + WriteCmdData( 0x0038,0x0504 ); + WriteCmdData( 0x0039,0x0206 ); + WriteCmdData( 0x003C,0x0206 ); + WriteCmdData( 0x003D,0x0408 ); //------------------ Set GRAM area ---------------// WriteCmdData( 0x50, 0x0000 ); // Horizontal GRAM Start Address WriteCmdData( 0x51, 0x00EF ); // Horizontal GRAM End Address WriteCmdData( 0x52, 0x0000 ); // Vertical GRAM Start Address WriteCmdData( 0x53, 0x013F ); // Vertical GRAM Start Address WriteCmdData( 0x60, gateScan ); // Gate Scan Line (0xA700) - WriteCmdData( 0x61, 0x0000 ); // NDL,VLE, REV - WriteCmdData( 0x6A, 0x0000 ); // set scrolling line + WriteCmdData( 0x0061,0x0001 ); // NDL,VLE, REV + //WriteCmdData( 0x6A, 0x0000 ); // set scrolling line //-------------- Partial Display Control ---------// - WriteCmdData( 0x80, 0x0000 ); - WriteCmdData( 0x81, 0x0000 ); - WriteCmdData( 0x82, 0x0000 ); - WriteCmdData( 0x83, 0x0000 ); - WriteCmdData( 0x84, 0x0000 ); - WriteCmdData( 0x85, 0x0000 ); + //WriteCmdData( 0x80, 0x0000 ); + //WriteCmdData( 0x81, 0x0000 ); + //WriteCmdData( 0x82, 0x0000 ); + //WriteCmdData( 0x83, 0x0000 ); + //WriteCmdData( 0x84, 0x0000 ); + //WriteCmdData( 0x85, 0x0000 ); //-------------- Panel Control -------------------// - WriteCmdData( 0x90, 0x0010 ); - WriteCmdData( 0x92, 0x0000 ); - WriteCmdData( 0x07, 0x0133 ); // 262K color and display ON + WriteCmdData( 0x90, 0x0033 ); + //WriteCmdData( 0x92, 0x0000 ); + WriteCmdData( 0x0007,0x0133 ); // 262K color and display ON Deactivate(); } @@ -162,7 +162,7 @@ { Activate(); WriteCmdData( 0x10, 0x1692 ); // enter sleep mode - wait_ms( 200 ); + wait_ms( 50 ); LCD::Sleep(); Deactivate(); } @@ -171,7 +171,7 @@ { Activate(); WriteCmdData( 0x10, 0x1690 ); // exit sleep mode - wait_ms( 200 ); + wait_ms( 50 ); LCD::WakeUp(); Deactivate(); }