1 #ifdef USE_ESP32_VARIANT_ESP32S3 9 esph_log_config(TAG,
"Setting up ST7701S");
13 esp_lcd_rgb_panel_config_t config{};
14 config.flags.fb_in_psram = 1;
15 #if ESP_IDF_VERSION_MAJOR >= 5 16 config.bounce_buffer_size_px = this->
width_ * 10;
18 #endif // ESP_IDF_VERSION_MAJOR 19 config.timings.h_res = this->
width_;
20 config.timings.v_res = this->
height_;
29 config.clk_src = LCD_CLK_SRC_PLL160M;
30 config.psram_trans_align = 64;
32 for (
size_t i = 0; i != data_pin_count; i++) {
35 config.data_width = data_pin_count;
36 config.disp_gpio_num = -1;
41 esp_err_t err = esp_lcd_new_rgb_panel(&config, &this->
handle_);
42 ESP_ERROR_CHECK(esp_lcd_panel_reset(this->
handle_));
43 ESP_ERROR_CHECK(esp_lcd_panel_init(this->
handle_));
45 esph_log_e(TAG,
"lcd_new_rgb_panel failed: %s", esp_err_to_name(err));
47 esph_log_config(TAG,
"ST7701S setup complete");
51 #if ESP_IDF_VERSION_MAJOR >= 5 53 esp_lcd_rgb_panel_restart(this->
handle_);
54 #endif // ESP_IDF_VERSION_MAJOR 64 return display::Display::draw_pixels_at(x_start, y_start, w, h, ptr, order, bitness, big_endian, x_offset, y_offset,
71 if (x_offset == 0 && x_pad == 0 && y_offset == 0) {
73 err = esp_lcd_panel_draw_bitmap(this->
handle_, x_start, y_start, x_start + w, y_start + h, ptr);
76 auto stride = x_offset + w + x_pad;
77 for (
int y = 0;
y !=
h;
y++) {
78 err = esp_lcd_panel_draw_bitmap(this->
handle_, x_start,
y + y_start, x_start + w,
y + y_start + 1,
79 ptr + ((
y + y_offset) * stride + x_offset) * 2);
85 esph_log_e(TAG,
"lcd_lcd_panel_draw_bitmap failed: %s", esp_err_to_name(err));
117 if (this->
dc_pin_ ==
nullptr) {
118 this->
write(value, 9);
129 if (this->
dc_pin_ ==
nullptr) {
130 this->
write(value | 0x100, 9);
153 ESP_LOGV(TAG,
"Delay %dms", cmd);
158 ESP_LOGV(TAG,
"Command %X, %d bytes", cmd, len);
172 ESP_LOGD(TAG,
"write MADCTL %X", val);
183 ESP_LOGCONFIG(
"",
"ST7701S RGB LCD");
184 ESP_LOGCONFIG(TAG,
" Height: %u", this->
height_);
185 ESP_LOGCONFIG(TAG,
" Width: %u", this->
width_);
186 LOG_PIN(
" CS Pin: ", this->
cs_);
187 LOG_PIN(
" DC Pin: ", this->
dc_pin_);
188 LOG_PIN(
" DE Pin: ", this->
de_pin_);
191 for (
size_t i = 0; i != data_pin_count; i++)
192 ESP_LOGCONFIG(TAG,
" Data pin %d: %s", i, (this->
data_pins_[i])->dump_summary().c_str());
193 ESP_LOGCONFIG(TAG,
" SPI Data rate: %dMHz", (
unsigned) (this->
data_rate_ / 1000000));
198 #endif // USE_ESP32_VARIANT_ESP32S3 virtual void digital_write(bool value)=0
InternalGPIOPin * hsync_pin_
uint16_t hsync_pulse_width_
uint16_t hsync_back_porch_
InternalGPIOPin * pclk_pin_
void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, display::ColorOrder order, display::ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad) override
static uint16_t color_to_565(Color color, ColorOrder color_order=ColorOrder::COLOR_ORDER_RGB)
void write_sequence_(uint8_t cmd, size_t len, const uint8_t *bytes)
this relies upon the init sequence being well-formed, which is guaranteed by the Python init code...
uint16_t vsync_front_porch_
void write_data_(uint8_t value)
InternalGPIOPin * vsync_pin_
void spi_setup() override
InternalGPIOPin * data_pins_[16]
const uint8_t CMD2_BK0[5]
void write_command_(uint8_t value)
uint16_t vsync_back_porch_
Rect get_clipping() const
Get the current the clipping rectangle.
uint16_t vsync_pulse_width_
void write_byte(uint8_t data)
InternalGPIOPin * de_pin_
const uint8_t ST7701S_DELAY_FLAG
void spi_teardown() override
void dump_config() override
virtual uint8_t get_pin() const =0
display::ColorOrder color_mode_
void write(uint16_t data, size_t num_bits)
Write a single data item, up to 32 bits.
constexpr14 T convert_big_endian(T val)
Convert a value between host byte order and big endian (most significant byte first) order...
Application App
Global storage of Application pointer - only one Application can exist.
void swap(optional< T > &x, optional< T > &y)
DisplayRotation rotation_
std::vector< uint8_t > init_sequence_
uint16_t hsync_front_porch_
Implementation of SPI Controller mode.
const uint8_t SW_RESET_CMD
std::vector< uint8_t > bytes
void draw_pixel_at(int x, int y, Color color) override
void write_init_sequence_()
esp_lcd_panel_handle_t handle_
virtual void draw_pixels_at(int x_start, int y_start, int w, int h, const uint8_t *ptr, ColorOrder order, ColorBitness bitness, bool big_endian, int x_offset, int y_offset, int x_pad)
Given an array of pixels encoded in the nominated format, draw these into the display's buffer...
void IRAM_ATTR HOT delay(uint32_t ms)