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.
Fork of TFTLCD by
Diff: ssd1289.cpp
- Revision:
- 12:d0978272a340
- Parent:
- 10:69571adcfad5
- Child:
- 15:af3cd35886fb
--- a/ssd1289.cpp Tue Dec 11 16:50:09 2012 +0000 +++ b/ssd1289.cpp Tue Dec 11 18:11:14 2012 +0000 @@ -32,9 +32,10 @@ else _lcd_pin_rd = 0; } -void SSD1289_LCD::Initialize( orientation_t orientation ) +void SSD1289_LCD::Initialize( orientation_t orientation, colordepth_t colors ) { _orientation = orientation; + _colorDepth = RGB16; _lcd_pin_reset = HIGH; wait_ms( 5 ); @@ -142,7 +143,12 @@ WriteCmd( 0x22 ); } -void SSD1289_LCD::SetPixelColor( unsigned short color ) +void SSD1289_LCD::SetPixelColor( unsigned int color ) { - WriteData( color ); + unsigned char r, g, b; + r = ( color >> 16 ) & 0xFF; + g = ( color >> 8 ) & 0xFF; + b = color & 0xFF; + unsigned short clr = ( ( ( ( r ) & 0xF8 ) | ( ( g ) >> 5 ) ) << 8 ) | ( ( ( ( g ) & 0x1C ) << 3 ) | ( ( b ) >> 3 ) ); + WriteData( clr ); }