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