This is a port of Henning Kralsen's UTFT library for Arduino/chipKIT to mbed, refactored to make full use of C++ inheritance and access control, in order to reduce work when implementing new drivers and at the same time make the code more readable and easier to maintain. As of now supported are SSD1289 (16-bit interface), HX8340-B (serial interface) and ST7735 (serial interface). Drivers for other controllers will be added as time and resources to acquire the displays to test the code permit.

Dependents:   test SDCard capstone_display capstone_display_2 ... more

TFTLCD Library

NOTE (2013-03-25) Tested with both mbed LPC1768 and Freedom KL25Z. -todor

A TFT LCD driver library, which at the moment provides support for the following display controllers: HX8340-B (serial interface), SSD1289 (16-bit interface), ST7735-R (serial interface), ILI9325/ILI9328 (16-bit interface).

As I am acquiring and testing out new displays, I decided to combine all ported drivers into one library as with the original work done by Henning. However I also had as a goal to make the code maintenance and readability easier/better, so the code has been heavily refactored to make full use of C++ facilities as inheritance and access control. I extracted the common pieces of code into a base class, which every driver inherits and only the controller-specific side is provided in the actual driver - things like initialization, addressing, data transfer, etc.

Another nice extension is that the display's backlight can now be controlled through the driver. Either a simple on/off method of control could be selected, or the brightness can be set through use of PWM (the latter placing some restrictions on which pins can be used for this, as mbed offers hardware PWM on only 6 pins).

I also plan to add support for touch screens as part of the library. The goal is to grow this piece of software into a lightweight graphics widgets library, which can be used to construct control screens with buttons or menus in a speedy and intuitive way.

Changes

2013-07-21

  • Fixed the sleep/wake-up functions of the ILI9328 driver.

2013-06-15

  • Added driver for ILI9328 (works with ILI9325) controller, 16-bit data bus. Screen rotation works as usual with the TFTLCD library, but for now only RGB565 color depth is working and you can use both 65K and 262K color space with this driver. But for some reason the sleep function is not behaving as expected; I am working on this.
  • This is only on my to-do list for now - haven't really had the time yet - but I am going to refactor the library a bit to allow use of GPIO ports for data transfers instead of DigitalOut: faster and cleaner that way. For those who are using it already in a working design and cannot repurpose the pins anymore, the current way it's working will still be available; I am hoping not to tear up the public interfaces of the library (... too much). Anyway, since I am at it, I will also try to add support for multiple bus interfaces to drivers that support it (i.e. both 8bit and 16bit use of ILI932x or SSD1289). Thought this might be a good place to give you guys the heads-up.

2013-01-25

  • Replaced all existing fonts from the UTFT library with the free Terminus font. Two different sizes are provided: 8x12 pixels and 16x28 pixels. I found the old fonts not so good looking and then they supported only the ASCII codes in the range 30 (space) to 126 (the tilde ). The 7segment font didn't even implement anything else than the numbers from 0 to 9 - so it was unusable for anything (one couldn't even display the time or date as it lacked the colon [:] or the period [.] or the slash [/] or the space [ ] characters). So I completely revamped the fonts and added Terminus as the new default with its 2 sizes. Further more I added in both sizes most of the characters up to ASCII code 255. For any code not in there, the space character is substituted. In the case, when you already have provided your own fonts, please have a look at the API changes in the files <terminus.h> and <terminus.cpp>: I promise you whatever time you spent designing your own font, it is not wasted; you merely need to add a second array, which describes which ASCII codes are available in your font, and their byte offset in the original character bitmap array; and a struct to tie all parts together and describe the character size. I am sorry for breaking the old API, but you will like the change and new options it brings you. Now you can insert any char above 127 up to code 255 (if available, of course) with its hex representation, e.g displaying the current temperature would look something like 85\xB0 F or 26\xB0 C (the space in between degree and F or C is needed because both F and C are used in hex numbers, so \xB0F is interpreted as ASCII code 2831 instead of ASCII code 176, followed by the temperature scale denomination; if you insist on avoiding the space, you could write 85\xB0\x46 which will be displayed correctly as 85°F). You can either look up the ASCII code you need on Google or Bing, or just look at what's available - how it looks and its hex value - in the comments in <terminus.cpp>.
  • Added PWM backlight control. If you intend to use this, please make sure that control pin is either one of p21, p22, p23, p24, p25, or p26, as only they support hardware PWM. Please be aware that the mbed pins do not have much juice behind them, so if your display's backlight requires a lot of current, you are better off interfacing through as small signal transistor or a MOSFET. For the rest please consult the updated Doxygen documentation. NOTE The addition of PWM-controlled backlight will not break your existing code, the new options have default values, which initialize the used driver to behave as prior to PWM. Only if you want to use the new feature, some changes need to be made. The PWM is configured to be 120Hz (period of 8.33 milliseconds), in order to avoid noticeable flicker in the backlight. If in your opinion this value is too fine, then you can reduce the frequency in the LCD constructor in <lcd_base.cpp> by increasing the period value. My recommendation is to avoid frequencies lower than 60Hz.

2012-12-21

  • Internal-only changes in the way drivers transmit colors - done to simplify the bitmap drawing routines; client API remains unchanged.

2012-12-12

  • Added the driver for the ST7735 display controller.
  • Added the RGB18 color mode: choose between 16-bit (65K distinct colors) and 18-bit (262K distinct colors) color space [supported by all drivers]. NOTE This feature requires the image drawing functions to be changed, in order to account for differences between configured display color depth and the color depth of the image. Please review the API docs, in particular the new type bitmap_t and the DrawBitmap functions.
  • Changed display rotation to be achieved through the correspondent settings in the respective controller registers: no more software translation between width and height in different display orientations.
  • Extended the orientation options: PORTRAIT (top line to 12 o'clock/upright) and LANDSCAPE (top line to 9 o'clock) positions are the old options, PORTRAIT_REV (top line to 6 o'clock/upside-down) and LANDSCAPE_REV (top line to 3 o'clock) are the new orientations.
  • Added more pre-defined colors: available now are COLOR_BLACK, COLOR_WHITE, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_CYAN, COLOR_MAGENTA and COLOR_YELLOW.

TODO

  • Finish implementing PWM-controlled backlight (current-sink configuration).
  • Add a driver for the HX8352-A controller (ITDB02-3.2WD 16:9 240x400 pixel resolution display).

How to Use

The code is documented, so please review the API docs. There is a simple example to get you started...

Committer:
ttodorov
Date:
Sat Jun 15 05:34:53 2013 +0000
Revision:
24:ac6e35658037
Parent:
23:eca4414196ca
Child:
25:6cffb758c075
- ported ILI9328 (actually ILI9325D) driver from UTFT; still need to fix screen rotation.

Who changed what in which revision?

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