From 09cdf07b7ca292680f3f151c39064a9b2b93bba5 Mon Sep 17 00:00:00 2001 From: Shadowtrance Date: Sat, 22 Feb 2025 22:53:48 +1000 Subject: [PATCH] Bring the ST7789 driver inline with the ILI934x driver (#228) more configuration options as not every display / board is the same. --- Drivers/ST7789/Source/St7789Display.cpp | 12 ++++++------ Drivers/ST7789/Source/St7789Display.h | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Drivers/ST7789/Source/St7789Display.cpp b/Drivers/ST7789/Source/St7789Display.cpp index 44b0b552..c7e49a21 100644 --- a/Drivers/ST7789/Source/St7789Display.cpp +++ b/Drivers/ST7789/Source/St7789Display.cpp @@ -67,17 +67,17 @@ bool St7789Display::start() { return false; } - if (esp_lcd_panel_invert_color(panelHandle, true) != ESP_OK) { + if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) { TT_LOG_E(TAG, "Failed to set panel to invert"); return false; } - if (esp_lcd_panel_swap_xy(panelHandle, true) != ESP_OK) { + if (esp_lcd_panel_swap_xy(panelHandle, configuration->swapXY) != ESP_OK) { TT_LOG_E(TAG, "Failed to swap XY "); return false; } - if (esp_lcd_panel_mirror(panelHandle, true, false) != ESP_OK) { + if (esp_lcd_panel_mirror(panelHandle, configuration->mirrorX, configuration->mirrorY) != ESP_OK) { TT_LOG_E(TAG, "Failed to set panel to mirror"); return false; } @@ -104,9 +104,9 @@ bool St7789Display::start() { .vres = configuration->verticalResolution, .monochrome = false, .rotation = { - .swap_xy = true, - .mirror_x = true, - .mirror_y = false, + .swap_xy = configuration->swapXY, + .mirror_x = configuration->mirrorX, + .mirror_y = configuration->mirrorY, }, .color_format = LV_COLOR_FORMAT_RGB565, .flags = { diff --git a/Drivers/ST7789/Source/St7789Display.h b/Drivers/ST7789/Source/St7789Display.h index 820b3382..8296d255 100644 --- a/Drivers/ST7789/Source/St7789Display.h +++ b/Drivers/ST7789/Source/St7789Display.h @@ -23,12 +23,22 @@ public: gpio_num_t dcPin, unsigned int horizontalResolution, unsigned int verticalResolution, - std::shared_ptr touch + std::shared_ptr touch, + bool swapXY = false, + bool mirrorX = false, + bool mirrorY = false, + bool invertColor = false, + uint32_t bufferSize = 0 // Size in pixel count. 0 means default, which is 1/10 of the screen size ) : spiBusHandle(spi_bus_handle), csPin(csPin), dcPin(dcPin), horizontalResolution(horizontalResolution), verticalResolution(verticalResolution), + swapXY(swapXY), + mirrorX(mirrorX), + mirrorY(mirrorY), + invertColor(invertColor), + bufferSize(bufferSize), touch(std::move(touch)) {} @@ -40,6 +50,10 @@ public: 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; // Size in pixel count. 0 means default, which is 1/10 of the screen size std::shared_ptr touch; std::function _Nullable backlightDutyFunction = nullptr;