Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of TFTLCD by
ssd1963.h
00001 /** \file ssd1963.h 00002 * \brief mbed TFT LCD controller for displays with the SSD1963 IC. 00003 * \copyright GNU Public License, v2. or later 00004 * 00005 * 00006 * This library is based on the Arduino/chipKIT UTFT library by Henning 00007 * Karlsen, http://henningkarlsen.com/electronics/library.php?id=52 00008 * 00009 * Copyright (C)2010-2012 Henning Karlsen. All right reserved. 00010 * 00011 * Copyright (C)2012 Todor Todorov. 00012 * 00013 * Copyright (C)2014 Robert Fischer 00014 * 00015 * This library is free software; you can redistribute it and/or 00016 * modify it under the terms of the GNU Lesser General Public 00017 * License as published by the Free Software Foundation; either 00018 * version 2.1 of the License, or (at your option) any later version. 00019 * 00020 * This library is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00023 * Lesser General Public License for more details. 00024 * 00025 * You should have received a copy of the GNU Lesser General Public 00026 * License along with this library; if not, write to: 00027 * 00028 * Free Software Foundation, Inc. 00029 * 51 Franklin St, 5th Floor, Boston, MA 02110-1301, USA 00030 * 00031 *********************************************************************/ 00032 #ifndef TFTLCD_SSD1963_H 00033 #define TFTLCD_SSD1963_H 00034 00035 #include "lcd_base.h" 00036 00037 #ifdef __cplusplus 00038 extern "C" { 00039 #endif 00040 00041 /********************************************************************* 00042 * Overview: Panel Data Width (R,G,B) in (6,6,6) 00043 *********************************************************************/ 00044 #define DISP_DATA_WIDTH 18 00045 /********************************************************************* 00046 * Overview: Horizontal and vertical display resolution 00047 * (from the glass datasheet). 00048 *********************************************************************/ 00049 #define DISP_HOR_RESOLUTION 480 //800 00050 #define DISP_VER_RESOLUTION 272 //480 00051 /********************************************************************* 00052 * Overview: Horizontal synchronization timing in pixels 00053 * (from the glass datasheet). 00054 *********************************************************************/ 00055 #define DISP_HOR_PULSE_WIDTH 1 00056 #define DISP_HOR_BACK_PORCH 210 00057 #define DISP_HOR_FRONT_PORCH 45 00058 /********************************************************************* 00059 * Overview: Vertical synchronization timing in lines 00060 * (from the glass datasheet). 00061 *********************************************************************/ 00062 #define DISP_VER_PULSE_WIDTH 1 00063 #define DISP_VER_BACK_PORCH 34 00064 #define DISP_VER_FRONT_PORCH 10 00065 00066 /** Represents a LCD instance. 00067 * 00068 * This is the utility class, through which the display can be manipulated 00069 * and graphics objects can be shown to the user. 00070 * 00071 * The display needs 20 to 22 pins to work with mbed, so it is possibly not 00072 * the best of choices out there, but other than that it uses +3.3V for 00073 * power and logic, as well as the backlight, thus can be interfaced directly 00074 * to the mbed without the need of shields or level shifters as with Arduino. 00075 * 00076 * How to use: 00077 * \code 00078 * // include the library, this will also pull in the header for the provided fonts 00079 * #include "ssd1963.h" 00080 * 00081 * // prepare the data bus for writing commands and pixel data 00082 * BusOut dataBus( p30, p29, p28, p27, p26, p25, p24, p23, p22, p21, p20, p19, p18, p17, p16, p15 ); // 16 pins 00083 * // create the lcd instance 00084 * SSD1963_LCD lcd( p14, p13, p12, p11, &dataBus ); // control pins and data bus 00085 * 00086 * int main() 00087 * { 00088 * // initialize display - place it in standard portrait mode and set background to black and 00089 * // foreground to white color. 00090 * lcd.Initialize(); 00091 * // set current font to the smallest 8x12 pixels font. 00092 * lcd.SetFont( Font8x12 ); 00093 * // print something on the screen 00094 * lcd.Print( "Hello, World!", CENTER, 25 ); // align text to center horizontally and use starndard colors 00095 * 00096 * while ( 1 ) { } 00097 * } 00098 * 00099 * \endcode 00100 * \version 0.1 00101 * \author Todor Todorov 00102 */ 00103 class SSD1963_LCD : public LCD 00104 { 00105 public: 00106 /** Creates a new instance of the class. 00107 * 00108 * \param CS Pin for the ChipSelect signal. 00109 * \param RESET Pin for the RESET line. 00110 * \param RS Pin for the RS signal. 00111 * \param WR Pin for the WR signal. 00112 * \param DATA_PORT Address of the data bus for transfer of commands and pixel data. 00113 * \param BL Pin for controlling the backlight. By default not used. 00114 * \param RD Pin for the RD signal. This line is not needed by the driver, so if you would like to 00115 * use the pin on the mbed for something else, just pull-up the respective pin on the LCD high, 00116 * and do not assign a value to this parameter when creating the controller instance. 00117 * \param blType The backlight type, the default is to utilize the pin - if supplied - as a simple on/off switch 00118 * \param defaultBacklightLevel If using PWM to control backlight, this would be the default brightness in percent after LCD initialization. 00119 */ 00120 SSD1963_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 ); 00121 00122 /** Initialize display. 00123 * 00124 * Wakes up the display from sleep, initializes power parameters. 00125 * This function must be called first, befor any painting on the 00126 * display is done, otherwise the positioning of graphical elements 00127 * will not work properly and any paynt operation will not be visible 00128 * or produce garbage. 00129 * 00130 * \param oritentation The display orientation, landscape is default. 00131 * \param colors The correct color depth to use for the pixel data. Value is disregarded. 00132 */ 00133 virtual void Initialize( orientation_t orientation = LANDSCAPE, colordepth_t colors = RGB16 ); 00134 00135 /** Puts the display to sleep. 00136 * 00137 * When the display is in sleep mode, its power consumption is 00138 * minimized. Before new pixel data can be written to the display 00139 * memory, the controller needs to be brought out of sleep mode. 00140 * \sa #WakeUp( void ); 00141 * \remarks The result of this operation might not be exactly as 00142 * expected. Putting the display to sleep will cause the 00143 * controller to switch to the standard color of the LCD, 00144 * so depending on whether the display is normally white, 00145 * or normally dark, the screen might or might not go 00146 * dark. Additional power saving can be achieved, if 00147 * the backlight of the used display is not hardwired on 00148 * the PCB and can be controlled via the BL pin. 00149 */ 00150 virtual void Sleep( void ); 00151 00152 /** Wakes up the display from sleep mode. 00153 * 00154 * This function needs to be called before any other, when the 00155 * display has been put into sleep mode by a previois call to 00156 * #Sleep( void ). 00157 */ 00158 virtual void WakeUp( void ); 00159 00160 protected: 00161 /** Sends a command to the display. 00162 * 00163 * \param cmd The display command. 00164 * \remarks Commands are controller-specific and this function needs to 00165 * be implemented separately for each available controller. 00166 */ 00167 virtual void WriteCmd( unsigned short cmd ); 00168 00169 /** Sends pixel data to the display. 00170 * 00171 * \param data The display data. 00172 * \remarks Sending data is controller-specific and this function needs to 00173 * be implemented separately for each available controller. 00174 */ 00175 virtual void WriteData( unsigned short data ); 00176 00177 /** Assigns a chunk of the display memory to receive data. 00178 * 00179 * When data is sent to the display after this function completes, the opertion will 00180 * start from the begining of the assigned address (pixel position) and the pointer 00181 * will be automatically incremented so that the next data write operation will continue 00182 * with the next pixel from the memory block. If more data is written than available 00183 * pixels, at the end of the block the pointer will jump back to its beginning and 00184 * commence again, until the next address change command is sent to the display. 00185 * 00186 * \param x1 The X coordinate of the pixel at the beginning of the block. 00187 * \param y1 The Y coordinate of the pixel at the beginning of the block. 00188 * \param x2 The X coordinate of the pixel at the end of the block. 00189 * \param y2 The Y coordinate of the pixel at the end of the block. 00190 * \remarks Addressing commands are controller-specific and this function needs to be 00191 * implemented separately for each available controller. 00192 */ 00193 virtual void SetXY( unsigned short x1, unsigned short y1, unsigned short x2, unsigned short y2 ); 00194 00195 /** Sets the color of the pixel at the address pointer of the controller. 00196 * 00197 * This function is to be provided by each implementation separately in 00198 * order to account for different color depth used by the controller. 00199 * \param color The color of the pixel. 00200 * \param mode The depth (palette) of the color. 00201 */ 00202 virtual void SetPixelColor( unsigned int color, colordepth_t mode = RGB24 ); 00203 00204 private: 00205 DigitalOut _lcd_pin_wr; 00206 BusOut* _lcd_port; 00207 DigitalOut* _lcd_pin_bl; 00208 DigitalOut* _lcd_pin_rd; 00209 }; 00210 00211 #ifdef __cplusplus 00212 } 00213 #endif 00214 00215 #endif /* TFTLCD_SSD1963_H */
Generated on Tue Jul 12 2022 22:53:43 by
1.7.2
