ql_lcd.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. /*================================================================
  2. Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
  3. Quectel Wireless Solutions Proprietary and Confidential.
  4. =================================================================*/
  5. /*=================================================================
  6. EDIT HISTORY FOR MODULE
  7. This section contains comments describing changes made to the module.
  8. Notice that changes are listed in reverse chronological order.
  9. WHEN WHO WHAT, WHERE, WHY
  10. ------------ ------- -------------------------------------------------------------------------------
  11. =================================================================*/
  12. #ifndef QL_LCD_H
  13. #define QL_LCD_H
  14. #ifdef __cplusplus
  15. extern "C" {
  16. #endif
  17. /*===========================================================================
  18. * Macro Definition
  19. ===========================================================================*/
  20. #define QL_LCD_ERRCODE_BASE (QL_COMPONENT_BSP_LCD<<16)
  21. /*===========================================================================
  22. * Enum
  23. ===========================================================================*/
  24. /**
  25. * LCD errcode
  26. */
  27. typedef enum
  28. {
  29. QL_LCD_SUCCESS = QL_SUCCESS,
  30. QL_LCD_EXECUTE_ERR = 1|QL_LCD_ERRCODE_BASE,
  31. QL_LCD_INVALID_PARAM_ERR,
  32. QL_LCD_INIT_ERR,
  33. QL_LCD_BUFFER_CREATE_ERR,
  34. QL_LCD_BLOCK_SET_ERR,
  35. QL_LCD_OPERATION_ERR,
  36. QL_LCD_NOT_INIT_ERR,
  37. QL_LCD_CREATE_MUTEX_ERR,
  38. QL_LCD_MUTEX_TIMEOUT_ERR
  39. }ql_errcode_lcd;
  40. /**
  41. * LCD reset pin level
  42. */
  43. typedef enum
  44. {
  45. QL_LCD_RESET_PIN_LOW_LVL,
  46. QL_LCD_RESET_PIN_HIGH_LVL
  47. }ql_lcd_reset_pin_lvl_s;
  48. /**
  49. * LCD bus mode
  50. */
  51. typedef enum
  52. {
  53. QL_LCD_SPI_LINE_4 = 0,
  54. QL_LCD_SPI_LINE_3 = 1,
  55. QL_LCD_SPI_LINE_3_2_LANE = 3,
  56. QL_LCD_SPI_LINE_MAX
  57. }ql_lcd_busmode_s;
  58. /**
  59. * LCD bwscreen driver select index
  60. * this index is equal to the index of ql_lcd_bwscreen_tab in drv_lcd_cfg.c
  61. */
  62. typedef enum
  63. {
  64. QL_LCD_BW_ST7567A = 0, // don't change name&num
  65. // customer add bwscreen driver from here...
  66. QL_LCD_BW_MAX
  67. }ql_lcd_bwscreen_s;
  68. typedef enum
  69. {
  70. QL_LCD_RGB565 = 2, // don't change name&num
  71. QL_LCD_YUV422_UYVY = 5,
  72. QL_LCD_RESOLUTION_MAX
  73. }ql_lcd_resolution_s;
  74. /**
  75. * LCD backlight pin select
  76. */
  77. typedef enum
  78. {
  79. QL_LCD_BL_SEL_ISINK = 0,
  80. QL_LCD_BL_SEL_MAX
  81. }QL_LCD_BLSEL;
  82. /*===========================================================================
  83. * Struct
  84. ===========================================================================*/
  85. typedef struct
  86. {
  87. uint32_t drv_id;
  88. uint32_t width;
  89. uint32_t height;
  90. ql_lcd_busmode_s bus_mode;
  91. uint32_t freq;
  92. } ql_lcd_info_t;
  93. typedef struct
  94. {
  95. uint8_t index;
  96. } ql_lcd_bw_info_t;
  97. typedef struct
  98. {
  99. uint16_t lcdrotation; //LCD rotation
  100. uint16_t widthoriginal; //width of display
  101. ql_lcd_resolution_s lcdcolorformat; //LCD color format
  102. bool clean_screen; //clean_screen
  103. ql_lcd_busmode_s bus_mode; // driver busmode
  104. uint32_t freq; // driver frequence
  105. } ql_lcd_config_t;
  106. /*===========================================================================
  107. * Functions declaration
  108. ===========================================================================*/
  109. /**
  110. * @brief Extend init the LCD moudle
  111. * @param color : background color
  112. * @param backlight_sw : whether to open backlight in LCD initialize program
  113. if this argument is false,
  114. customers need set ql_lcd_set_brightness.
  115. * @return
  116. * QL_LCD_INIT_ERR
  117. * QL_LCD_BUFFER_CREATE_ERR
  118. * QL_LCD_BLOCK_SET_ERR
  119. * QL_LCD_SUCCESS
  120. */
  121. ql_errcode_lcd ql_lcd_init_ext(uint16_t color, bool backlight_sw);
  122. /**
  123. * @brief Init the LCD moudle
  124. * @return
  125. * QL_LCD_INIT_ERR
  126. * QL_LCD_BUFFER_CREATE_ERR
  127. * QL_LCD_BLOCK_SET_ERR
  128. * QL_LCD_SUCCESS
  129. */
  130. ql_errcode_lcd ql_lcd_init(void);
  131. /**
  132. * @brief Init the LCD(st7567a) moudle
  133. * @return
  134. * QL_LCD_INIT_ERR
  135. * QL_LCD_BUFFER_CREATE_ERR
  136. * QL_LCD_BLOCK_SET_ERR
  137. * QL_LCD_SUCCESS
  138. */
  139. ql_errcode_lcd ql_lcd_init_st7567a(void);
  140. /**
  141. * @brief Init the LCD bwscreen driver
  142. * @param bw_info
  143. * .index : this index is equal to the index of ql_lcd_bwscreen_tab in drv_lcd_cfg.c
  144. * @return
  145. * QL_LCD_INIT_ERR
  146. * QL_LCD_BUFFER_CREATE_ERR
  147. * QL_LCD_BLOCK_SET_ERR
  148. * QL_LCD_SUCCESS
  149. */
  150. ql_errcode_lcd ql_lcd_init_bwscreen(ql_lcd_bw_info_t bw_info);
  151. /**
  152. * @brief Free LCD memory space
  153. * @return
  154. * QL_LCD_SUCCESS
  155. */
  156. ql_errcode_lcd ql_lcd_free(void);
  157. /*** this API apply to color screen driver, ***/
  158. /*** if driver is bwscreen, apply only to ST7567A. ***/
  159. /*** other bwscreen directly use write cmd&data API. ***/
  160. /**
  161. * @brief Clear screen background to a kind of color
  162. * @param color : background color
  163. * @return
  164. * QL_LCD_BLOCK_SET_ERR
  165. * QL_LCD_SUCCESS
  166. */
  167. ql_errcode_lcd ql_lcd_clear_screen(uint16_t color);
  168. /*** this API is apply to LCD's driver what except bwscreen ***/
  169. /*** if driver is bwscreen, directly use write cmd&data API ***/
  170. /*** location param is page and column ***/
  171. /**
  172. * @brief LCD part area set
  173. * @param buffer : write-in data buffer
  174. * @param start_x : horizontal coordinate x start location
  175. * @param start_y : vertical coordinate y start location
  176. * @param end_x : horizontal coordinate x end location
  177. * @param end_x : vertical coordinate y end location
  178. * @return
  179. * QL_LCD_INVALID_PARAM_ERR
  180. * QL_LCD_BLOCK_SET_ERR
  181. * QL_LCD_SUCCESS
  182. */
  183. ql_errcode_lcd ql_lcd_write(uint16_t *buffer, uint16_t start_x, uint16_t start_y, uint16_t end_x, uint16_t end_y);
  184. /**
  185. * @brief LCD display turn on
  186. * @return
  187. * QL_LCD_OPERATION_ERR
  188. * QL_LCD_SUCCESS
  189. */
  190. ql_errcode_lcd ql_lcd_display_on(void);
  191. /**
  192. * @brief LCD display turn off
  193. * @return
  194. * QL_LCD_OPERATION_ERR
  195. * QL_LCD_SUCCESS
  196. */
  197. ql_errcode_lcd ql_lcd_display_off(void);
  198. /**
  199. * @brief LCD SPI CMD send interface
  200. * @param cmd : LCD SPI CMD param
  201. * @return
  202. * QL_LCD_INVALID_PARAM_ERR
  203. * QL_LCD_SUCCESS
  204. */
  205. ql_errcode_lcd ql_spi_lcd_write_cmd(uint8_t cmd);
  206. /**
  207. * @brief LCD SPI DATA send interface
  208. * @param data : LCD SPI DATA param
  209. * @return
  210. * QL_LCD_INVALID_PARAM_ERR
  211. * QL_LCD_SUCCESS
  212. */
  213. ql_errcode_lcd ql_spi_lcd_write_data(uint8_t data);
  214. /**
  215. * @brief LCD backlight brightness pin select function
  216. * @param backlight_pin : select LCD backlight brightness pin
  217. * pin name is: 0: ISINK
  218. * @return
  219. * QL_LCD_INVALID_PARAM_ERR
  220. * QL_LCD_SUCCESS
  221. */
  222. ql_errcode_lcd ql_lcd_brightness_pin_sel(QL_LCD_BLSEL backlight_pin);
  223. /**
  224. * @brief LCD backlight brightness adjust function
  225. * @param level : LCD backlight brightness level
  226. * level is 0 to 5
  227. * @return
  228. * QL_LCD_INVALID_PARAM_ERR
  229. * QL_LCD_SUCCESS
  230. */
  231. ql_errcode_lcd ql_lcd_set_brightness(uint32_t level);
  232. /**
  233. * @brief LCD backlight brightness one channel of each level set function
  234. * @param level : LCD backlight brightness level
  235. * level 0: means close backlight, so can't set
  236. * set backlight brightness, from level 1 to level 5
  237. * @param level_brightness : 1. when pin is ISINK,
  238. * each level steps set, range is 0~63, one step is 0.84mA
  239. * one channel current: mix is 1.68mA, max is 54.6mA
  240. * there is 3 channels
  241. * total current is (1.68 + 0.84 * level_brightness) * 3 (mA)
  242. * @return
  243. * QL_LCD_INVALID_PARAM_ERR
  244. * QL_LCD_SUCCESS
  245. */
  246. ql_errcode_lcd ql_lcd_set_level_brightness(uint32_t level, uint8_t level_brightness);
  247. /**
  248. * @brief LCD enter and exit sleep function
  249. * if the lcd has been initialized, the function must be called before enter sleep
  250. * @param is_sleep : true --lcd enter sleep
  251. * false--lcd exit sleep
  252. * @return
  253. * QL_LCD_OPERATION_ERR
  254. * QL_LCD_SUCCESS
  255. */
  256. ql_errcode_lcd ql_lcd_enter_sleep(bool is_sleep);
  257. /**
  258. * @brief LCD display area set
  259. * @param start_x_offset : start pixel's x_offset (distance from (0,0) in x)
  260. * @param start_y_offset : start pixel's y_offset (distance from (0,0) in y)
  261. * @param width_offset : width's x_offset (the diff between the supported width in driver and the width user want)
  262. * @param height_offset : height's y_offset (the diff between the supported height in driver and the height user want)
  263. * when less than the supported width/height, offset is positive value;
  264. * when greater than the supported width/height, offset is negative value.
  265. * @return
  266. * QL_LCD_EXECUTE_ERR
  267. * QL_LCD_BUFFER_CREATE_ERR
  268. * QL_LCD_SUCCESS
  269. * @notice!!!
  270. * The next configuration clears the last configured offset.
  271. */
  272. ql_errcode_lcd ql_lcd_set_display_offset(uint16_t start_x_offset, uint16_t start_y_offset, int16_t width_offset, int16_t height_offset);
  273. /**
  274. * @brief LCD busmode set function
  275. * be used before LCD init!!!
  276. * @param bus_mode : Line4/Line3/Line3_2lane
  277. * @return
  278. * QL_LCD_BUFFER_CREATE_ERR
  279. * QL_LCD_SUCCESS
  280. */
  281. ql_errcode_lcd ql_lcd_set_busmode(ql_lcd_busmode_s bus_mode);
  282. /**
  283. * @brief LCD screen cancel reset control
  284. LCD initialization will reset LCD by default.
  285. This function can configure whether to skip reset during initialization.
  286. * @param lcd_reset : true -- lcd reset
  287. false -- lcd does not reset
  288. * @return
  289. * QL_LCD_INVALID_PARAM_ERR
  290. * QL_LCD_SUCCESS
  291. *
  292. * @attention
  293. * This Function need to be used before LCD init
  294. */
  295. ql_errcode_lcd ql_lcd_reset_config(bool lcd_reset);
  296. /**
  297. * @brief get LCD driver info
  298. * this API is used after initialization!!!
  299. * @param *info : driver info
  300. * @return
  301. * QL_LCD_EXECUTE_ERR
  302. * QL_LCD_SUCCESS
  303. */
  304. ql_errcode_lcd ql_lcd_get_info(ql_lcd_info_t *info);
  305. /**
  306. * @brief Customer set LCD configure value
  307. * rotation/colorformat/widthoriginal/clean_screen/drv bus_mode/drv freq
  308. * @param *config :
  309. * rotation -- 0:not rotating 1:rotate 90
  310. * widthoriginal -- Width of landscape screen
  311. * colorformat -- QL_LCD_YUV422_UYVY QL_LCD_RGB565
  312. * clean_screen -- false: clean screen true: keep screen
  313. * bus_mode -- Line4/Line3/Line3_2lane
  314. * freq -- 0 means use default driver frequence
  315. * @return
  316. * QL_LCD_SUCCESS
  317. */
  318. ql_errcode_lcd ql_lcd_set_config(ql_lcd_config_t *config);
  319. /**
  320. * @brief Customer get LCD configure value
  321. * rotation/colorformat/widthoriginal/clean_screen/drv bus_mode/drv freq
  322. * Notice: the getted value is Customer set value by ql_lcd_set_config!!!
  323. if not set config, the value is default value!!!
  324. * @param *config :
  325. * rotation -- default:0
  326. * widthoriginal -- default:0
  327. * colorformat -- default:QL_LCD_RGB565
  328. * clean_screen -- default:false
  329. * bus_mode -- default:QL_LCD_SPI_LINE_4
  330. * freq -- default:0 (0 means use default driver frequence)
  331. * @return
  332. * QL_LCD_SUCCESS
  333. */
  334. ql_errcode_lcd ql_lcd_get_config(ql_lcd_config_t *config);
  335. /**
  336. * @brief Customer set lcd reset pin level
  337. * Notice: This api should be called after initialization
  338. * @param pin_lvl : pin level
  339. * @return
  340. * QL_LCD_SUCCESS
  341. */
  342. ql_errcode_lcd ql_lcd_set_reset_pin(ql_lcd_reset_pin_lvl_s pin_lvl);
  343. #ifdef __cplusplus
  344. } /*"C" */
  345. #endif
  346. #endif /* QL_LCD_H */