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