feat(rlcd): Waveshare ESP32-S3-RLCD-4.2 support on latest main
- ST7305 driver with persistent 15KB DMA buffer (fix use-after-free +
WDT lockup that caused freeze after flash)
- Reset timing fix: 150ms after reset, 50ms after init
- DTS: i2s0 mclk 16, bclk 9, ws 45, out 8, in 10 - fixes GPIO5 conflict
- i2c0 uses esp32-i2c-master, SDMMC 1-bit
- device.properties: colorDepth 16, fontSize 20, DefaultDark
- Amp GPIO46 init in initBoot
- Buttons: two-button control GPIO18 (cycle) + GPIO0 (select)
Base: origin/main f9453d89
This commit is contained in:
@@ -0,0 +1,108 @@
|
||||
#include "St7305Display.h"
|
||||
#include "esp_lcd_st7305.h"
|
||||
|
||||
#include <tactility/log.h>
|
||||
#include <esp_lcd_panel_ops.h>
|
||||
#include <esp_lvgl_port.h>
|
||||
|
||||
static const char* TAG = "ST7305";
|
||||
|
||||
bool St7305Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
|
||||
LOG_I(TAG, "Starting ST7305 SPI panel IO creation");
|
||||
|
||||
const esp_lcd_panel_io_spi_config_t panel_io_config = {
|
||||
.cs_gpio_num = configuration->csPin,
|
||||
.dc_gpio_num = configuration->dcPin,
|
||||
.spi_mode = 0,
|
||||
.pclk_hz = configuration->pixelClockFrequency,
|
||||
.trans_queue_depth = configuration->transactionQueueDepth,
|
||||
.on_color_trans_done = nullptr,
|
||||
.user_ctx = nullptr,
|
||||
.lcd_cmd_bits = 8,
|
||||
.lcd_param_bits = 8,
|
||||
.flags = {
|
||||
.dc_high_on_cmd = 0,
|
||||
.dc_low_on_data = 0,
|
||||
.dc_low_on_param = 0,
|
||||
.octal_mode = 0,
|
||||
.quad_mode = 0,
|
||||
.sio_mode = 0,
|
||||
.lsb_first = 0,
|
||||
.cs_high_active = 0
|
||||
}
|
||||
};
|
||||
|
||||
if (esp_lcd_new_panel_io_spi(configuration->spiHostDevice, &panel_io_config, &outHandle) != ESP_OK) {
|
||||
LOG_E(TAG, "Failed to create panel SPI IO");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool St7305Display::createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) {
|
||||
const esp_lcd_panel_dev_config_t panel_config = {
|
||||
.reset_gpio_num = configuration->resetPin,
|
||||
.color_space = ESP_LCD_COLOR_SPACE_MONOCHROME,
|
||||
.data_endian = LCD_RGB_DATA_ENDIAN_BIG,
|
||||
.bits_per_pixel = 1,
|
||||
.flags = {
|
||||
.reset_active_high = false
|
||||
},
|
||||
.vendor_config = nullptr
|
||||
};
|
||||
|
||||
if (esp_lcd_new_panel_st7305(ioHandle, &panel_config, &panelHandle) != ESP_OK) {
|
||||
LOG_E(TAG, "Failed to create st7305 panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
// ST7305 needs extra delay after reset before init — prevents freeze on fast boot
|
||||
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
|
||||
LOG_E(TAG, "Failed to reset st7305 panel");
|
||||
return false;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(150));
|
||||
|
||||
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
|
||||
LOG_E(TAG, "Failed to init st7305 panel");
|
||||
return false;
|
||||
}
|
||||
vTaskDelay(pdMS_TO_TICKS(50));
|
||||
|
||||
if (configuration->invertColor) {
|
||||
if (esp_lcd_panel_invert_color(panelHandle, true) != ESP_OK) {
|
||||
LOG_W(TAG, "Failed to apply initial invertColor");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
lvgl_port_display_cfg_t St7305Display::getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) {
|
||||
return lvgl_port_display_cfg_t {
|
||||
.io_handle = ioHandle,
|
||||
.panel_handle = panelHandle,
|
||||
.control_handle = nullptr,
|
||||
.buffer_size = configuration->bufferSize,
|
||||
.double_buffer = false, // Monochrome displays usually use single buffering to save RAM
|
||||
.trans_size = 0,
|
||||
.hres = configuration->horizontalResolution,
|
||||
.vres = configuration->verticalResolution,
|
||||
.monochrome = true, // Enables esp_lvgl_port monochrome converter
|
||||
.rotation = {
|
||||
.swap_xy = false,
|
||||
.mirror_x = true,
|
||||
.mirror_y = false,
|
||||
},
|
||||
.color_format = LV_COLOR_FORMAT_RGB565, // Must be RGB565 for monochrome mode to trigger converter
|
||||
.flags = {
|
||||
.buff_dma = false,
|
||||
.buff_spiram = false,
|
||||
.sw_rotate = false,
|
||||
.swap_bytes = false,
|
||||
.full_refresh = true, // We want full refresh to rewrite the converted block format to ST7305
|
||||
.direct_mode = false
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user