ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
rpi_dpi_rgb.h
Go to the documentation of this file.
1//
2// Created by Clyde Stubbs on 29/10/2023.
3//
4#pragma once
5
6// only applicable on ESP32-S3
7#ifdef USE_ESP32_VARIANT_ESP32S3
9#include "esphome/core/gpio.h"
10#include "esphome/core/log.h"
13#include "esp_lcd_panel_ops.h"
14
15#include "esp_lcd_panel_rgb.h"
16
17namespace esphome::rpi_dpi_rgb {
18
19ESPHOME_LOG_TAG(TAG, "rpi_dpi_rgb");
20
21class RpiDpiRgb final : public display::Display {
22 public:
23 void update() override { this->do_update_(); }
24 void setup() override;
25 void loop() override;
26 float get_setup_priority() const override { return setup_priority::HARDWARE; }
27 void draw_pixel_at(int x, int y, Color color) override;
28
30 void set_color_mode(display::ColorOrder color_mode) { this->color_mode_ = color_mode; }
31 void set_invert_colors(bool invert_colors) { this->invert_colors_ = invert_colors; }
32
33 void add_data_pin(InternalGPIOPin *data_pin, size_t index) { this->data_pins_[index] = data_pin; };
34 void set_de_pin(InternalGPIOPin *de_pin) { this->de_pin_ = de_pin; }
35 void set_pclk_pin(InternalGPIOPin *pclk_pin) { this->pclk_pin_ = pclk_pin; }
36 void set_vsync_pin(InternalGPIOPin *vsync_pin) { this->vsync_pin_ = vsync_pin; }
37 void set_hsync_pin(InternalGPIOPin *hsync_pin) { this->hsync_pin_ = hsync_pin; }
38 void set_enable_pin(GPIOPin *enable_pin) { this->enable_pin_ = enable_pin; }
39 void set_reset_pin(GPIOPin *reset_pin) { this->reset_pin_ = reset_pin; }
40 void set_width(uint16_t width) { this->width_ = width; }
41 void set_dimensions(uint16_t width, uint16_t height) {
42 this->width_ = width;
43 this->height_ = height;
44 }
45 int get_width() override;
46 int get_height() override;
47 void set_hsync_back_porch(uint16_t hsync_back_porch) { this->hsync_back_porch_ = hsync_back_porch; }
48 void set_hsync_front_porch(uint16_t hsync_front_porch) { this->hsync_front_porch_ = hsync_front_porch; }
49 void set_hsync_pulse_width(uint16_t hsync_pulse_width) { this->hsync_pulse_width_ = hsync_pulse_width; }
50 void set_vsync_pulse_width(uint16_t vsync_pulse_width) { this->vsync_pulse_width_ = vsync_pulse_width; }
51 void set_vsync_back_porch(uint16_t vsync_back_porch) { this->vsync_back_porch_ = vsync_back_porch; }
52 void set_vsync_front_porch(uint16_t vsync_front_porch) { this->vsync_front_porch_ = vsync_front_porch; }
53 void set_pclk_frequency(uint32_t pclk_frequency) { this->pclk_frequency_ = pclk_frequency; }
54 void set_pclk_inverted(bool inverted) { this->pclk_inverted_ = inverted; }
55 void set_offsets(int16_t offset_x, int16_t offset_y) {
56 this->offset_x_ = offset_x;
57 this->offset_y_ = offset_y;
58 }
60 void dump_config() override;
61
62 protected:
63 void draw_pixels_internal(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorBitness bitness,
64 bool big_endian, int x_offset, int y_offset, int x_pad) override;
65
66 void write_to_display_(int x_start, int y_start, int w, int h, const uint8_t *ptr, int x_offset, int y_offset,
67 int x_pad);
68 int get_width_internal() override { return this->width_; }
69 int get_height_internal() override { return this->height_; }
70 void reset_display_() const;
78 uint16_t hsync_front_porch_ = 8;
79 uint16_t hsync_pulse_width_ = 4;
80 uint16_t hsync_back_porch_ = 8;
81 uint16_t vsync_front_porch_ = 8;
82 uint16_t vsync_pulse_width_ = 4;
83 uint16_t vsync_back_porch_ = 8;
84 uint32_t pclk_frequency_ = 16 * 1000 * 1000;
85 bool pclk_inverted_{true};
86
89 size_t width_{};
90 size_t height_{};
91 int16_t offset_x_{0};
92 int16_t offset_y_{0};
93
94 esp_lcd_panel_handle_t handle_{};
95};
96
97} // namespace esphome::rpi_dpi_rgb
98#endif // USE_ESP32_VARIANT_ESP32S3
int int int const uint8_t ColorOrder ColorBitness bitness
Definition display.h:392
int int int const uint8_t ColorOrder ColorBitness bool int int y_offset
Definition display.h:392
int int int const uint8_t ColorOrder ColorBitness bool int int int x_pad
Definition display.h:392
int int int const uint8_t * ptr
Definition display.h:391
int int int const uint8_t ColorOrder ColorBitness bool big_endian
Definition display.h:392
int int int const uint8_t ColorOrder ColorBitness bool int x_offset
Definition display.h:392
void set_vsync_front_porch(uint16_t vsync_front_porch)
Definition rpi_dpi_rgb.h:52
display::DisplayType get_display_type() override
Definition rpi_dpi_rgb.h:59
void set_hsync_pin(InternalGPIOPin *hsync_pin)
Definition rpi_dpi_rgb.h:37
display::ColorOrder get_color_mode()
Definition rpi_dpi_rgb.h:29
void set_dimensions(uint16_t width, uint16_t height)
Definition rpi_dpi_rgb.h:41
void set_hsync_back_porch(uint16_t hsync_back_porch)
Definition rpi_dpi_rgb.h:47
void set_pclk_pin(InternalGPIOPin *pclk_pin)
Definition rpi_dpi_rgb.h:35
InternalGPIOPin * data_pins_[16]
Definition rpi_dpi_rgb.h:77
void set_vsync_pulse_width(uint16_t vsync_pulse_width)
Definition rpi_dpi_rgb.h:50
void set_invert_colors(bool invert_colors)
Definition rpi_dpi_rgb.h:31
void set_de_pin(InternalGPIOPin *de_pin)
Definition rpi_dpi_rgb.h:34
void set_width(uint16_t width)
Definition rpi_dpi_rgb.h:40
void set_pclk_inverted(bool inverted)
Definition rpi_dpi_rgb.h:54
display::ColorOrder color_mode_
Definition rpi_dpi_rgb.h:88
float get_setup_priority() const override
Definition rpi_dpi_rgb.h:26
void set_hsync_pulse_width(uint16_t hsync_pulse_width)
Definition rpi_dpi_rgb.h:49
void set_reset_pin(GPIOPin *reset_pin)
Definition rpi_dpi_rgb.h:39
void write_to_display_(int x_start, int y_start, int w, int h, const uint8_t *ptr, int x_offset, int y_offset, int x_pad)
void set_vsync_pin(InternalGPIOPin *vsync_pin)
Definition rpi_dpi_rgb.h:36
void add_data_pin(InternalGPIOPin *data_pin, size_t index)
Definition rpi_dpi_rgb.h:33
esp_lcd_panel_handle_t handle_
Definition rpi_dpi_rgb.h:94
void set_enable_pin(GPIOPin *enable_pin)
Definition rpi_dpi_rgb.h:38
void set_offsets(int16_t offset_x, int16_t offset_y)
Definition rpi_dpi_rgb.h:55
void set_hsync_front_porch(uint16_t hsync_front_porch)
Definition rpi_dpi_rgb.h:48
void set_vsync_back_porch(uint16_t vsync_back_porch)
Definition rpi_dpi_rgb.h:51
void draw_pixels_internal(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override
void draw_pixel_at(int x, int y, Color color) override
void set_color_mode(display::ColorOrder color_mode)
Definition rpi_dpi_rgb.h:30
void set_pclk_frequency(uint32_t pclk_frequency)
Definition rpi_dpi_rgb.h:53
ESPHOME_LOG_TAG(TAG, "rpi_dpi_rgb")
constexpr float HARDWARE
For components that deal with hardware and are very important like GPIO switch.
Definition component.h:43
static void uint32_t
uint16_t x
Definition tt21100.cpp:5
uint16_t y
Definition tt21100.cpp:6