esp_lcd_panel_interface.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdbool.h>
  8. #include "esp_err.h"
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. typedef struct esp_lcd_panel_t esp_lcd_panel_t; /*!< Type of LCD panel */
  13. /**
  14. * @brief LCD panel interface
  15. */
  16. struct esp_lcd_panel_t {
  17. /**
  18. * @brief Reset LCD panel
  19. *
  20. * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
  21. * @return
  22. * - ESP_OK on success
  23. */
  24. esp_err_t (*reset)(esp_lcd_panel_t *panel);
  25. /**
  26. * @brief Initialize LCD panel
  27. *
  28. * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
  29. * @return
  30. * - ESP_OK on success
  31. */
  32. esp_err_t (*init)(esp_lcd_panel_t *panel);
  33. /**
  34. * @brief Destory LCD panel
  35. *
  36. * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
  37. * @return
  38. * - ESP_OK on success
  39. */
  40. esp_err_t (*del)(esp_lcd_panel_t *panel);
  41. /**
  42. * @brief Draw bitmap on LCD panel
  43. *
  44. * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
  45. * @param[in] x_start Start index on x-axis (x_start included)
  46. * @param[in] y_start Start index on y-axis (y_start included)
  47. * @param[in] x_end End index on x-axis (x_end not included)
  48. * @param[in] y_end End index on y-axis (y_end not included)
  49. * @param[in] color_data RGB color data that will be dumped to the specific window range
  50. * @return
  51. * - ESP_OK on success
  52. */
  53. esp_err_t (*draw_bitmap)(esp_lcd_panel_t *panel, int x_start, int y_start, int x_end, int y_end, const void *color_data);
  54. /**
  55. * @brief Mirror the LCD panel on specific axis
  56. *
  57. * @note Combine this function with `swap_xy`, one can realize screen rotatation
  58. *
  59. * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
  60. * @param[in] x_axis Whether the panel will be mirrored about the x_axis
  61. * @param[in] y_axis Whether the panel will be mirrored about the y_axis
  62. * @return
  63. * - ESP_OK on success
  64. * - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
  65. */
  66. esp_err_t (*mirror)(esp_lcd_panel_t *panel, bool x_axis, bool y_axis);
  67. /**
  68. * @brief Swap/Exchange x and y axis
  69. *
  70. * @note Combine this function with `mirror`, one can realize screen rotatation
  71. *
  72. * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
  73. * @param[in] swap_axes Whether to swap the x and y axis
  74. * @return
  75. * - ESP_OK on success
  76. * - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
  77. */
  78. esp_err_t (*swap_xy)(esp_lcd_panel_t *panel, bool swap_axes);
  79. /**
  80. * @brief Set extra gap in x and y axis
  81. *
  82. * @note The gap is only used for calculating the real coordinates.
  83. *
  84. * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
  85. * @param[in] x_gap Extra gap on x axis, in pixels
  86. * @param[in] y_gap Extra gap on y axis, in pixels
  87. * @return
  88. * - ESP_OK on success
  89. */
  90. esp_err_t (*set_gap)(esp_lcd_panel_t *panel, int x_gap, int y_gap);
  91. /**
  92. * @brief Invert the color (bit 1 -> 0 for color data line, and vice versa)
  93. *
  94. * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
  95. * @param[in] invert_color_data Whether to invert the color data
  96. * @return
  97. * - ESP_OK on success
  98. */
  99. esp_err_t (*invert_color)(esp_lcd_panel_t *panel, bool invert_color_data);
  100. /**
  101. * @brief Turn on or off the display
  102. *
  103. * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
  104. * @param[in] on_off True to turns on display, False to turns off display
  105. * @return
  106. * - ESP_OK on success
  107. * - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
  108. */
  109. esp_err_t (*disp_on_off)(esp_lcd_panel_t *panel, bool on_off);
  110. };
  111. #ifdef __cplusplus
  112. }
  113. #endif