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 #include "esp_lcd_types.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 /**
17  * @brief Reset LCD panel
18  *
19  * @note Panel reset must be called before attempting to initialize the panel using `esp_lcd_panel_init()`.
20  *
21  * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
22  * @return
23  *          - ESP_OK on success
24  */
25 esp_err_t esp_lcd_panel_reset(esp_lcd_panel_handle_t panel);
26 
27 /**
28  * @brief Initialize LCD panel
29  *
30  * @note Before calling this function, make sure the LCD panel has finished the `reset` stage by `esp_lcd_panel_reset()`.
31  *
32  * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
33  * @return
34  *          - ESP_OK on success
35  */
36 esp_err_t esp_lcd_panel_init(esp_lcd_panel_handle_t panel);
37 
38 /**
39  * @brief Deinitialize the LCD panel
40  *
41  * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
42  * @return
43  *          - ESP_OK on success
44  */
45 esp_err_t esp_lcd_panel_del(esp_lcd_panel_handle_t panel);
46 
47 /**
48  * @brief Draw bitmap on LCD panel
49  *
50  * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
51  * @param[in] x_start Start index on x-axis (x_start included)
52  * @param[in] y_start Start index on y-axis (y_start included)
53  * @param[in] x_end End index on x-axis (x_end not included)
54  * @param[in] y_end End index on y-axis (y_end not included)
55  * @param[in] color_data RGB color data that will be dumped to the specific window range
56  * @return
57  *          - ESP_OK on success
58  */
59 esp_err_t esp_lcd_panel_draw_bitmap(esp_lcd_panel_handle_t panel, int x_start, int y_start, int x_end, int y_end, const void *color_data);
60 
61 /**
62  * @brief Mirror the LCD panel on specific axis
63  *
64  * @note Combined with `esp_lcd_panel_swap_xy()`, one can realize screen rotation
65  *
66  * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
67  * @param[in] mirror_x Whether the panel will be mirrored about the x axis
68  * @param[in] mirror_y Whether the panel will be mirrored about the y axis
69  * @return
70  *          - ESP_OK on success
71  *          - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
72  */
73 esp_err_t esp_lcd_panel_mirror(esp_lcd_panel_handle_t panel, bool mirror_x, bool mirror_y);
74 
75 /**
76  * @brief Swap/Exchange x and y axis
77  *
78  * @note Combined with `esp_lcd_panel_mirror()`, one can realize screen rotation
79  *
80  * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
81  * @param[in] swap_axes Whether to swap the x and y axis
82  * @return
83  *          - ESP_OK on success
84  *          - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
85  */
86 esp_err_t esp_lcd_panel_swap_xy(esp_lcd_panel_handle_t panel, bool swap_axes);
87 
88 /**
89  * @brief Set extra gap in x and y axis
90  *
91  * The gap is the space (in pixels) between the left/top sides of the LCD panel and the first row/column respectively of the actual contents displayed.
92  *
93  * @note Setting a gap is useful when positioning or centering a frame that is smaller than the LCD.
94  *
95  * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
96  * @param[in] x_gap Extra gap on x axis, in pixels
97  * @param[in] y_gap Extra gap on y axis, in pixels
98  * @return
99  *          - ESP_OK on success
100  */
101 esp_err_t esp_lcd_panel_set_gap(esp_lcd_panel_handle_t panel, int x_gap, int y_gap);
102 
103 /**
104  * @brief Invert the color (bit-wise invert the color data line)
105  *
106  * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
107  * @param[in] invert_color_data Whether to invert the color data
108  * @return
109  *          - ESP_OK on success
110  */
111 esp_err_t esp_lcd_panel_invert_color(esp_lcd_panel_handle_t panel, bool invert_color_data);
112 
113 /**
114  * @brief Turn off the display
115  *
116  * @param[in] panel LCD panel handle, which is created by other factory API like `esp_lcd_new_panel_st7789()`
117  * @param[in] off Whether to turn off the screen
118  * @return
119  *          - ESP_OK on success
120  *          - ESP_ERR_NOT_SUPPORTED if this function is not supported by the panel
121  */
122 esp_err_t esp_lcd_panel_disp_off(esp_lcd_panel_handle_t panel, bool off);
123 
124 #ifdef __cplusplus
125 }
126 #endif
127