1a96307de2
- 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
101 lines
3.2 KiB
C++
101 lines
3.2 KiB
C++
#pragma once
|
|
|
|
#include <EspLcdDisplay.h>
|
|
#include <Tactility/hal/display/DisplayDevice.h>
|
|
|
|
#include <driver/gpio.h>
|
|
#include <driver/spi_common.h>
|
|
#include <esp_lcd_panel_io.h>
|
|
#include <esp_lcd_types.h>
|
|
#include <functional>
|
|
#include <lvgl.h>
|
|
|
|
class St7305Display final : public EspLcdDisplay {
|
|
|
|
public:
|
|
|
|
class Configuration {
|
|
|
|
public:
|
|
|
|
Configuration(
|
|
spi_host_device_t spiHostDevice,
|
|
gpio_num_t csPin,
|
|
gpio_num_t dcPin,
|
|
unsigned int horizontalResolution,
|
|
unsigned int verticalResolution,
|
|
std::shared_ptr<tt::hal::touch::TouchDevice> touch = nullptr,
|
|
bool swapXY = false,
|
|
bool mirrorX = false,
|
|
bool mirrorY = false,
|
|
bool invertColor = false,
|
|
uint32_t bufferSize = 0
|
|
) : spiHostDevice(spiHostDevice),
|
|
csPin(csPin),
|
|
dcPin(dcPin),
|
|
horizontalResolution(horizontalResolution),
|
|
verticalResolution(verticalResolution),
|
|
swapXY(swapXY),
|
|
mirrorX(mirrorX),
|
|
mirrorY(mirrorY),
|
|
invertColor(invertColor),
|
|
bufferSize(bufferSize),
|
|
touch(std::move(touch))
|
|
{
|
|
if (this->bufferSize == 0) {
|
|
// For monochrome display, full pixel count is expected for buffer size
|
|
this->bufferSize = horizontalResolution * verticalResolution;
|
|
}
|
|
}
|
|
|
|
spi_host_device_t spiHostDevice;
|
|
gpio_num_t csPin;
|
|
gpio_num_t dcPin;
|
|
gpio_num_t resetPin = GPIO_NUM_NC;
|
|
unsigned int pixelClockFrequency = 10'000'000; // 10MHz SPI clock for ST7305
|
|
size_t transactionQueueDepth = 10;
|
|
unsigned int horizontalResolution;
|
|
unsigned int verticalResolution;
|
|
bool swapXY = false;
|
|
bool mirrorX = false;
|
|
bool mirrorY = false;
|
|
bool invertColor = false;
|
|
uint32_t bufferSize = 0;
|
|
std::shared_ptr<tt::hal::touch::TouchDevice> touch;
|
|
std::function<void(uint8_t)> _Nullable backlightDutyFunction = nullptr;
|
|
};
|
|
|
|
private:
|
|
|
|
std::unique_ptr<Configuration> configuration;
|
|
|
|
bool createIoHandle(esp_lcd_panel_io_handle_t& ioHandle) override;
|
|
|
|
bool createPanelHandle(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t& panelHandle) override;
|
|
|
|
lvgl_port_display_cfg_t getLvglPortDisplayConfig(esp_lcd_panel_io_handle_t ioHandle, esp_lcd_panel_handle_t panelHandle) override;
|
|
|
|
public:
|
|
|
|
explicit St7305Display(std::unique_ptr<Configuration> inConfiguration) :
|
|
configuration(std::move(inConfiguration))
|
|
{}
|
|
|
|
std::string getName() const override { return "ST7305"; }
|
|
|
|
std::string getDescription() const override { return "ST7305 monochrome reflective LCD display"; }
|
|
|
|
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable getTouchDevice() override { return configuration->touch; }
|
|
|
|
void setBacklightDuty(uint8_t backlightDuty) override {
|
|
if (configuration->backlightDutyFunction != nullptr) {
|
|
configuration->backlightDutyFunction(backlightDuty);
|
|
}
|
|
}
|
|
|
|
bool supportsBacklightDuty() const override { return configuration->backlightDutyFunction != nullptr; }
|
|
|
|
};
|
|
|
|
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|