roo_display
API Documentation for roo_display
Loading...
Searching...
No Matches
rgb_panel.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6#pragma once
7
8#ifdef ESP32
9
10#ifdef __cplusplus
11extern "C" {
12#endif
13
14#include <stdbool.h>
15#include "esp_err.h"
16#include "soc/soc_caps.h"
17#include "hal/lcd_types.h"
18
19#if SOC_LCD_RGB_SUPPORTED
20
21#include "esp_lcd_types.h"
22#include "esp_lcd_panel_ops.h"
23
24/**
25 * @brief LCD RGB timing structure
26 * @verbatim
27 * Total Width
28 * <--------------------------------------------------->
29 * HSYNC width HBP Active Width HFP
30 * <---><--><--------------------------------------><--->
31 * ____ ____|_______________________________________|____|
32 * |___| | | |
33 * | | |
34 * __| | | |
35 * /|\ /|\ | | | |
36 * | VSYNC| | | | |
37 * |Width\|/ |__ | | |
38 * | /|\ | | | |
39 * | VBP | | | | |
40 * | \|/_____|_________|_______________________________________| |
41 * | /|\ | | / / / / / / / / / / / / / / / / / / / | |
42 * | | | |/ / / / / / / / / / / / / / / / / / / /| |
43 * Total | | | |/ / / / / / / / / / / / / / / / / / / /| |
44 * Height | | | |/ / / / / / / / / / / / / / / / / / / /| |
45 * |Active| | |/ / / / / / / / / / / / / / / / / / / /| |
46 * |Heigh | | |/ / / / / / Active Display Area / / / /| |
47 * | | | |/ / / / / / / / / / / / / / / / / / / /| |
48 * | | | |/ / / / / / / / / / / / / / / / / / / /| |
49 * | | | |/ / / / / / / / / / / / / / / / / / / /| |
50 * | | | |/ / / / / / / / / / / / / / / / / / / /| |
51 * | | | |/ / / / / / / / / / / / / / / / / / / /| |
52 * | \|/_____|_________|_______________________________________| |
53 * | /|\ | |
54 * | VFP | | |
55 * \|/ \|/_____|______________________________________________________|
56 * @endverbatim
57 */
58typedef struct {
59 unsigned int pclk_hz; /*!< Frequency of pixel clock */
60 unsigned int h_res; /*!< Horizontal resolution, i.e. the number of pixels in a line */
61 unsigned int v_res; /*!< Vertical resolution, i.e. the number of lines in the frame */
62 unsigned int hsync_pulse_width; /*!< Horizontal sync width, unit: PCLK period */
63 unsigned int hsync_back_porch; /*!< Horizontal back porch, number of PCLK between hsync and start of line active data */
64 unsigned int hsync_front_porch; /*!< Horizontal front porch, number of PCLK between the end of active data and the next hsync */
65 unsigned int vsync_pulse_width; /*!< Vertical sync width, unit: number of lines */
66 unsigned int vsync_back_porch; /*!< Vertical back porch, number of invalid lines between vsync and start of frame */
67 unsigned int vsync_front_porch; /*!< Vertical front porch, number of invalid lines between the end of frame and the next vsync */
68 struct {
69 unsigned int hsync_idle_low: 1; /*!< The hsync signal is low in IDLE state */
70 unsigned int vsync_idle_low: 1; /*!< The vsync signal is low in IDLE state */
71 unsigned int de_idle_high: 1; /*!< The de signal is high in IDLE state */
72 unsigned int pclk_active_neg: 1; /*!< Whether the display data is clocked out at the falling edge of PCLK */
73 unsigned int pclk_idle_high: 1; /*!< The PCLK stays at high level in IDLE phase */
74 } flags; /*!< LCD RGB timing flags */
75} esp_lcd_rgb_timing_t;
76
77/**
78 * @brief Type of RGB LCD panel event data
79 */
80typedef struct {
81} esp_lcd_rgb_panel_event_data_t;
82
83/**
84 * @brief Declare the prototype of the function that will be invoked when panel IO finishes transferring color data
85 *
86 * @param[in] panel LCD panel handle, returned from `esp_lcd_new_rgb_panel`
87 * @param[in] edata Panel event data, fed by driver
88 * @param[in] user_ctx User data, passed from `esp_lcd_rgb_panel_config_t`
89 * @return Whether a high priority task has been waken up by this function
90 */
91typedef bool (*esp_lcd_rgb_panel_frame_trans_done_cb_t)(esp_lcd_panel_handle_t panel, esp_lcd_rgb_panel_event_data_t *edata, void *user_ctx);
92
93/**
94 * @brief LCD RGB panel configuration structure
95 */
96typedef struct {
97 lcd_clock_source_t clk_src; /*!< Clock source for the RGB LCD peripheral */
98 esp_lcd_rgb_timing_t timings; /*!< RGB timing parameters */
99 size_t data_width; /*!< Number of data lines */
100 size_t sram_trans_align; /*!< Alignment for framebuffer that allocated in SRAM */
101 size_t psram_trans_align; /*!< Alignment for framebuffer that allocated in PSRAM */
102 int hsync_gpio_num; /*!< GPIO used for HSYNC signal */
103 int vsync_gpio_num; /*!< GPIO used for VSYNC signal */
104 int de_gpio_num; /*!< GPIO used for DE signal, set to -1 if it's not used */
105 int pclk_gpio_num; /*!< GPIO used for PCLK signal */
106 int data_gpio_nums[SOC_LCD_RGB_DATA_WIDTH]; /*!< GPIOs used for data lines */
107 int disp_gpio_num; /*!< GPIO used for display control signal, set to -1 if it's not used */
108 esp_lcd_rgb_panel_frame_trans_done_cb_t on_frame_trans_done; /*!< Callback invoked when one frame buffer has transferred done */
109 void *user_ctx; /*!< User data which would be passed to on_frame_trans_done's user_ctx */
110 struct {
111 unsigned int disp_active_low: 1; /*!< If this flag is enabled, a low level of display control signal can turn the screen on; vice versa */
112 unsigned int relax_on_idle: 1; /*!< If this flag is enabled, the host won't refresh the LCD if nothing changed in host's frame buffer (this is usefull for LCD with built-in GRAM) */
113 unsigned int fb_in_psram: 1; /*!< If this flag is enabled, the frame buffer will be allocated from PSRAM preferentially */
114 } flags; /*!< LCD RGB panel configuration flags */
115} esp_lcd_rgb_panel_config_t;
116
117/**
118 * @brief Create RGB LCD panel
119 *
120 * @param rgb_panel_config RGB panel configuration
121 * @param ret_panel Returned LCD panel handle
122 * @return
123 * - ESP_ERR_INVALID_ARG if parameter is invalid
124 * - ESP_ERR_NO_MEM if out of memory
125 * - ESP_ERR_NOT_FOUND if no free RGB panel is available
126 * - ESP_OK on success
127 */
128esp_err_t esp_lcd_new_rgb_panel(const esp_lcd_rgb_panel_config_t *rgb_panel_config, esp_lcd_panel_handle_t *ret_panel);
129
130esp_err_t esp_lcd_rgb_panel_get_frame_buffer(esp_lcd_panel_handle_t panel, uint32_t fb_num, void **fb0, ...);
131
132#endif // SOC_LCD_RGB_SUPPORTED
133
134#ifdef __cplusplus
135}
136#endif
137
138#endif