Forked from TFTLCD_8bit by Thiha Electronics

Dependents:   GR-PEACH_TFTLCD_8bit

Fork of TFTLCD_8bit by Thiha Electronics

Committer:
ThihaElectronics
Date:
Wed Dec 03 16:35:25 2014 +0000
Revision:
32:155abe4126e3
Parent:
30:5f23a4cbebd7
sorry if i broken any of your code by recent check in. please enlighten me how to unlink library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ThihaElectronics 28:8808898a7f0c 1 /*
ThihaElectronics 28:8808898a7f0c 2 * Copyright (C)2010-2012 Henning Karlsen. All right reserved.
ThihaElectronics 28:8808898a7f0c 3 * Copyright (C)2012-2013 Todor Todorov.
ThihaElectronics 28:8808898a7f0c 4 *
ThihaElectronics 28:8808898a7f0c 5 * This library is free software; you can redistribute it and/or
ThihaElectronics 28:8808898a7f0c 6 * modify it under the terms of the GNU Lesser General Public
ThihaElectronics 28:8808898a7f0c 7 * License as published by the Free Software Foundation; either
ThihaElectronics 28:8808898a7f0c 8 * version 2.1 of the License, or (at your option) any later version.
ThihaElectronics 28:8808898a7f0c 9 *
ThihaElectronics 28:8808898a7f0c 10 * This library is distributed in the hope that it will be useful,
ThihaElectronics 28:8808898a7f0c 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ThihaElectronics 28:8808898a7f0c 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ThihaElectronics 28:8808898a7f0c 13 * Lesser General Public License for more details.
ThihaElectronics 28:8808898a7f0c 14 *
ThihaElectronics 28:8808898a7f0c 15 * You should have received a copy of the GNU Lesser General Public
ThihaElectronics 28:8808898a7f0c 16 * License along with this library; if not, write to:
ThihaElectronics 28:8808898a7f0c 17 *
ThihaElectronics 28:8808898a7f0c 18 * Free Software Foundation, Inc.
ThihaElectronics 28:8808898a7f0c 19 * 51 Franklin St, 5th Floor, Boston, MA 02110-1301, USA
ThihaElectronics 28:8808898a7f0c 20 *
ThihaElectronics 28:8808898a7f0c 21 *********************************************************************/
ThihaElectronics 28:8808898a7f0c 22 #include "ili9325.h"
ThihaElectronics 28:8808898a7f0c 23 #include "helpers.h"
ThihaElectronics 28:8808898a7f0c 24
ThihaElectronics 29:ad9d18445005 25 ILI9325_LCD::ILI9325_LCD( PinName CS, PinName RESET, PinName RS, PinName WR, BusOut* DATA_PORT, PinName BL, PinName RD, backlight_t blType, float defaultBackLightLevel )
ThihaElectronics 28:8808898a7f0c 26 : LCD( 240, 320, CS, RS, RESET, BL, blType, defaultBackLightLevel ), _lcd_pin_wr( WR )
ThihaElectronics 28:8808898a7f0c 27 {
ThihaElectronics 28:8808898a7f0c 28 _lcd_port = DATA_PORT;
ThihaElectronics 28:8808898a7f0c 29 if ( RD != NC ) _lcd_pin_rd = new DigitalOut( RD );
ThihaElectronics 28:8808898a7f0c 30 else _lcd_pin_rd = 0;
ThihaElectronics 28:8808898a7f0c 31 }
ThihaElectronics 28:8808898a7f0c 32
ThihaElectronics 29:ad9d18445005 33 void ILI9325_LCD::Initialize( orientation_t orientation, colordepth_t colors )
ThihaElectronics 28:8808898a7f0c 34 {
ThihaElectronics 28:8808898a7f0c 35 _orientation = orientation;
ThihaElectronics 28:8808898a7f0c 36 _colorDepth = colors;
ThihaElectronics 28:8808898a7f0c 37
ThihaElectronics 28:8808898a7f0c 38 _lcd_pin_reset = HIGH;
ThihaElectronics 30:5f23a4cbebd7 39 // wait_ms( 50 );
ThihaElectronics 30:5f23a4cbebd7 40 wait_ms( 100 );
ThihaElectronics 28:8808898a7f0c 41 _lcd_pin_reset = LOW;
ThihaElectronics 30:5f23a4cbebd7 42 // wait_ms( 100 );
ThihaElectronics 30:5f23a4cbebd7 43 wait_ms( 200 );
ThihaElectronics 28:8808898a7f0c 44 _lcd_pin_reset = HIGH;
ThihaElectronics 30:5f23a4cbebd7 45 // wait_ms( 1000 );
ThihaElectronics 28:8808898a7f0c 46 wait_ms( 1000 );
ThihaElectronics 28:8808898a7f0c 47 _lcd_pin_cs = HIGH;
ThihaElectronics 28:8808898a7f0c 48 if ( _lcd_pin_bl != 0 )
ThihaElectronics 28:8808898a7f0c 49 *_lcd_pin_bl = HIGH;
ThihaElectronics 28:8808898a7f0c 50 else if ( _bl_pwm != 0 )
ThihaElectronics 28:8808898a7f0c 51 *_bl_pwm = _bl_pwm_default;
ThihaElectronics 28:8808898a7f0c 52 if ( _lcd_pin_rd != 0 )
ThihaElectronics 28:8808898a7f0c 53 *_lcd_pin_rd = HIGH;
ThihaElectronics 28:8808898a7f0c 54 _lcd_pin_wr = HIGH;
ThihaElectronics 30:5f23a4cbebd7 55 // wait_ms( 15 );
ThihaElectronics 30:5f23a4cbebd7 56 wait_ms( 50 );
ThihaElectronics 28:8808898a7f0c 57
ThihaElectronics 28:8808898a7f0c 58 Activate();
ThihaElectronics 28:8808898a7f0c 59
ThihaElectronics 28:8808898a7f0c 60 short drivOut = 0;
ThihaElectronics 28:8808898a7f0c 61 short entryMod = 0;
ThihaElectronics 28:8808898a7f0c 62 short gateScan = 0x2700;
ThihaElectronics 28:8808898a7f0c 63 switch ( _orientation )
ThihaElectronics 28:8808898a7f0c 64 {
ThihaElectronics 28:8808898a7f0c 65 case LANDSCAPE:
ThihaElectronics 28:8808898a7f0c 66 drivOut = 0x0100;
ThihaElectronics 28:8808898a7f0c 67 entryMod |= 0x0038;
ThihaElectronics 28:8808898a7f0c 68 gateScan |= 0x0000;
ThihaElectronics 28:8808898a7f0c 69 break;
ThihaElectronics 28:8808898a7f0c 70
ThihaElectronics 28:8808898a7f0c 71 case LANDSCAPE_REV:
ThihaElectronics 28:8808898a7f0c 72 drivOut = 0x0000;
ThihaElectronics 28:8808898a7f0c 73 entryMod |= 0x0038;
ThihaElectronics 28:8808898a7f0c 74 gateScan |= 0x8000;
ThihaElectronics 28:8808898a7f0c 75 break;
ThihaElectronics 28:8808898a7f0c 76
ThihaElectronics 28:8808898a7f0c 77 case PORTRAIT_REV:
ThihaElectronics 28:8808898a7f0c 78 drivOut = 0x0000;
ThihaElectronics 28:8808898a7f0c 79 entryMod |= 0x0030;
ThihaElectronics 28:8808898a7f0c 80 gateScan |= 0x0000;
ThihaElectronics 28:8808898a7f0c 81 break;
ThihaElectronics 28:8808898a7f0c 82
ThihaElectronics 28:8808898a7f0c 83 case PORTRAIT:
ThihaElectronics 28:8808898a7f0c 84 default:
ThihaElectronics 28:8808898a7f0c 85 drivOut = 0x0100;
ThihaElectronics 28:8808898a7f0c 86 entryMod |= 0x0030;
ThihaElectronics 28:8808898a7f0c 87 gateScan |= 0x8000;
ThihaElectronics 28:8808898a7f0c 88 break;
ThihaElectronics 28:8808898a7f0c 89 }
ThihaElectronics 28:8808898a7f0c 90 switch ( _colorDepth )
ThihaElectronics 28:8808898a7f0c 91 {
ThihaElectronics 28:8808898a7f0c 92 case RGB18:
ThihaElectronics 28:8808898a7f0c 93 entryMod |= 0x9000;
ThihaElectronics 28:8808898a7f0c 94 break;
ThihaElectronics 28:8808898a7f0c 95
ThihaElectronics 28:8808898a7f0c 96 case RGB16:
ThihaElectronics 28:8808898a7f0c 97 default:
ThihaElectronics 28:8808898a7f0c 98 entryMod |= 0x1000;
ThihaElectronics 28:8808898a7f0c 99 break;
ThihaElectronics 28:8808898a7f0c 100 }
ThihaElectronics 28:8808898a7f0c 101
ThihaElectronics 30:5f23a4cbebd7 102 // WriteCmdData( 0xE5, 0x78F0 ); // set SRAM internal timing
ThihaElectronics 30:5f23a4cbebd7 103 WriteCmdData( 0xE5, 0x8000 ); // set SRAM internal timing
ThihaElectronics 30:5f23a4cbebd7 104 WriteCmdData( 0x00, 0x0000 ); // set Driver Output Control
ThihaElectronics 28:8808898a7f0c 105 WriteCmdData( 0x01, drivOut ); // set Driver Output Control
ThihaElectronics 30:5f23a4cbebd7 106 // WriteCmdData( 0x02, 0x0200 ); // set 1 line inversion
ThihaElectronics 30:5f23a4cbebd7 107 WriteCmdData( 0x02, 0x0700 ); // set 1 line inversion
ThihaElectronics 28:8808898a7f0c 108 WriteCmdData( 0x03, entryMod ); // set GRAM write direction and BGR=1.
ThihaElectronics 28:8808898a7f0c 109 WriteCmdData( 0x04, 0x0000 ); // Resize register
ThihaElectronics 30:5f23a4cbebd7 110 // WriteCmdData( 0x08, 0x0207 ); // set the back porch and front porch
ThihaElectronics 30:5f23a4cbebd7 111 WriteCmdData( 0x08, 0x0202 ); // set the back porch and front porch
ThihaElectronics 30:5f23a4cbebd7 112
ThihaElectronics 28:8808898a7f0c 113 WriteCmdData( 0x09, 0x0000 ); // set non-display area refresh cycle ISC[3:0]
ThihaElectronics 28:8808898a7f0c 114 WriteCmdData( 0x0A, 0x0000 ); // FMARK function
ThihaElectronics 28:8808898a7f0c 115 WriteCmdData( 0x0C, 0x0000 ); // RGB interface setting
ThihaElectronics 28:8808898a7f0c 116 WriteCmdData( 0x0D, 0x0000 ); // Frame marker Position
ThihaElectronics 28:8808898a7f0c 117 WriteCmdData( 0x0F, 0x0000 ); // RGB interface polarity
ThihaElectronics 28:8808898a7f0c 118 // ----------- Power On sequence ----------- //
ThihaElectronics 28:8808898a7f0c 119 WriteCmdData( 0x10, 0x0000 ); // SAP, BT[3:0], AP, DSTB, SLP, STB
ThihaElectronics 30:5f23a4cbebd7 120 // WriteCmdData( 0x11, 0x0007 ); // DC1[2:0], DC0[2:0], VC[2:0]
ThihaElectronics 30:5f23a4cbebd7 121 WriteCmdData( 0x11, 0x0000 ); // DC1[2:0], DC0[2:0], VC[2:0]
ThihaElectronics 28:8808898a7f0c 122 WriteCmdData( 0x12, 0x0000 ); // VREG1OUT voltage
ThihaElectronics 28:8808898a7f0c 123 WriteCmdData( 0x13, 0x0000 ); // VDV[4:0] for VCOM amplitude
ThihaElectronics 30:5f23a4cbebd7 124 // WriteCmdData( 0x07, 0x0001 );
ThihaElectronics 28:8808898a7f0c 125 wait_ms( 200 ); // Dis-charge capacitor power voltage
ThihaElectronics 30:5f23a4cbebd7 126
ThihaElectronics 30:5f23a4cbebd7 127 // WriteCmdData( 0x10, 0x1690 ); // SAP, BT[3:0], AP, DSTB, SLP, STB
ThihaElectronics 30:5f23a4cbebd7 128 WriteCmdData( 0x10, 0x17B0 ); // SAP, BT[3:0], AP, DSTB, SLP, STB
ThihaElectronics 30:5f23a4cbebd7 129 // WriteCmdData( 0x11, 0x0227 ); // Set DC1[2:0], DC0[2:0], VC[2:0]
ThihaElectronics 30:5f23a4cbebd7 130 WriteCmdData( 0x11, 0x0037 ); // Set DC1[2:0], DC0[2:0], VC[2:0]
ThihaElectronics 28:8808898a7f0c 131 wait_ms( 50 ); // Delay 50ms
ThihaElectronics 30:5f23a4cbebd7 132
ThihaElectronics 30:5f23a4cbebd7 133 // WriteCmdData( 0x12, 0x000D ); // 0012
ThihaElectronics 30:5f23a4cbebd7 134 WriteCmdData( 0x12, 0x0138 ); // 0012
ThihaElectronics 28:8808898a7f0c 135 wait_ms( 50 ); // Delay 50ms
ThihaElectronics 30:5f23a4cbebd7 136
ThihaElectronics 30:5f23a4cbebd7 137 // WriteCmdData( 0x13, 0x1200 ); // VDV[4:0] for VCOM amplitude
ThihaElectronics 30:5f23a4cbebd7 138 WriteCmdData( 0x13, 0x1700 ); // VDV[4:0] for VCOM amplitude
ThihaElectronics 30:5f23a4cbebd7 139 // WriteCmdData( 0x29, 0x000A ); // 04 VCM[5:0] for VCOMH
ThihaElectronics 30:5f23a4cbebd7 140 WriteCmdData( 0x29, 0x000D ); // 04 VCM[5:0] for VCOMH
ThihaElectronics 28:8808898a7f0c 141 WriteCmdData( 0x2B, 0x000D ); // Set Frame Rate
ThihaElectronics 28:8808898a7f0c 142 wait_ms( 50 ); // Delay 50ms
ThihaElectronics 30:5f23a4cbebd7 143
ThihaElectronics 28:8808898a7f0c 144 WriteCmdData( 0x20, 0x0000 ); // GRAM horizontal Address
ThihaElectronics 28:8808898a7f0c 145 WriteCmdData( 0x21, 0x0000 ); // GRAM Vertical Address
ThihaElectronics 30:5f23a4cbebd7 146
ThihaElectronics 28:8808898a7f0c 147 // ----------- Adjust the Gamma Curve ----------//
ThihaElectronics 30:5f23a4cbebd7 148 // WriteCmdData( 0x30, 0x0000 );
ThihaElectronics 30:5f23a4cbebd7 149 WriteCmdData( 0x30, 0x0001 );
ThihaElectronics 30:5f23a4cbebd7 150 // WriteCmdData( 0x31, 0x0404 );
ThihaElectronics 30:5f23a4cbebd7 151 WriteCmdData( 0x31, 0x0606 );
ThihaElectronics 30:5f23a4cbebd7 152 // WriteCmdData( 0x32, 0x0003 );
ThihaElectronics 30:5f23a4cbebd7 153 WriteCmdData( 0x32, 0x0304 );
ThihaElectronics 30:5f23a4cbebd7 154 //new line
ThihaElectronics 30:5f23a4cbebd7 155 WriteCmdData( 0x33, 0x0202 );
ThihaElectronics 30:5f23a4cbebd7 156 WriteCmdData( 0x34, 0x0202 );
ThihaElectronics 30:5f23a4cbebd7 157 // WriteCmdData( 0x35, 0x0405 );
ThihaElectronics 30:5f23a4cbebd7 158 WriteCmdData( 0x35, 0x0103 );
ThihaElectronics 30:5f23a4cbebd7 159
ThihaElectronics 30:5f23a4cbebd7 160 // WriteCmdData( 0x36, 0x0808 );
ThihaElectronics 30:5f23a4cbebd7 161 WriteCmdData( 0x36, 0x011D );
ThihaElectronics 30:5f23a4cbebd7 162 // WriteCmdData( 0x37, 0x0407 );
ThihaElectronics 30:5f23a4cbebd7 163 WriteCmdData( 0x37, 0x0404 );
ThihaElectronics 30:5f23a4cbebd7 164 // WriteCmdData( 0x38, 0x0303 );
ThihaElectronics 30:5f23a4cbebd7 165 WriteCmdData( 0x38, 0x0404 );
ThihaElectronics 30:5f23a4cbebd7 166 // WriteCmdData( 0x39, 0x0707 );
ThihaElectronics 30:5f23a4cbebd7 167 WriteCmdData( 0x39, 0x0404 );
ThihaElectronics 30:5f23a4cbebd7 168 // WriteCmdData( 0x3C, 0x0504 );
ThihaElectronics 30:5f23a4cbebd7 169 WriteCmdData( 0x3C, 0x0700 );
ThihaElectronics 30:5f23a4cbebd7 170 // WriteCmdData( 0x3D, 0x0808 );
ThihaElectronics 30:5f23a4cbebd7 171 WriteCmdData( 0x3D, 0x0A1F );
ThihaElectronics 30:5f23a4cbebd7 172
ThihaElectronics 28:8808898a7f0c 173 //------------------ Set GRAM area ---------------//
ThihaElectronics 28:8808898a7f0c 174 WriteCmdData( 0x50, 0x0000 ); // Horizontal GRAM Start Address
ThihaElectronics 28:8808898a7f0c 175 WriteCmdData( 0x51, 0x00EF ); // Horizontal GRAM End Address
ThihaElectronics 28:8808898a7f0c 176 WriteCmdData( 0x52, 0x0000 ); // Vertical GRAM Start Address
ThihaElectronics 28:8808898a7f0c 177 WriteCmdData( 0x53, 0x013F ); // Vertical GRAM Start Address
ThihaElectronics 28:8808898a7f0c 178 WriteCmdData( 0x60, gateScan ); // Gate Scan Line (0xA700)
ThihaElectronics 30:5f23a4cbebd7 179 // WriteCmdData( 0x61, 0x0000 ); // NDL,VLE, REV
ThihaElectronics 30:5f23a4cbebd7 180 WriteCmdData( 0x61, 0x0001 ); // NDL,VLE, REV
ThihaElectronics 28:8808898a7f0c 181 WriteCmdData( 0x6A, 0x0000 ); // set scrolling line
ThihaElectronics 28:8808898a7f0c 182 //-------------- Partial Display Control ---------//
ThihaElectronics 28:8808898a7f0c 183 WriteCmdData( 0x80, 0x0000 );
ThihaElectronics 28:8808898a7f0c 184 WriteCmdData( 0x81, 0x0000 );
ThihaElectronics 28:8808898a7f0c 185 WriteCmdData( 0x82, 0x0000 );
ThihaElectronics 28:8808898a7f0c 186 WriteCmdData( 0x83, 0x0000 );
ThihaElectronics 28:8808898a7f0c 187 WriteCmdData( 0x84, 0x0000 );
ThihaElectronics 28:8808898a7f0c 188 WriteCmdData( 0x85, 0x0000 );
ThihaElectronics 28:8808898a7f0c 189 //-------------- Panel Control -------------------//
ThihaElectronics 28:8808898a7f0c 190 WriteCmdData( 0x90, 0x0010 );
ThihaElectronics 28:8808898a7f0c 191 WriteCmdData( 0x92, 0x0000 );
ThihaElectronics 30:5f23a4cbebd7 192 //new lines
ThihaElectronics 30:5f23a4cbebd7 193 WriteCmdData( 0x93, 0x0003 );
ThihaElectronics 30:5f23a4cbebd7 194 WriteCmdData( 0x95, 0x0101 );
ThihaElectronics 30:5f23a4cbebd7 195 WriteCmdData( 0x97, 0x0000 );
ThihaElectronics 30:5f23a4cbebd7 196 WriteCmdData( 0x98, 0x0000 );
ThihaElectronics 30:5f23a4cbebd7 197
ThihaElectronics 30:5f23a4cbebd7 198 // WriteCmdData( 0x07, 0x0133 ); // 262K color and display ON
ThihaElectronics 30:5f23a4cbebd7 199 WriteCmdData( 0x07, 0x0021 ); // 262K color and display ON
ThihaElectronics 30:5f23a4cbebd7 200 WriteCmdData( 0x07, 0x0031 ); // 262K color and display ON
ThihaElectronics 30:5f23a4cbebd7 201 WriteCmdData( 0x07, 0x0173 ); // 262K color and display ON
ThihaElectronics 30:5f23a4cbebd7 202 //new line
ThihaElectronics 30:5f23a4cbebd7 203 wait_ms( 50 ); // Delay 50ms
ThihaElectronics 28:8808898a7f0c 204 Deactivate();
ThihaElectronics 28:8808898a7f0c 205 }
ThihaElectronics 28:8808898a7f0c 206
ThihaElectronics 29:ad9d18445005 207 void ILI9325_LCD::Sleep( void )
ThihaElectronics 28:8808898a7f0c 208 {
ThihaElectronics 28:8808898a7f0c 209 Activate();
ThihaElectronics 28:8808898a7f0c 210 WriteCmdData( 0x10, 0x1692 ); // enter sleep mode
ThihaElectronics 28:8808898a7f0c 211 wait_ms( 200 );
ThihaElectronics 28:8808898a7f0c 212 LCD::Sleep();
ThihaElectronics 28:8808898a7f0c 213 Deactivate();
ThihaElectronics 28:8808898a7f0c 214 }
ThihaElectronics 28:8808898a7f0c 215
ThihaElectronics 29:ad9d18445005 216 void ILI9325_LCD::WakeUp( void )
ThihaElectronics 28:8808898a7f0c 217 {
ThihaElectronics 28:8808898a7f0c 218 Activate();
ThihaElectronics 28:8808898a7f0c 219 WriteCmdData( 0x10, 0x1690 ); // exit sleep mode
ThihaElectronics 28:8808898a7f0c 220 wait_ms( 200 );
ThihaElectronics 28:8808898a7f0c 221 LCD::WakeUp();
ThihaElectronics 28:8808898a7f0c 222 Deactivate();
ThihaElectronics 28:8808898a7f0c 223 }
ThihaElectronics 28:8808898a7f0c 224
ThihaElectronics 29:ad9d18445005 225 void ILI9325_LCD::WriteCmd( unsigned short cmd )
ThihaElectronics 28:8808898a7f0c 226 {
ThihaElectronics 28:8808898a7f0c 227
ThihaElectronics 28:8808898a7f0c 228 unsigned short u,l;
ThihaElectronics 28:8808898a7f0c 229 u = (cmd>>8) & 0xFF;
ThihaElectronics 28:8808898a7f0c 230 l = cmd & 0xFF;
ThihaElectronics 28:8808898a7f0c 231
ThihaElectronics 28:8808898a7f0c 232 //New
ThihaElectronics 28:8808898a7f0c 233 _lcd_pin_cs = LOW;
ThihaElectronics 28:8808898a7f0c 234 //
ThihaElectronics 28:8808898a7f0c 235 _lcd_pin_rs = LOW;
ThihaElectronics 28:8808898a7f0c 236
ThihaElectronics 28:8808898a7f0c 237 //New
ThihaElectronics 28:8808898a7f0c 238 *_lcd_pin_rd = HIGH;
ThihaElectronics 28:8808898a7f0c 239 _lcd_pin_wr = HIGH;
ThihaElectronics 28:8808898a7f0c 240 //
ThihaElectronics 28:8808898a7f0c 241 _lcd_port->write( u );
ThihaElectronics 28:8808898a7f0c 242 pulseLow( _lcd_pin_wr );
ThihaElectronics 28:8808898a7f0c 243
ThihaElectronics 28:8808898a7f0c 244 _lcd_port->write( l );
ThihaElectronics 28:8808898a7f0c 245 pulseLow( _lcd_pin_wr );
ThihaElectronics 28:8808898a7f0c 246
ThihaElectronics 28:8808898a7f0c 247 //New
ThihaElectronics 28:8808898a7f0c 248 _lcd_pin_cs = HIGH;
ThihaElectronics 28:8808898a7f0c 249 //
ThihaElectronics 28:8808898a7f0c 250 }
ThihaElectronics 28:8808898a7f0c 251
ThihaElectronics 29:ad9d18445005 252 void ILI9325_LCD::WriteData( unsigned short data )
ThihaElectronics 28:8808898a7f0c 253 {
ThihaElectronics 28:8808898a7f0c 254 unsigned short u,l;
ThihaElectronics 28:8808898a7f0c 255 u = (data>>8) & 0xFF;
ThihaElectronics 28:8808898a7f0c 256 l = data & 0xFF;
ThihaElectronics 28:8808898a7f0c 257
ThihaElectronics 28:8808898a7f0c 258 //New
ThihaElectronics 28:8808898a7f0c 259 _lcd_pin_cs = LOW;
ThihaElectronics 28:8808898a7f0c 260 //
ThihaElectronics 28:8808898a7f0c 261 _lcd_pin_rs = HIGH;
ThihaElectronics 28:8808898a7f0c 262 //New
ThihaElectronics 28:8808898a7f0c 263 *_lcd_pin_rd = HIGH;
ThihaElectronics 28:8808898a7f0c 264 _lcd_pin_wr = HIGH;
ThihaElectronics 28:8808898a7f0c 265 //
ThihaElectronics 28:8808898a7f0c 266 _lcd_port->write( u );
ThihaElectronics 28:8808898a7f0c 267 pulseLow( _lcd_pin_wr );
ThihaElectronics 28:8808898a7f0c 268
ThihaElectronics 28:8808898a7f0c 269 _lcd_port->write( l );
ThihaElectronics 28:8808898a7f0c 270 pulseLow( _lcd_pin_wr );
ThihaElectronics 28:8808898a7f0c 271
ThihaElectronics 28:8808898a7f0c 272 //New
ThihaElectronics 28:8808898a7f0c 273 _lcd_pin_cs = HIGH;
ThihaElectronics 28:8808898a7f0c 274 //
ThihaElectronics 28:8808898a7f0c 275 }
ThihaElectronics 28:8808898a7f0c 276
ThihaElectronics 29:ad9d18445005 277 void ILI9325_LCD::SetXY( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2 )
ThihaElectronics 28:8808898a7f0c 278 {
ThihaElectronics 28:8808898a7f0c 279 switch ( _orientation )
ThihaElectronics 28:8808898a7f0c 280 {
ThihaElectronics 28:8808898a7f0c 281 case LANDSCAPE:
ThihaElectronics 28:8808898a7f0c 282 case LANDSCAPE_REV:
ThihaElectronics 28:8808898a7f0c 283 WriteCmdData( 0x20, y1 );
ThihaElectronics 28:8808898a7f0c 284 WriteCmdData( 0x21, x1 );
ThihaElectronics 28:8808898a7f0c 285 WriteCmdData( 0x50, y1 );
ThihaElectronics 28:8808898a7f0c 286 WriteCmdData( 0x52, x1 );
ThihaElectronics 28:8808898a7f0c 287 WriteCmdData( 0x51, y2 );
ThihaElectronics 28:8808898a7f0c 288 WriteCmdData( 0x53, x2 );
ThihaElectronics 28:8808898a7f0c 289 break;
ThihaElectronics 28:8808898a7f0c 290
ThihaElectronics 28:8808898a7f0c 291 case PORTRAIT_REV:
ThihaElectronics 28:8808898a7f0c 292 case PORTRAIT:
ThihaElectronics 28:8808898a7f0c 293 default:
ThihaElectronics 28:8808898a7f0c 294 WriteCmdData( 0x20, x1 );
ThihaElectronics 28:8808898a7f0c 295 WriteCmdData( 0x21, y1 );
ThihaElectronics 28:8808898a7f0c 296 WriteCmdData( 0x50, x1 );
ThihaElectronics 28:8808898a7f0c 297 WriteCmdData( 0x52, y1 );
ThihaElectronics 28:8808898a7f0c 298 WriteCmdData( 0x51, x2 );
ThihaElectronics 28:8808898a7f0c 299 WriteCmdData( 0x53, y2 );
ThihaElectronics 28:8808898a7f0c 300 break;
ThihaElectronics 28:8808898a7f0c 301 }
ThihaElectronics 28:8808898a7f0c 302 WriteCmd( 0x22 );
ThihaElectronics 28:8808898a7f0c 303 }
ThihaElectronics 28:8808898a7f0c 304
ThihaElectronics 29:ad9d18445005 305 void ILI9325_LCD::SetPixelColor( unsigned int color, colordepth_t mode )
ThihaElectronics 28:8808898a7f0c 306 {
ThihaElectronics 28:8808898a7f0c 307 unsigned char r, g, b;
ThihaElectronics 28:8808898a7f0c 308 unsigned short clr;
ThihaElectronics 28:8808898a7f0c 309 r = g = b = 0;
ThihaElectronics 28:8808898a7f0c 310 if ( _colorDepth == RGB16 )
ThihaElectronics 28:8808898a7f0c 311 {
ThihaElectronics 28:8808898a7f0c 312 switch ( mode )
ThihaElectronics 28:8808898a7f0c 313 {
ThihaElectronics 28:8808898a7f0c 314 case RGB16:
ThihaElectronics 28:8808898a7f0c 315 WriteData( color & 0xFFFF );
ThihaElectronics 28:8808898a7f0c 316 break;
ThihaElectronics 28:8808898a7f0c 317 case RGB18:
ThihaElectronics 28:8808898a7f0c 318 r = ( color >> 10 ) & 0xF8;
ThihaElectronics 28:8808898a7f0c 319 g = ( color >> 4 ) & 0xFC;
ThihaElectronics 28:8808898a7f0c 320 b = ( color >> 1 ) & 0x1F;
ThihaElectronics 28:8808898a7f0c 321 clr = ( ( r | ( g >> 5 ) ) << 8 ) | ( ( g << 3 ) | b );
ThihaElectronics 28:8808898a7f0c 322 WriteData( clr );
ThihaElectronics 28:8808898a7f0c 323 break;
ThihaElectronics 28:8808898a7f0c 324 case RGB24:
ThihaElectronics 28:8808898a7f0c 325 r = ( color >> 16 ) & 0xF8;
ThihaElectronics 28:8808898a7f0c 326 g = ( color >> 8 ) & 0xFC;
ThihaElectronics 28:8808898a7f0c 327 b = color & 0xF8;
ThihaElectronics 28:8808898a7f0c 328 clr = ( ( r | ( g >> 5 ) ) << 8 ) | ( ( g << 3 ) | ( b >> 3 ) );
ThihaElectronics 28:8808898a7f0c 329 WriteData( clr );
ThihaElectronics 28:8808898a7f0c 330 break;
ThihaElectronics 28:8808898a7f0c 331 }
ThihaElectronics 28:8808898a7f0c 332 }
ThihaElectronics 28:8808898a7f0c 333 else if ( _colorDepth == RGB18 )
ThihaElectronics 28:8808898a7f0c 334 {
ThihaElectronics 28:8808898a7f0c 335 switch ( mode )
ThihaElectronics 28:8808898a7f0c 336 {
ThihaElectronics 28:8808898a7f0c 337 case RGB16:
ThihaElectronics 28:8808898a7f0c 338 r = ( ( color >> 8 ) & 0xF8 ) | ( ( color & 0x8000 ) >> 13 );
ThihaElectronics 28:8808898a7f0c 339 g = ( color >> 3 ) & 0xFC;
ThihaElectronics 28:8808898a7f0c 340 b = ( ( color << 3 ) & 0xFC ) | ( ( color >> 3 ) & 0x01 );
ThihaElectronics 28:8808898a7f0c 341 break;
ThihaElectronics 28:8808898a7f0c 342 case RGB18:
ThihaElectronics 28:8808898a7f0c 343 b = ( color << 2 ) & 0xFC;
ThihaElectronics 28:8808898a7f0c 344 g = ( color >> 4 ) & 0xFC;
ThihaElectronics 28:8808898a7f0c 345 r = ( color >> 10 ) & 0xFC;
ThihaElectronics 28:8808898a7f0c 346 break;
ThihaElectronics 28:8808898a7f0c 347 case RGB24:
ThihaElectronics 28:8808898a7f0c 348 r = ( color >> 16 ) & 0xFC;
ThihaElectronics 28:8808898a7f0c 349 g = ( color >> 8 ) & 0xFC;
ThihaElectronics 28:8808898a7f0c 350 b = color & 0xFC;
ThihaElectronics 28:8808898a7f0c 351 break;
ThihaElectronics 28:8808898a7f0c 352 }
ThihaElectronics 28:8808898a7f0c 353 clr = ( r << 8 ) | ( g << 2 ) | ( b >> 4 );
ThihaElectronics 28:8808898a7f0c 354 WriteData( clr );
ThihaElectronics 28:8808898a7f0c 355 WriteData( b << 4 );
ThihaElectronics 28:8808898a7f0c 356 }
ThihaElectronics 28:8808898a7f0c 357 }