Programme de test pour lcd ITDB02
Fork of TFTLCD by
Revision 3:64a5b67d5b51, committed 2012-12-02
- Comitter:
- ttodorov
- Date:
- Sun Dec 02 01:44:23 2012 +0000
- Parent:
- 2:81ed304b7e9b
- Child:
- 4:3ac4239f6c9c
- Commit message:
- - fixed documentation; - renamed ssd* source files to match the name of the LCD controller
Changed in this revision
--- a/fonts.h Sun Dec 02 00:12:43 2012 +0000 +++ b/fonts.h Sun Dec 02 01:44:23 2012 +0000 @@ -132,8 +132,8 @@ * Free Software Foundation, Inc. * 51 Franklin St, 5th Floor, Boston, MA 02110-1301, USA */ -#ifndef SSD1289_FONTS_H -#define SSD1289_FONTS_H +#ifndef TFTLCD_FONTS_H +#define TFTLCD_FONTS_H /** Small font, 8x12 pixels, <space> 1st character, 95 total characters */ const char Font8x12[] = { @@ -355,4 +355,4 @@ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFE,0x00,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x60,0x0C,0xFF,0xFE,0xF0,0x1E,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3F,0x00,0x01,0xF8,0x3E,0x00,0x00,0x78,0x39,0xFF,0xFE,0x18,0x23,0xFF,0xFF,0x88,0x0F,0xFF,0xFF,0xE0,0x07,0xFF,0xFF,0xC0,0x01,0xFF,0xFF,0x18,0x00,0x00,0x00,0x78,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x01,0xF8,0x00,0x00,0x00,0xF0,0x00,0xFF,0xFE,0x60,0x01,0xFF,0xFF,0x00,0x03,0xFF,0xFF,0x80,0x01,0xFF,0xFF,0x00,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 9 }; -#endif /* SSD1289_FONTS_H */ +#endif /* TFTLCD_FONTS_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/helpers.h Sun Dec 02 01:44:23 2012 +0000 @@ -0,0 +1,61 @@ +/** \file helpers.h + * \brief Utility functions and macros. + * \copyright GNU Public License, v2. or later + * + * This library is based on the Arduino/chipKIT UTFT library by Henning + * Karlsen, http://henningkarlsen.com/electronics/library.php?id=52 + * + * Copyright (C)2010-2012 Henning Karlsen. All right reserved. + * Copyright (C)2012 Todor Todorov. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to: + * + * Free Software Foundation, Inc. + * 51 Franklin St, 5th Floor, Boston, MA 02110-1301, USA + * + *********************************************************************/ +#ifndef TFTLCD_HELPERS_H +#define TFTLCD_HELPERS_H + +#include "mbed.h" + +/** \def HIGH + * \brief User-friendly high pin level designation. + */ +#define HIGH 1 +/** \def LOW + * \brief User-friendly low pin level designation. + */ +#define LOW 0 + +/** \def swap( type, a, b ) + * \brief Convenience macro to swap two values. + */ +#define swap( type, a, b ) { type tmp = ( a ); ( a ) = ( b ); ( b ) = tmp; } + +/** \def pulseLow( pin ) + * \brief Toggles a pin low, then high. + */ +#define pulseLow( pin ) pin = LOW; pin = HIGH + +/** \def pulseHigh( pin ) + * \brief Toggles a pin high, then low. + */ +#define pulseHigh( pin ) pin = HIGH; pin = LOW + +#ifndef ushort +typedef unsigned short ushort; +#endif + +#endif /* TFTLCD_HELPERS_H */
--- a/lcd_base.cpp Sun Dec 02 00:12:43 2012 +0000 +++ b/lcd_base.cpp Sun Dec 02 01:44:23 2012 +0000 @@ -20,10 +20,7 @@ * *********************************************************************/ #include "lcd_base.h" - -#ifndef ushort -typedef unsigned short ushort; -#endif +#include "helpers.h" LCD::LCD( unsigned short width, unsigned short height ,PinName CS, PinName RS ) : _disp_width( width ), _disp_height( height ), _lcd_pin_cs( CS ), _lcd_pin_rs( RS )
--- a/lcd_base.h Sun Dec 02 00:12:43 2012 +0000 +++ b/lcd_base.h Sun Dec 02 01:44:23 2012 +0000 @@ -27,26 +27,12 @@ * 51 Franklin St, 5th Floor, Boston, MA 02110-1301, USA * *********************************************************************/ -#ifndef LCD_BASE_H -#define LCD_BASE_H +#ifndef TFTLCD_BASE_H +#define TFTLCD_BASE_H #include "mbed.h" #include "fonts.h" -/** \def HIGH - * \brief User-friendly high pin level designation. - */ -#define HIGH 1 -/** \def LOW - * \brief User-friendly low pin level designation. - */ -#define LOW 0 - -/** \def swap( type, a, b ) - * \brief Convenience macro to swap two values. - */ -#define swap( type, a, b ) { type tmp = ( a ); ( a ) = ( b ); ( b ) = tmp; } - /** \def RGB(r,g,b) * \brief Creates a RGB-565 color value. * @@ -437,4 +423,4 @@ font_metrics_t _font; }; -#endif /* LCD_BASE_H */ +#endif /* TFTLCD_BASE_H */
--- a/ssd.cpp Sun Dec 02 00:12:43 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -/* - * Copyright (C)2010-2012 Henning Karlsen. All right reserved. - * Copyright (C)2012 Todor Todorov. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to: - * - * Free Software Foundation, Inc. - * 51 Franklin St, 5th Floor, Boston, MA 02110-1301, USA - * - *********************************************************************/ -#include "ssd.h" - -#define pulseLow( pin ) pin = LOW; pin = HIGH -#define pulseHigh( pin ) pin = HIGH; pin = LOW - -SSD1289LCD::SSD1289LCD( PinName CS, PinName RESET, PinName RS, PinName WR, BusOut* DATA_PORT, PinName RD ) - : LCD( 240, 320, CS, RS ), _lcd_pin_reset( RESET ), _lcd_pin_wr( WR ) -{ - _lcd_port = DATA_PORT; - if ( RD != NC ) - _lcd_pin_rd = new DigitalOut( RD ); - else - _lcd_pin_rd = 0; - - SetForeground(); - SetBackground(); - _font.font = 0; -} - -void SSD1289LCD::Initialize( orientation_t orientation ) -{ - _orientation = orientation; - - _lcd_pin_reset = HIGH; - wait_ms( 5 ); - _lcd_pin_reset = LOW; - wait_ms( 15 ); - _lcd_pin_reset = HIGH; - _lcd_pin_cs = HIGH; - if ( _lcd_pin_rd != 0 ) - *_lcd_pin_rd = HIGH; - _lcd_pin_wr = HIGH; - wait_ms( 15 ); - - - WriteCmdData( 0x00, 0x0001 ); wait_ms( 1 ); - WriteCmdData( 0x03, 0xA8A4 ); wait_ms( 1 ); - WriteCmdData( 0x0C, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x0D, 0x080C ); wait_ms( 1 ); - WriteCmdData( 0x0E, 0x2B00 ); wait_ms( 1 ); - WriteCmdData( 0x1E, 0x00B7 ); wait_ms( 1 ); - WriteCmdData( 0x01, 0x2B3F ); wait_ms( 1 ); - WriteCmdData( 0x02, 0x0600 ); wait_ms( 1 ); - WriteCmdData( 0x10, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x11, 0x6070 ); wait_ms( 1 ); - WriteCmdData( 0x05, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x06, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x16, 0xEF1C ); wait_ms( 1 ); - WriteCmdData( 0x17, 0x0003 ); wait_ms( 1 ); - WriteCmdData( 0x07, 0x0233 ); wait_ms( 1 ); - WriteCmdData( 0x0B, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x0F, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x41, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x42, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x48, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x49, 0x013F ); wait_ms( 1 ); - WriteCmdData( 0x4A, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x4B, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x44, 0xEF00 ); wait_ms( 1 ); - WriteCmdData( 0x45, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x46, 0x013F ); wait_ms( 1 ); - WriteCmdData( 0x30, 0x0707 ); wait_ms( 1 ); - WriteCmdData( 0x31, 0x0204 ); wait_ms( 1 ); - WriteCmdData( 0x32, 0x0204 ); wait_ms( 1 ); - WriteCmdData( 0x33, 0x0502 ); wait_ms( 1 ); - WriteCmdData( 0x34, 0x0507 ); wait_ms( 1 ); - WriteCmdData( 0x35, 0x0204 ); wait_ms( 1 ); - WriteCmdData( 0x36, 0x0204 ); wait_ms( 1 ); - WriteCmdData( 0x37, 0x0502 ); wait_ms( 1 ); - WriteCmdData( 0x3A, 0x0302 ); wait_ms( 1 ); - WriteCmdData( 0x3B, 0x0302 ); wait_ms( 1 ); - WriteCmdData( 0x23, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x24, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x25, 0x8000 ); wait_ms( 1 ); - WriteCmdData( 0x4f, 0x0000 ); wait_ms( 1 ); - WriteCmdData( 0x4e, 0x0000 ); wait_ms( 1 ); - WriteCmd( 0x22 ); -} - -void SSD1289LCD::WriteCmd( unsigned short cmd ) -{ - _lcd_pin_rs = LOW; - _lcd_pin_cs = LOW; - _lcd_port->write( cmd ); - pulseLow( _lcd_pin_wr ); - _lcd_pin_cs = HIGH; -} - -void SSD1289LCD::WriteData( unsigned short data ) -{ - _lcd_pin_rs = HIGH; - _lcd_pin_cs = LOW; - _lcd_port->write( data ); - pulseLow( _lcd_pin_wr ); - _lcd_pin_cs = HIGH; -} - -void SSD1289LCD::SetXY( uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2 ) -{ - if ( _orientation == LANDSCAPE ) - { - swap( uint16_t, x1, y1 ) - swap( uint16_t, x2, y2 ) - y1 = _disp_height - y1; - y2 = _disp_height - y2; - swap( uint16_t, y1, y2 ) - } - - WriteCmdData( 0x44, ( x2 << 8 ) + x1 ); - WriteCmdData( 0x45, y1 ); - WriteCmdData( 0x46, y2 ); - WriteCmdData( 0x4e, x1 ); - WriteCmdData( 0x4f, y1 ); - WriteCmd( 0x22 ); -}
--- a/ssd.h Sun Dec 02 00:12:43 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +0,0 @@ -/** \file ssd.h - * \brief mbed TFT LCD controller for displays with the SSD1289 IC. - * \copyright GNU Public License, v2. or later - * - * A known display with this type of controller chip is the ITDB02-3.2S - * from http://imall.iteadstudio.com - * - * This library is based on the Arduino/chipKIT UTFT library by Henning - * Karlsen, http://henningkarlsen.com/electronics/library.php?id=52 - * - * Copyright (C)2010-2012 Henning Karlsen. All right reserved. - * Copyright (C)2012 Todor Todorov. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to: - * - * Free Software Foundation, Inc. - * 51 Franklin St, 5th Floor, Boston, MA 02110-1301, USA - * - *********************************************************************/ -#ifndef SSD_H -#define SSD_H - -#include "lcd_base.h" - -class SSD1289LCD : public LCD -{ -public: - /** Creates a new instance of the class. - * - * \param CS Pin for the ChipSelect signal. - * \param RESET Pin for the RESET line. - * \param RS Pin for the RS signal. - * \param WR Pin for the WR signal. - * \param DATA_PORT Address of the data bus for transfer of commands and pixel data. - * \param RD Pin for the RD signal. This line is not needed by the driver, so if you would like to - * use the pin on the mbed for something else, just pull-up the respective pin on the LCD high, - * and do not assign a value to this parameter when creating the controller instance. - */ - SSD1289LCD( PinName CS, PinName RESET, PinName RS, PinName WR, BusOut* DATA_PORT, PinName RD = NC ); - - /** Initialize display. - * - * Wakes up the display from sleep, initializes power parameters. - * This function must be called first, befor any painting on the - * display is done, otherwise the positioning of graphical elements - * will not work properly and any paynt operation will not be visible - * or produce garbage. - * - * \param oritentation The display orientation, landscape is default. - */ - virtual void Initialize( orientation_t orientation = LANDSCAPE ); - -protected: - virtual void WriteCmd( unsigned short cmd ); - virtual void WriteData( unsigned short data ); - virtual void SetXY( uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2 ); - -private: - DigitalOut _lcd_pin_reset, _lcd_pin_wr; - BusOut* _lcd_port; - DigitalOut* _lcd_pin_rd; -}; - -#endif /* SSD_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ssd1289.cpp Sun Dec 02 01:44:23 2012 +0000 @@ -0,0 +1,134 @@ +/* + * Copyright (C)2010-2012 Henning Karlsen. All right reserved. + * Copyright (C)2012 Todor Todorov. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to: + * + * Free Software Foundation, Inc. + * 51 Franklin St, 5th Floor, Boston, MA 02110-1301, USA + * + *********************************************************************/ +#include "ssd1289.h" +#include "helpers.h" + +SSD1289LCD::SSD1289LCD( PinName CS, PinName RESET, PinName RS, PinName WR, BusOut* DATA_PORT, PinName RD ) + : LCD( 240, 320, CS, RS ), _lcd_pin_reset( RESET ), _lcd_pin_wr( WR ) +{ + _lcd_port = DATA_PORT; + if ( RD != NC ) + _lcd_pin_rd = new DigitalOut( RD ); + else + _lcd_pin_rd = 0; + + SetForeground(); + SetBackground(); + _font.font = 0; +} + +void SSD1289LCD::Initialize( orientation_t orientation ) +{ + _orientation = orientation; + + _lcd_pin_reset = HIGH; + wait_ms( 5 ); + _lcd_pin_reset = LOW; + wait_ms( 15 ); + _lcd_pin_reset = HIGH; + _lcd_pin_cs = HIGH; + if ( _lcd_pin_rd != 0 ) + *_lcd_pin_rd = HIGH; + _lcd_pin_wr = HIGH; + wait_ms( 15 ); + + + WriteCmdData( 0x00, 0x0001 ); wait_ms( 1 ); + WriteCmdData( 0x03, 0xA8A4 ); wait_ms( 1 ); + WriteCmdData( 0x0C, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x0D, 0x080C ); wait_ms( 1 ); + WriteCmdData( 0x0E, 0x2B00 ); wait_ms( 1 ); + WriteCmdData( 0x1E, 0x00B7 ); wait_ms( 1 ); + WriteCmdData( 0x01, 0x2B3F ); wait_ms( 1 ); + WriteCmdData( 0x02, 0x0600 ); wait_ms( 1 ); + WriteCmdData( 0x10, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x11, 0x6070 ); wait_ms( 1 ); + WriteCmdData( 0x05, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x06, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x16, 0xEF1C ); wait_ms( 1 ); + WriteCmdData( 0x17, 0x0003 ); wait_ms( 1 ); + WriteCmdData( 0x07, 0x0233 ); wait_ms( 1 ); + WriteCmdData( 0x0B, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x0F, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x41, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x42, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x48, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x49, 0x013F ); wait_ms( 1 ); + WriteCmdData( 0x4A, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x4B, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x44, 0xEF00 ); wait_ms( 1 ); + WriteCmdData( 0x45, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x46, 0x013F ); wait_ms( 1 ); + WriteCmdData( 0x30, 0x0707 ); wait_ms( 1 ); + WriteCmdData( 0x31, 0x0204 ); wait_ms( 1 ); + WriteCmdData( 0x32, 0x0204 ); wait_ms( 1 ); + WriteCmdData( 0x33, 0x0502 ); wait_ms( 1 ); + WriteCmdData( 0x34, 0x0507 ); wait_ms( 1 ); + WriteCmdData( 0x35, 0x0204 ); wait_ms( 1 ); + WriteCmdData( 0x36, 0x0204 ); wait_ms( 1 ); + WriteCmdData( 0x37, 0x0502 ); wait_ms( 1 ); + WriteCmdData( 0x3A, 0x0302 ); wait_ms( 1 ); + WriteCmdData( 0x3B, 0x0302 ); wait_ms( 1 ); + WriteCmdData( 0x23, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x24, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x25, 0x8000 ); wait_ms( 1 ); + WriteCmdData( 0x4f, 0x0000 ); wait_ms( 1 ); + WriteCmdData( 0x4e, 0x0000 ); wait_ms( 1 ); + WriteCmd( 0x22 ); +} + +void SSD1289LCD::WriteCmd( unsigned short cmd ) +{ + _lcd_pin_rs = LOW; + _lcd_pin_cs = LOW; + _lcd_port->write( cmd ); + pulseLow( _lcd_pin_wr ); + _lcd_pin_cs = HIGH; +} + +void SSD1289LCD::WriteData( unsigned short data ) +{ + _lcd_pin_rs = HIGH; + _lcd_pin_cs = LOW; + _lcd_port->write( data ); + pulseLow( _lcd_pin_wr ); + _lcd_pin_cs = HIGH; +} + +void SSD1289LCD::SetXY( uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2 ) +{ + if ( _orientation == LANDSCAPE ) + { + swap( uint16_t, x1, y1 ) + swap( uint16_t, x2, y2 ) + y1 = _disp_height - y1; + y2 = _disp_height - y2; + swap( uint16_t, y1, y2 ) + } + + WriteCmdData( 0x44, ( x2 << 8 ) + x1 ); + WriteCmdData( 0x45, y1 ); + WriteCmdData( 0x46, y2 ); + WriteCmdData( 0x4e, x1 ); + WriteCmdData( 0x4f, y1 ); + WriteCmd( 0x22 ); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ssd1289.h Sun Dec 02 01:44:23 2012 +0000 @@ -0,0 +1,114 @@ +/** \file ssd.h + * \brief mbed TFT LCD controller for displays with the SSD1289 IC. + * \copyright GNU Public License, v2. or later + * + * A known display with this type of controller chip is the ITDB02-3.2S + * from http://imall.iteadstudio.com + * + * This library is based on the Arduino/chipKIT UTFT library by Henning + * Karlsen, http://henningkarlsen.com/electronics/library.php?id=52 + * + * Copyright (C)2010-2012 Henning Karlsen. All right reserved. + * Copyright (C)2012 Todor Todorov. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to: + * + * Free Software Foundation, Inc. + * 51 Franklin St, 5th Floor, Boston, MA 02110-1301, USA + * + *********************************************************************/ +#ifndef TFTLCD_SSD1289_H +#define TFTLCD_SSD1289_H + +#include "lcd_base.h" + +/** Represents a LCD instance. + * + * This is the utility class, through which the display can be manipulated + * and graphics objects can be shown to the user. A known display, which + * works with this library is the ITDB02-3.2S from iTeadStudio - a RGB TFT + * with 240x320 pixels resolution and 65K colors, using 16-bit interface. + * + * The display needs 20 or 21 pins to work with mbed, so it is possibly not + * the best of choices out there, but other than that it uses +3.3V for + * power and logic, as well as the backlight, thus can be interfaced directly + * to the mbed without the need of shields or level shifters as with Arduino. + * + * How to use: + * \code + * // include the library, this will also pull in the header for the provided fonts + * #include "ssd1289.h" + * + * // prepare the data bus for writing commands and pixel data + * BusOut dataBus( p30, p29, p28, p27, p26, p25, p24, p23, p22, p21, p20, p19, p18, p17, p16, p15 ); // 16 pins + * // create the lcd instance + * SSD1289 lcd( p14, p13, p12, p11, &dataBus ); // control pins and data bus + * + * int main() + * { + * // initialize display - place it in standard portrait mode and set background to black and + * // foreground to white color. + * lcd.Initialize(); + * // set current font to the smallest 8x12 pixels font. + * lcd.SetFont( Font8x12 ); + * // print something on the screen + * lcd.Print( "Hello, World!", CENTER, 25 ); // align text to center horizontally and use starndard colors + * + * while ( 1 ) { } + * } + * + * \endcode + * \version 0.1 + * \author Todor Todorov + */ +class SSD1289LCD : public LCD +{ +public: + /** Creates a new instance of the class. + * + * \param CS Pin for the ChipSelect signal. + * \param RESET Pin for the RESET line. + * \param RS Pin for the RS signal. + * \param WR Pin for the WR signal. + * \param DATA_PORT Address of the data bus for transfer of commands and pixel data. + * \param RD Pin for the RD signal. This line is not needed by the driver, so if you would like to + * use the pin on the mbed for something else, just pull-up the respective pin on the LCD high, + * and do not assign a value to this parameter when creating the controller instance. + */ + SSD1289LCD( PinName CS, PinName RESET, PinName RS, PinName WR, BusOut* DATA_PORT, PinName RD = NC ); + + /** Initialize display. + * + * Wakes up the display from sleep, initializes power parameters. + * This function must be called first, befor any painting on the + * display is done, otherwise the positioning of graphical elements + * will not work properly and any paynt operation will not be visible + * or produce garbage. + * + * \param oritentation The display orientation, landscape is default. + */ + virtual void Initialize( orientation_t orientation = LANDSCAPE ); + +protected: + virtual void WriteCmd( unsigned short cmd ); + virtual void WriteData( unsigned short data ); + virtual void SetXY( uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2 ); + +private: + DigitalOut _lcd_pin_reset, _lcd_pin_wr; + BusOut* _lcd_port; + DigitalOut* _lcd_pin_rd; +}; + +#endif /* TFTLCD_SSD1289_H */