st7735.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /**
  2. ******************************************************************************
  3. * @file st7735.h
  4. * @author MCD Application Team
  5. * @version V1.1.1
  6. * @date 24-November-2014
  7. * @brief This file contains all the functions prototypes for the st7735.c
  8. * driver.
  9. ******************************************************************************
  10. * @attention
  11. *
  12. * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
  13. *
  14. * Redistribution and use in source and binary forms, with or without modification,
  15. * are permitted provided that the following conditions are met:
  16. * 1. Redistributions of source code must retain the above copyright notice,
  17. * this list of conditions and the following disclaimer.
  18. * 2. Redistributions in binary form must reproduce the above copyright notice,
  19. * this list of conditions and the following disclaimer in the documentation
  20. * and/or other materials provided with the distribution.
  21. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  22. * may be used to endorse or promote products derived from this software
  23. * without specific prior written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  26. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  28. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  29. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  31. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  32. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  33. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. *
  36. ******************************************************************************
  37. */
  38. /* Define to prevent recursive inclusion -------------------------------------*/
  39. #ifndef __ST7735_H
  40. #define __ST7735_H
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. /* Includes ------------------------------------------------------------------*/
  45. #include "../Common/lcd.h"
  46. /** @addtogroup BSP
  47. * @{
  48. */
  49. /** @addtogroup Components
  50. * @{
  51. */
  52. /** @addtogroup ST7735
  53. * @{
  54. */
  55. /** @defgroup ST7735_Exported_Types
  56. * @{
  57. */
  58. /**
  59. * @}
  60. */
  61. /** @defgroup ST7735_Exported_Constants
  62. * @{
  63. */
  64. /**
  65. * @brief ST7735 Size
  66. */
  67. #define ST7735_LCD_PIXEL_WIDTH ((uint16_t)128)
  68. #define ST7735_LCD_PIXEL_HEIGHT ((uint16_t)160)
  69. /**
  70. * @brief ST7735 Registers
  71. */
  72. #define LCD_REG_0 0x00 /* No Operation: NOP */
  73. #define LCD_REG_1 0x01 /* Software reset: SWRESET */
  74. #define LCD_REG_4 0x04 /* Read Display ID: RDDID */
  75. #define LCD_REG_9 0x09 /* Read Display Statu: RDDST */
  76. #define LCD_REG_10 0x0A /* Read Display Power: RDDPM */
  77. #define LCD_REG_11 0x0B /* Read Display: RDDMADCTL */
  78. #define LCD_REG_12 0x0C /* Read Display Pixel: RDDCOLMOD */
  79. #define LCD_REG_13 0x0D /* Read Display Image: RDDIM */
  80. #define LCD_REG_14 0x0E /* Read Display Signal: RDDSM */
  81. #define LCD_REG_16 0x10 /* Sleep in & booster off: SLPIN */
  82. #define LCD_REG_17 0x11 /* Sleep out & booster on: SLPOUT */
  83. #define LCD_REG_18 0x12 /* Partial mode on: PTLON */
  84. #define LCD_REG_19 0x13 /* Partial off (Normal): NORON */
  85. #define LCD_REG_32 0x20 /* Display inversion off: INVOFF */
  86. #define LCD_REG_33 0x21 /* Display inversion on: INVON */
  87. #define LCD_REG_38 0x26 /* Gamma curve select: GAMSET */
  88. #define LCD_REG_40 0x28 /* Display off: DISPOFF */
  89. #define LCD_REG_41 0x29 /* Display on: DISPON */
  90. #define LCD_REG_42 0x2A /* Column address set: CASET */
  91. #define LCD_REG_43 0x2B /* Row address set: RASET */
  92. #define LCD_REG_44 0x2C /* Memory write: RAMWR */
  93. #define LCD_REG_45 0x2D /* LUT for 4k,65k,262k color: RGBSET */
  94. #define LCD_REG_46 0x2E /* Memory read: RAMRD*/
  95. #define LCD_REG_48 0x30 /* Partial start/end address set: PTLAR */
  96. #define LCD_REG_52 0x34 /* Tearing effect line off: TEOFF */
  97. #define LCD_REG_53 0x35 /* Tearing effect mode set & on: TEON */
  98. #define LCD_REG_54 0x36 /* Memory data access control: MADCTL */
  99. #define LCD_REG_56 0x38 /* Idle mode off: IDMOFF */
  100. #define LCD_REG_57 0x39 /* Idle mode on: IDMON */
  101. #define LCD_REG_58 0x3A /* Interface pixel format: COLMOD */
  102. #define LCD_REG_177 0xB1 /* In normal mode (Full colors): FRMCTR1 */
  103. #define LCD_REG_178 0xB2 /* In Idle mode (8-colors): FRMCTR2 */
  104. #define LCD_REG_179 0xB3 /* In partial mode + Full colors: FRMCTR3 */
  105. #define LCD_REG_180 0xB4 /* Display inversion control: INVCTR */
  106. #define LCD_REG_192 0xC0 /* Power control setting: PWCTR1 */
  107. #define LCD_REG_193 0xC1 /* Power control setting: PWCTR2 */
  108. #define LCD_REG_194 0xC2 /* In normal mode (Full colors): PWCTR3 */
  109. #define LCD_REG_195 0xC3 /* In Idle mode (8-colors): PWCTR4 */
  110. #define LCD_REG_196 0xC4 /* In partial mode + Full colors: PWCTR5 */
  111. #define LCD_REG_197 0xC5 /* VCOM control 1: VMCTR1 */
  112. #define LCD_REG_199 0xC7 /* Set VCOM offset control: VMOFCTR */
  113. #define LCD_REG_209 0xD1 /* Set LCM version code: WRID2 */
  114. #define LCD_REG_210 0xD2 /* Customer Project code: WRID3 */
  115. #define LCD_REG_217 0xD9 /* NVM control status: NVCTR1 */
  116. #define LCD_REG_218 0xDA /* Read ID1: RDID1 */
  117. #define LCD_REG_219 0xDB /* Read ID2: RDID2 */
  118. #define LCD_REG_220 0xDC /* Read ID3: RDID3 */
  119. #define LCD_REG_222 0xDE /* NVM Read Command: NVCTR2 */
  120. #define LCD_REG_223 0xDF /* NVM Write Command: NVCTR3 */
  121. #define LCD_REG_224 0xE0 /* Set Gamma adjustment (+ polarity): GAMCTRP1 */
  122. #define LCD_REG_225 0xE1 /* Set Gamma adjustment (- polarity): GAMCTRN1 */
  123. /**
  124. * @brief LCD Lines depending on the chosen fonts.
  125. */
  126. #define LCD_LINE_0 LINE(0)
  127. #define LCD_LINE_1 LINE(1)
  128. #define LCD_LINE_2 LINE(2)
  129. #define LCD_LINE_3 LINE(3)
  130. #define LCD_LINE_4 LINE(4)
  131. #define LCD_LINE_5 LINE(5)
  132. #define LCD_LINE_6 LINE(6)
  133. #define LCD_LINE_7 LINE(7)
  134. #define LCD_LINE_8 LINE(8)
  135. #define LCD_LINE_9 LINE(9)
  136. #define LCD_LINE_10 LINE(10)
  137. #define LCD_LINE_11 LINE(11)
  138. #define LCD_LINE_12 LINE(12)
  139. #define LCD_LINE_13 LINE(13)
  140. #define LCD_LINE_14 LINE(14)
  141. #define LCD_LINE_15 LINE(15)
  142. #define LCD_LINE_16 LINE(16)
  143. #define LCD_LINE_17 LINE(17)
  144. #define LCD_LINE_18 LINE(18)
  145. #define LCD_LINE_19 LINE(19)
  146. /**
  147. * @}
  148. */
  149. /** @defgroup ADAFRUIT_SPI_LCD_Exported_Functions
  150. * @{
  151. */
  152. void st7735_Init(void);
  153. uint16_t st7735_ReadID(void);
  154. void st7735_DisplayOn(void);
  155. void st7735_DisplayOff(void);
  156. void st7735_SetCursor(uint16_t Xpos, uint16_t Ypos);
  157. void st7735_WritePixel(uint16_t Xpos, uint16_t Ypos, uint16_t RGBCode);
  158. void st7735_WriteReg(uint8_t LCDReg, uint8_t LCDRegValue);
  159. uint8_t st7735_ReadReg(uint8_t LCDReg);
  160. void st7735_SetDisplayWindow(uint16_t Xpos, uint16_t Ypos, uint16_t Width, uint16_t Height);
  161. void st7735_DrawHLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
  162. void st7735_DrawVLine(uint16_t RGBCode, uint16_t Xpos, uint16_t Ypos, uint16_t Length);
  163. uint16_t st7735_GetLcdPixelWidth(void);
  164. uint16_t st7735_GetLcdPixelHeight(void);
  165. void st7735_DrawBitmap(uint16_t Xpos, uint16_t Ypos, uint8_t *pbmp);
  166. /* LCD driver structure */
  167. extern LCD_DrvTypeDef st7735_drv;
  168. /* LCD IO functions */
  169. void LCD_IO_Init(void);
  170. void LCD_IO_WriteMultipleData(uint8_t *pData, uint32_t Size);
  171. void LCD_IO_WriteReg(uint8_t Reg);
  172. void LCD_Delay(uint32_t delay);
  173. /**
  174. * @}
  175. */
  176. #ifdef __cplusplus
  177. }
  178. #endif
  179. #endif /* __ST7735_H */
  180. /**
  181. * @}
  182. */
  183. /**
  184. * @}
  185. */
  186. /**
  187. * @}
  188. */
  189. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/