WILLY BAYOT / stm32_adafruit

Dependents:   TDEMNucleo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers st7735.h Source File

st7735.h

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    st7735.h
00004   * @author  MCD Application Team
00005   * @version V1.0.0
00006   * @date    22-April-2014
00007   * @brief   This file contains all the functions prototypes for the st7735.c
00008   *          driver.
00009   ******************************************************************************
00010   * @attention
00011   *
00012   * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
00013   *
00014   * Redistribution and use in source and binary forms, with or without modification,
00015   * are permitted provided that the following conditions are met:
00016   *   1. Redistributions of source code must retain the above copyright notice,
00017   *      this list of conditions and the following disclaimer.
00018   *   2. Redistributions in binary form must reproduce the above copyright notice,
00019   *      this list of conditions and the following disclaimer in the documentation
00020   *      and/or other materials provided with the distribution.
00021   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00022   *      may be used to endorse or promote products derived from this software
00023   *      without specific prior written permission.
00024   *
00025   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00026   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00028   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00029   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00030   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00031   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00032   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00033   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00034   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00035   *
00036   ******************************************************************************
00037   */
00038 
00039 /* Define to prevent recursive inclusion -------------------------------------*/
00040 #ifndef __ST7735_H
00041 #define __ST7735_H
00042 
00043 #ifdef __cplusplus
00044  extern "C" {
00045 #endif 
00046 
00047 /* Includes ------------------------------------------------------------------*/
00048 #include "lcd.h"
00049 
00050 /** @addtogroup BSP
00051   * @{
00052   */ 
00053 
00054 /** @addtogroup Components
00055   * @{
00056   */ 
00057   
00058 /** @addtogroup ST7735
00059   * @{
00060   */
00061 
00062 /** @defgroup ST7735_Exported_Types
00063   * @{
00064   */
00065    
00066 /**
00067   * @}
00068   */ 
00069 
00070 /** @defgroup ST7735_Exported_Constants
00071   * @{
00072   */
00073       
00074 /** 
00075   * @brief  ST7735 Size  
00076   */  
00077 #define  ST7735_LCD_PIXEL_WIDTH    ((uint16_t)128)
00078 #define  ST7735_LCD_PIXEL_HEIGHT   ((uint16_t)160)
00079 
00080 /** 
00081   * @brief  ST7735 Registers  
00082   */ 
00083 #define  LCD_REG_0               0x00 /* No Operation: NOP */
00084 #define  LCD_REG_1               0x01 /* Software reset: SWRESET */
00085 #define  LCD_REG_4               0x04 /* Read Display ID: RDDID */
00086 #define  LCD_REG_9               0x09 /* Read Display Statu: RDDST */
00087 #define  LCD_REG_10              0x0A /* Read Display Power: RDDPM */
00088 #define  LCD_REG_11              0x0B /* Read Display: RDDMADCTL */
00089 #define  LCD_REG_12              0x0C /* Read Display Pixel: RDDCOLMOD */  
00090 #define  LCD_REG_13              0x0D /* Read Display Image: RDDIM */
00091 #define  LCD_REG_14              0x0E /* Read Display Signal: RDDSM */                           
00092 #define  LCD_REG_16              0x10 /* Sleep in & booster off: SLPIN */ 
00093 #define  LCD_REG_17              0x11 /* Sleep out & booster on: SLPOUT */
00094 #define  LCD_REG_18              0x12 /* Partial mode on: PTLON */ 
00095 #define  LCD_REG_19              0x13 /* Partial off (Normal): NORON */
00096 #define  LCD_REG_32              0x20 /* Display inversion off: INVOFF */
00097 #define  LCD_REG_33              0x21 /* Display inversion on: INVON */
00098 #define  LCD_REG_38              0x26 /* Gamma curve select: GAMSET */
00099 #define  LCD_REG_40              0x28 /* Display off: DISPOFF */
00100 #define  LCD_REG_41              0x29 /* Display on: DISPON */
00101 #define  LCD_REG_42              0x2A /* Column address set: CASET */ 
00102 #define  LCD_REG_43              0x2B /* Row address set: RASET */
00103 #define  LCD_REG_44              0x2C /* Memory write: RAMWR */  
00104 #define  LCD_REG_45              0x2D /* LUT for 4k,65k,262k color: RGBSET */
00105 #define  LCD_REG_46              0x2E /* Memory read: RAMRD*/
00106 #define  LCD_REG_48              0x30 /* Partial start/end address set: PTLAR */ 
00107 #define  LCD_REG_52              0x34 /* Tearing effect line off: TEOFF */ 
00108 #define  LCD_REG_53              0x35 /* Tearing effect mode set & on: TEON */ 
00109 #define  LCD_REG_54              0x36 /* Memory data access control: MADCTL */ 
00110 #define  LCD_REG_56              0x38 /* Idle mode off: IDMOFF */ 
00111 #define  LCD_REG_57              0x39 /* Idle mode on: IDMON */ 
00112 #define  LCD_REG_58              0x3A /* Interface pixel format: COLMOD */
00113 #define  LCD_REG_177             0xB1 /* In normal mode (Full colors): FRMCTR1 */
00114 #define  LCD_REG_178             0xB2 /* In Idle mode (8-colors): FRMCTR2 */   
00115 #define  LCD_REG_179             0xB3 /* In partial mode + Full colors: FRMCTR3 */ 
00116 #define  LCD_REG_180             0xB4 /* Display inversion control: INVCTR */
00117 #define  LCD_REG_192             0xC0 /* Power control setting: PWCTR1 */ 
00118 #define  LCD_REG_193             0xC1 /* Power control setting: PWCTR2 */ 
00119 #define  LCD_REG_194             0xC2 /* In normal mode (Full colors): PWCTR3 */
00120 #define  LCD_REG_195             0xC3 /* In Idle mode (8-colors): PWCTR4 */ 
00121 #define  LCD_REG_196             0xC4 /* In partial mode + Full colors: PWCTR5 */ 
00122 #define  LCD_REG_197             0xC5 /* VCOM control 1: VMCTR1 */ 
00123 #define  LCD_REG_199             0xC7 /* Set VCOM offset control: VMOFCTR */ 
00124 #define  LCD_REG_209             0xD1 /* Set LCM version code: WRID2 */ 
00125 #define  LCD_REG_210             0xD2 /* Customer Project code: WRID3 */ 
00126 #define  LCD_REG_217             0xD9 /* NVM control status: NVCTR1 */
00127 #define  LCD_REG_218             0xDA /* Read ID1: RDID1 */ 
00128 #define  LCD_REG_219             0xDB /* Read ID2: RDID2 */ 
00129 #define  LCD_REG_220             0xDC /* Read ID3: RDID3 */ 
00130 #define  LCD_REG_222             0xDE /* NVM Read Command: NVCTR2 */ 
00131 #define  LCD_REG_223             0xDF /* NVM Write Command: NVCTR3 */
00132 #define  LCD_REG_224             0xE0 /* Set Gamma adjustment (+ polarity): GAMCTRP1 */                          
00133 #define  LCD_REG_225             0xE1 /* Set Gamma adjustment (- polarity): GAMCTRN1 */ 
00134 
00135 /** 
00136   * @brief  LCD Lines depending on the chosen fonts.  
00137   */
00138 #define LCD_LINE_0               LINE(0)
00139 #define LCD_LINE_1               LINE(1)
00140 #define LCD_LINE_2               LINE(2)
00141 #define LCD_LINE_3               LINE(3)
00142 #define LCD_LINE_4               LINE(4)
00143 #define LCD_LINE_5               LINE(5)
00144 #define LCD_LINE_6               LINE(6)
00145 #define LCD_LINE_7               LINE(7)
00146 #define LCD_LINE_8               LINE(8)
00147 #define LCD_LINE_9               LINE(9)
00148 #define LCD_LINE_10              LINE(10)
00149 #define LCD_LINE_11              LINE(11)
00150 #define LCD_LINE_12              LINE(12)
00151 #define LCD_LINE_13              LINE(13)
00152 #define LCD_LINE_14              LINE(14)
00153 #define LCD_LINE_15              LINE(15)
00154 #define LCD_LINE_16              LINE(16)
00155 #define LCD_LINE_17              LINE(17)
00156 #define LCD_LINE_18              LINE(18)
00157 #define LCD_LINE_19              LINE(19) 
00158    
00159 /**
00160   * @}
00161   */
00162 
00163 /** @defgroup ADAFRUIT_SPI_LCD_Exported_Functions
00164   * @{
00165   */ 
00166 void     st7735_Init(void);
00167 uint16_t st7735_ReadID(void);
00168 
00169 void     st7735_DisplayOn(void);
00170 void     st7735_DisplayOff(void);
00171 void     st7735_SetCursor(uint16_t Xpos, uint16_t Ypos);
00172 void     st7735_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGB_Code);
00173 void     st7735_WriteReg(uint8_t LCDReg, uint8_t LCDRegValue);
00174 uint8_t  st7735_ReadReg(uint8_t LCDReg);
00175 
00176 void     st7735_DrawHLine(uint16_t RGB_Code, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
00177 void     st7735_DrawVLine(uint16_t RGB_Code, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
00178 
00179 uint16_t st7735_GetLcdPixelWidth(void);
00180 uint16_t st7735_GetLcdPixelHeight(void);
00181 
00182 /* LCD driver structure */
00183 extern LCD_DrvTypeDef   st7735_drv;
00184 
00185 /* LCD IO functions */
00186 void     LCD_IO_Init(void);
00187 void     LCD_IO_WriteData(uint8_t Data);
00188 void     LCD_IO_WriteReg(uint8_t Reg);
00189 void     LCD_Delay(uint32_t delay);
00190 /**
00191   * @}
00192   */
00193 
00194 #ifdef __cplusplus
00195 }
00196 #endif
00197 
00198 #endif /* __ST7735_H */
00199 
00200 /**
00201   * @}
00202   */ 
00203 
00204 /**
00205   * @}
00206   */
00207 
00208 /**
00209   * @}
00210   */ 
00211 
00212 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/