st7735.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /**
  2. ******************************************************************************
  3. * @file st7735.h
  4. * @author MCD Application Team
  5. * @brief This file contains all the functions prototypes for the st7735.c
  6. * driver.
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2018 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef ST7735_H
  22. #define ST7735_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "st7735_reg.h"
  28. #include <stddef.h>
  29. /** @addtogroup BSP
  30. * @{
  31. */
  32. /** @addtogroup Components
  33. * @{
  34. */
  35. /** @defgroup ST7735 ST7735
  36. * @{
  37. */
  38. /** @defgroup ST7735_Exported_Types Exported Types
  39. * @{
  40. */
  41. typedef int32_t (*ST7735_Init_Func) (void);
  42. typedef int32_t (*ST7735_DeInit_Func) (void);
  43. typedef int32_t (*ST7735_GetTick_Func) (void);
  44. typedef int32_t (*ST7735_Delay_Func) (uint32_t);
  45. typedef int32_t (*ST7735_WriteReg_Func) (uint8_t, uint8_t*, uint32_t);
  46. typedef int32_t (*ST7735_ReadReg_Func) (uint8_t, uint8_t*);
  47. typedef int32_t (*ST7735_SendData_Func) (uint8_t*, uint32_t);
  48. typedef int32_t (*ST7735_RecvData_Func) (uint8_t*, uint32_t);
  49. typedef struct
  50. {
  51. ST7735_Init_Func Init;
  52. ST7735_DeInit_Func DeInit;
  53. uint16_t Address;
  54. ST7735_WriteReg_Func WriteReg;
  55. ST7735_ReadReg_Func ReadReg;
  56. ST7735_SendData_Func SendData;
  57. ST7735_RecvData_Func RecvData;
  58. ST7735_GetTick_Func GetTick;
  59. } ST7735_IO_t;
  60. typedef struct
  61. {
  62. ST7735_IO_t IO;
  63. st7735_ctx_t Ctx;
  64. uint8_t IsInitialized;
  65. } ST7735_Object_t;
  66. typedef struct
  67. {
  68. /* Control functions */
  69. int32_t (*Init )(ST7735_Object_t*, uint32_t, uint32_t);
  70. int32_t (*DeInit )(ST7735_Object_t*);
  71. int32_t (*ReadID )(ST7735_Object_t*, uint32_t*);
  72. int32_t (*DisplayOn )(ST7735_Object_t*);
  73. int32_t (*DisplayOff )(ST7735_Object_t*);
  74. int32_t (*SetBrightness )(ST7735_Object_t*, uint32_t);
  75. int32_t (*GetBrightness )(ST7735_Object_t*, uint32_t*);
  76. int32_t (*SetOrientation )(ST7735_Object_t*, uint32_t);
  77. int32_t (*GetOrientation )(ST7735_Object_t*, uint32_t*);
  78. /* Drawing functions*/
  79. int32_t ( *SetCursor ) (ST7735_Object_t*, uint32_t, uint32_t);
  80. int32_t ( *DrawBitmap ) (ST7735_Object_t*, uint32_t, uint32_t, uint8_t *);
  81. int32_t ( *FillRGBRect ) (ST7735_Object_t*, uint32_t, uint32_t, uint8_t*, uint32_t, uint32_t);
  82. int32_t ( *DrawHLine ) (ST7735_Object_t*, uint32_t, uint32_t, uint32_t, uint32_t);
  83. int32_t ( *DrawVLine ) (ST7735_Object_t*, uint32_t, uint32_t, uint32_t, uint32_t);
  84. int32_t ( *FillRect ) (ST7735_Object_t*, uint32_t, uint32_t, uint32_t, uint32_t, uint32_t);
  85. int32_t ( *GetPixel ) (ST7735_Object_t*, uint32_t, uint32_t, uint32_t*);
  86. int32_t ( *SetPixel ) (ST7735_Object_t*, uint32_t, uint32_t, uint32_t);
  87. int32_t ( *GetXSize ) (ST7735_Object_t*, uint32_t *);
  88. int32_t ( *GetYSize ) (ST7735_Object_t*, uint32_t *);
  89. }ST7735_LCD_Drv_t;
  90. /**
  91. * @}
  92. */
  93. /** @defgroup ST7735_Exported_Constants Exported Constants
  94. * @{
  95. */
  96. /**
  97. * @brief ST7735 Size
  98. */
  99. #define ST7735_OK (0)
  100. #define ST7735_ERROR (-1)
  101. /**
  102. * @brief ST7735 ID
  103. */
  104. #define ST7735_ID 0x5CU
  105. /**
  106. * @brief ST7735 Size
  107. */
  108. #define ST7735_WIDTH 80U
  109. #define ST7735_HEIGHT 160U
  110. /**
  111. * @brief LCD_OrientationTypeDef
  112. * Possible values of Display Orientation
  113. */
  114. #define ST7735_ORIENTATION_PORTRAIT 0x00U /* Portrait orientation choice of LCD screen */
  115. #define ST7735_ORIENTATION_PORTRAIT_ROT180 0x01U /* Portrait rotated 180° orientation choice of LCD screen */
  116. #define ST7735_ORIENTATION_LANDSCAPE 0x02U /* Landscape orientation choice of LCD screen */
  117. #define ST7735_ORIENTATION_LANDSCAPE_ROT180 0x03U /* Landscape rotated 180° orientation choice of LCD screen */
  118. /**
  119. * @brief Possible values of pixel data format (ie color coding)
  120. */
  121. #define ST7735_FORMAT_RBG444 0x03U /* Pixel format chosen is RGB444 : 12 bpp */
  122. #define ST7735_FORMAT_RBG565 0x05U /* Pixel format chosen is RGB565 : 16 bpp */
  123. #define ST7735_FORMAT_RBG666 0x06U /* Pixel format chosen is RGB666 : 18 bpp */
  124. #define ST7735_FORMAT_DEFAULT ST7735_FORMAT_RBG565
  125. /**
  126. * @}
  127. */
  128. /** @defgroup ST7735_Exported_Functions Exported Functions
  129. * @{
  130. */
  131. int32_t ST7735_RegisterBusIO (ST7735_Object_t *pObj, ST7735_IO_t *pIO);
  132. int32_t ST7735_Init(ST7735_Object_t *pObj, uint32_t ColorCoding, uint32_t Orientation);
  133. int32_t ST7735_DeInit(ST7735_Object_t *pObj);
  134. int32_t ST7735_ReadID(ST7735_Object_t *pObj, uint32_t *Id);
  135. int32_t ST7735_DisplayOn(ST7735_Object_t *pObj);
  136. int32_t ST7735_DisplayOff(ST7735_Object_t *pObj);
  137. int32_t ST7735_SetBrightness(ST7735_Object_t *pObj, uint32_t Brightness);
  138. int32_t ST7735_GetBrightness(ST7735_Object_t *pObj, uint32_t *Brightness);
  139. int32_t ST7735_SetOrientation(ST7735_Object_t *pObj, uint32_t Orientation);
  140. int32_t ST7735_GetOrientation(ST7735_Object_t *pObj, uint32_t *Orientation);
  141. int32_t ST7735_SetCursor(ST7735_Object_t *pObj, uint32_t Xpos, uint32_t Ypos);
  142. int32_t ST7735_DrawBitmap(ST7735_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint8_t *pBmp);
  143. int32_t ST7735_FillRGBRect(ST7735_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint8_t *pData, uint32_t Width, uint32_t Height);
  144. int32_t ST7735_DrawHLine(ST7735_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Length, uint32_t Color);
  145. int32_t ST7735_DrawVLine(ST7735_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Length, uint32_t Color);
  146. int32_t ST7735_FillRect(ST7735_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Width, uint32_t Height, uint32_t Color);
  147. int32_t ST7735_SetPixel(ST7735_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t Color);
  148. int32_t ST7735_GetPixel(ST7735_Object_t *pObj, uint32_t Xpos, uint32_t Ypos, uint32_t *Color);
  149. int32_t ST7735_GetXSize(ST7735_Object_t *pObj, uint32_t *XSize);
  150. int32_t ST7735_GetYSize(ST7735_Object_t *pObj, uint32_t *YSize);
  151. extern ST7735_LCD_Drv_t ST7735_LCD_Driver;
  152. /**
  153. * @}
  154. */
  155. #ifdef __cplusplus
  156. }
  157. #endif
  158. #endif /* ST7735_H */
  159. /**
  160. * @}
  161. */
  162. /**
  163. * @}
  164. */
  165. /**
  166. * @}
  167. */
  168. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/