lv_hal_disp.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /**
  2. * @file hal_disp.h
  3. *
  4. * @description Display Driver HAL interface header file
  5. *
  6. */
  7. #ifndef HAL_DISP_H
  8. #define HAL_DISP_H
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. /*********************
  13. * INCLUDES
  14. *********************/
  15. #include <stdint.h>
  16. #include <stdbool.h>
  17. #include "lv_hal.h"
  18. #include "../lv_misc/lv_color.h"
  19. /*********************
  20. * DEFINES
  21. *********************/
  22. /**********************
  23. * TYPEDEFS
  24. **********************/
  25. /**
  26. * Display Driver structure to be registered by HAL
  27. */
  28. typedef struct _disp_drv_t {
  29. /*Write the internal buffer (VDB) to the display. 'lv_flush_ready()' has to be called when finished*/
  30. void (*disp_flush)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);
  31. /*Fill an area with a color on the display*/
  32. void (*disp_fill)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);
  33. /*Write pixel map (e.g. image) to the display*/
  34. void (*disp_map)(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_p);
  35. #if USE_LV_GPU
  36. /*Blend two memories using opacity (GPU only)*/
  37. void (*mem_blend)(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
  38. /*Fill a memory with a color (GPU only)*/
  39. void (*mem_fill)(lv_color_t * dest, uint32_t length, lv_color_t color);
  40. #endif
  41. } lv_disp_drv_t;
  42. typedef struct _disp_t {
  43. lv_disp_drv_t driver;
  44. struct _disp_t *next;
  45. } lv_disp_t;
  46. /**********************
  47. * GLOBAL PROTOTYPES
  48. **********************/
  49. /**
  50. * Initialize a display driver with default values.
  51. * It is used to surly have known values in the fields ant not memory junk.
  52. * After it you can set the fields.
  53. * @param driver pointer to driver variable to initialize
  54. */
  55. void lv_disp_drv_init(lv_disp_drv_t *driver);
  56. /**
  57. * Register an initialized display driver.
  58. * Automatically set the first display as active.
  59. * @param driver pointer to an initialized 'lv_disp_drv_t' variable (can be local variable)
  60. * @return pointer to the new display or NULL on error
  61. */
  62. lv_disp_t * lv_disp_drv_register(lv_disp_drv_t *driver);
  63. /**
  64. * Set the active display
  65. * @param disp pointer to a display (return value of 'lv_disp_register')
  66. */
  67. void lv_disp_set_active(lv_disp_t * disp);
  68. /**
  69. * Get a pointer to the active display
  70. * @return pointer to the active display
  71. */
  72. lv_disp_t * lv_disp_get_active(void);
  73. /**
  74. * Get the next display.
  75. * @param disp pointer to the current display. NULL to initialize.
  76. * @return the next display or NULL if no more. Give the first display when the parameter is NULL
  77. */
  78. lv_disp_t * lv_disp_next(lv_disp_t * disp);
  79. /**
  80. * Fill a rectangular area with a color on the active display
  81. * @param x1 left coordinate of the rectangle
  82. * @param x2 right coordinate of the rectangle
  83. * @param y1 top coordinate of the rectangle
  84. * @param y2 bottom coordinate of the rectangle
  85. * @param color_p pointer to an array of colors
  86. */
  87. void lv_disp_flush(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t *color_p);
  88. /**
  89. * Fill a rectangular area with a color on the active display
  90. * @param x1 left coordinate of the rectangle
  91. * @param x2 right coordinate of the rectangle
  92. * @param y1 top coordinate of the rectangle
  93. * @param y2 bottom coordinate of the rectangle
  94. * @param color fill color
  95. */
  96. void lv_disp_fill(int32_t x1, int32_t y1, int32_t x2, int32_t y2, lv_color_t color);
  97. /**
  98. * Put a color map to a rectangular area on the active display
  99. * @param x1 left coordinate of the rectangle
  100. * @param x2 right coordinate of the rectangle
  101. * @param y1 top coordinate of the rectangle
  102. * @param y2 bottom coordinate of the rectangle
  103. * @param color_map pointer to an array of colors
  104. */
  105. void lv_disp_map(int32_t x1, int32_t y1, int32_t x2, int32_t y2, const lv_color_t * color_map);
  106. #if USE_LV_GPU
  107. /**
  108. * Blend pixels to a destination memory from a source memory
  109. * In 'lv_disp_drv_t' 'mem_blend' is optional. (NULL if not available)
  110. * @param dest a memory address. Blend 'src' here.
  111. * @param src pointer to pixel map. Blend it to 'dest'.
  112. * @param length number of pixels in 'src'
  113. * @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
  114. */
  115. void lv_disp_mem_blend(lv_color_t * dest, const lv_color_t * src, uint32_t length, lv_opa_t opa);
  116. /**
  117. * Fill a memory with a color (GPUs may support it)
  118. * In 'lv_disp_drv_t' 'mem_fill' is optional. (NULL if not available)
  119. * @param dest a memory address. Copy 'src' here.
  120. * @param src pointer to pixel map. Copy it to 'dest'.
  121. * @param length number of pixels in 'src'
  122. * @param opa opacity (0, LV_OPA_TRANSP: transparent ... 255, LV_OPA_COVER, fully cover)
  123. */
  124. void lv_disp_mem_fill(lv_color_t * dest, uint32_t length, lv_color_t color);
  125. /**
  126. * Shows if memory blending (by GPU) is supported or not
  127. * @return false: 'mem_blend' is not supported in the driver; true: 'mem_blend' is supported in the driver
  128. */
  129. bool lv_disp_is_mem_blend_supported(void);
  130. /**
  131. * Shows if memory fill (by GPU) is supported or not
  132. * @return false: 'mem_fill' is not supported in the drover; true: 'mem_fill' is supported in the driver
  133. */
  134. bool lv_disp_is_mem_fill_supported(void);
  135. #endif
  136. /**********************
  137. * MACROS
  138. **********************/
  139. #ifdef __cplusplus
  140. } /* extern "C" */
  141. #endif
  142. #endif