A modifiedversion of TFTLCD by Todor Todorov with ultra-fast operation for SSD1289 controller. TODO: speed-up fonts, add my own fonts Can work out-of-the-box with ST Nucleo F401RE

Dependents:   TFT_320QVT_Window_Drag_Demo TFT_320QVT_HelloWorld

Fork of TFTLCD by Todor Todorov

Revision:
28:2f24de90cb46
Parent:
24:ac6e35658037
diff -r 26491d710e72 -r 2f24de90cb46 ssd1289.h
--- a/ssd1289.h	Mon Jul 22 01:48:06 2013 +0000
+++ b/ssd1289.h	Mon Jan 11 09:35:06 2016 +0000
@@ -8,10 +8,14 @@
  * This library is based on the Arduino/chipKIT UTFT library by Henning
  * Karlsen, http://henningkarlsen.com/electronics/library.php?id=52
  *
+ * Optimized fast version for SSD1289 by Dmitry Shtatnov
+ *
  * Copyright (C)2010-2012 Henning Karlsen. All right reserved.
  *
  * Copyright (C)2012 Todor Todorov.
  *
+ * Copyright (C)2016 Dmitry Shtatnov
+ *
  * 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
@@ -55,10 +59,20 @@
  * // 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
+ * // prepare the data bus for writing commands and pixel data (LSB..MSB)
  * 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 lcd( p14, p13, p12, p11, &dataBus ); // control pins and data bus
+ * // You can also prepare a PortOut for faster operation:
+ * // PortOut dataPort(PortC, 0xFFFF); // 16 pins
+ * // SSD1289_LCD lcd( p14, p13, p12, p11, &dataPort ); // control pins and data bus
+ * //
+ * // Or, you can use separated port, which is usefull with some platforms such as ST Nucleo F401RE,
+ * // having no ports with all 16 pins available for output. (by default)
+ * // PortOut dataPortA(PortA, 0xFF00); // 16 pins
+ * // PortOut dataPortC(PortC, 0x00FF); // 16 pins
+ * // SSD1289_LCD lcd( p14, p13, p12, p11, &dataPortA, &dataPortC ); // control pins and data bus
+ 
  *
  * int main()
  * {
@@ -66,7 +80,7 @@
  *     //                      foreground to white color.
  *     lcd.Initialize();
  *     // set current font to the smallest 8x12 pixels font.
- *     lcd.SetFont( Font8x12 );
+ *     lcd.SetFont( &TerminusFont );
  *     // print something on the screen
  *     lcd.Print( "Hello, World!", CENTER, 25 ); // align text to center horizontally and use starndard colors
  *
@@ -95,6 +109,39 @@
      * \param defaultBacklightLevel If using PWM to control backlight, this would be the default brightness in percent after LCD initialization.
      */
     SSD1289_LCD( PinName CS, PinName RESET, PinName RS, PinName WR, BusOut* DATA_PORT, PinName BL = NC, PinName RD = NC, backlight_t blType = Constant, float defaultBackLightLevel = 1.0 );
+
+    /** 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 FAST_DATA_PORT_H High Byte Address of the data port for transfer of commands and pixel data. Should have 0xFF00 mask
+     * \param FAST_DATA_PORT_L Low Byte Address of the data port for transfer of commands and pixel data. Should have 0x00FF mask
+     * \param BL Pin for controlling the backlight. By default not used.
+     * \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.
+     * \param blType The backlight type, the default is to utilize the pin - if supplied - as a simple on/off switch
+     * \param defaultBacklightLevel If using PWM to control backlight, this would be the default brightness in percent after LCD initialization.
+     */
+    SSD1289_LCD( PinName CS, PinName RESET, PinName RS, PinName WR, PortOut* FAST_DATA_PORT_H, PortOut* FAST_DATA_PORT_L, PinName BL = NC, PinName RD = NC, backlight_t blType = Constant, float defaultBackLightLevel = 1.0 );
+
+    /** 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 FAST_DATA_PORT Address of the data port for transfer of commands and pixel data.
+     * \param BL Pin for controlling the backlight. By default not used.
+     * \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.
+     * \param blType The backlight type, the default is to utilize the pin - if supplied - as a simple on/off switch
+     * \param defaultBacklightLevel If using PWM to control backlight, this would be the default brightness in percent after LCD initialization.
+     */
+    SSD1289_LCD( PinName CS, PinName RESET, PinName RS, PinName WR, PortOut* FAST_DATA_PORT, PinName BL = NC, PinName RD = NC, backlight_t blType = Constant, float defaultBackLightLevel = 1.0 );
     
     /** Initialize display.
      *
@@ -134,6 +181,14 @@
      */
     virtual void WakeUp( void );
     
+    virtual void FillScreen( int color );
+
+    virtual void FillRect( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2, int color );
+
+    virtual void DrawVLine( unsigned short x, unsigned short y, unsigned short len, int color = -2);
+
+    virtual void DrawHLine( unsigned short x, unsigned short y, unsigned short len, int color = -2);
+
 protected:
     /** Sends a command to the display.
      *
@@ -151,6 +206,8 @@
      */
     virtual void WriteData( unsigned short data );
     
+    virtual void _fast_fill_16(int color, long pix);
+    
     /** Assigns a chunk of the display memory to receive data.
      *
      * When data is sent to the display after this function completes, the opertion will
@@ -183,6 +240,9 @@
     BusOut*     _lcd_port;
     DigitalOut* _lcd_pin_bl;
     DigitalOut* _lcd_pin_rd;
+    PortOut* _hp;
+    PortOut* _lp;
+    bool    _use_fast_port, _use_separate_port;
 };
 
 #ifdef __cplusplus