Shadowtrance board implementations (#241)
Adapted from pull request https://github.com/ByteWelder/Tactility/pull/238 - JC2432W328C - ST7789 - CST820 (816) 240x320 - 2.8 inch - ESP32-8048S043C - ST7262 - GT911 800x480 - 4.3 inch - JC8048W550C - ST7262 - GT911 800x480 - 5 inch
This commit is contained in:
committed by
GitHub
parent
85a6ad3bbe
commit
778e003d4d
@@ -94,5 +94,3 @@ public:
|
||||
|
||||
lv_display_t* _Nullable getLvglDisplay() const final { return displayHandle; }
|
||||
};
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
idf_component_register(
|
||||
SRC_DIRS "Source"
|
||||
INCLUDE_DIRS "Source"
|
||||
REQUIRES Tactility esp_lvgl_port esp_lcd
|
||||
)
|
||||
@@ -0,0 +1,3 @@
|
||||
# RGB Display Driver
|
||||
|
||||
This driver is used for displays that use multiple parallel data lanes.
|
||||
@@ -0,0 +1,109 @@
|
||||
#include "RgbDisplay.h"
|
||||
|
||||
#include <Tactility/Log.h>
|
||||
|
||||
#include <esp_err.h>
|
||||
#include <esp_lcd_panel_rgb.h>
|
||||
#include <esp_lcd_panel_ops.h>
|
||||
#include <esp_lvgl_port.h>
|
||||
|
||||
#define TAG "RgbDisplay"
|
||||
|
||||
bool RgbDisplay::start() {
|
||||
TT_LOG_I(TAG, "Starting");
|
||||
|
||||
if (esp_lcd_new_rgb_panel(&configuration->panelConfig, &panelHandle) != ESP_OK) {
|
||||
TT_LOG_E(TAG, "Failed to create panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_reset(panelHandle) != ESP_OK) {
|
||||
TT_LOG_E(TAG, "Failed to reset panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
|
||||
TT_LOG_E(TAG, "Failed to init panel");
|
||||
return false;
|
||||
}
|
||||
|
||||
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, configuration->mirrorX, configuration->mirrorY) != ESP_OK) {
|
||||
TT_LOG_E(TAG, "Failed to set panel to mirror");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_invert_color(panelHandle, configuration->invertColor) != ESP_OK) {
|
||||
TT_LOG_E(TAG, "Failed to set panel to invert");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto horizontal_resolution = configuration->panelConfig.timings.h_res;
|
||||
auto vertical_resolution = configuration->panelConfig.timings.v_res;
|
||||
|
||||
uint32_t buffer_size;
|
||||
if (configuration->bufferConfiguration.size == 0) {
|
||||
buffer_size = horizontal_resolution * vertical_resolution / 15;
|
||||
} else {
|
||||
buffer_size = configuration->bufferConfiguration.size;
|
||||
}
|
||||
|
||||
const lvgl_port_display_cfg_t display_config = {
|
||||
.io_handle = ioHandle,
|
||||
.panel_handle = panelHandle,
|
||||
.control_handle = nullptr,
|
||||
.buffer_size = buffer_size,
|
||||
.double_buffer = configuration->bufferConfiguration.doubleBuffer,
|
||||
.trans_size = 0,
|
||||
.hres = horizontal_resolution,
|
||||
.vres = vertical_resolution,
|
||||
.monochrome = false,
|
||||
.rotation = {
|
||||
.swap_xy = configuration->swapXY,
|
||||
.mirror_x = configuration->mirrorX,
|
||||
.mirror_y = configuration->mirrorY,
|
||||
},
|
||||
.color_format = configuration->colorFormat,
|
||||
.flags = {
|
||||
.buff_dma = !configuration->bufferConfiguration.useSpi,
|
||||
.buff_spiram = configuration->bufferConfiguration.useSpi,
|
||||
.sw_rotate = false,
|
||||
.swap_bytes = false,
|
||||
.full_refresh = false,
|
||||
.direct_mode = false
|
||||
}
|
||||
};
|
||||
|
||||
const lvgl_port_display_rgb_cfg_t rgb_config = {
|
||||
.flags = {
|
||||
.bb_mode = configuration->bufferConfiguration.bounceBufferMode,
|
||||
.avoid_tearing = configuration->bufferConfiguration.avoidTearing
|
||||
}
|
||||
};
|
||||
|
||||
displayHandle = lvgl_port_add_disp_rgb(&display_config, &rgb_config);
|
||||
TT_LOG_I(TAG, "Finished");
|
||||
|
||||
return displayHandle != nullptr;
|
||||
}
|
||||
|
||||
bool RgbDisplay::stop() {
|
||||
assert(displayHandle != nullptr);
|
||||
|
||||
lvgl_port_remove_disp(displayHandle);
|
||||
|
||||
if (esp_lcd_panel_del(panelHandle) != ESP_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (esp_lcd_panel_io_del(ioHandle) != ESP_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
displayHandle = nullptr;
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/hal/display/DisplayDevice.h"
|
||||
|
||||
#include <esp_lcd_panel_rgb.h>
|
||||
#include <esp_lcd_types.h>
|
||||
#include <lvgl.h>
|
||||
|
||||
#include <utility>
|
||||
|
||||
class RgbDisplay : public tt::hal::display::DisplayDevice {
|
||||
|
||||
public:
|
||||
|
||||
struct BufferConfiguration final {
|
||||
uint32_t size; // Size in pixel count. 0 means default, which is 1/15 of the screen size
|
||||
bool useSpi;
|
||||
bool doubleBuffer;
|
||||
bool bounceBufferMode;
|
||||
bool avoidTearing;
|
||||
};
|
||||
|
||||
class Configuration final {
|
||||
public:
|
||||
|
||||
esp_lcd_rgb_panel_config_t panelConfig;
|
||||
BufferConfiguration bufferConfiguration;
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> touch;
|
||||
lv_color_format_t colorFormat;
|
||||
bool swapXY;
|
||||
bool mirrorX;
|
||||
bool mirrorY;
|
||||
bool invertColor;
|
||||
std::function<void(uint8_t)> _Nullable backlightDutyFunction;
|
||||
|
||||
Configuration(
|
||||
esp_lcd_rgb_panel_config_t panelConfig,
|
||||
BufferConfiguration bufferConfiguration,
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> touch,
|
||||
lv_color_format_t colorFormat,
|
||||
bool swapXY = false,
|
||||
bool mirrorX = false,
|
||||
bool mirrorY = false,
|
||||
bool invertColor = false,
|
||||
std::function<void(uint8_t)> _Nullable backlightDutyFunction = nullptr
|
||||
) : panelConfig(panelConfig),
|
||||
bufferConfiguration(bufferConfiguration),
|
||||
touch(std::move(touch)),
|
||||
colorFormat(colorFormat),
|
||||
swapXY(swapXY),
|
||||
mirrorX(mirrorX),
|
||||
mirrorY(mirrorY),
|
||||
invertColor(invertColor),
|
||||
backlightDutyFunction(std::move(backlightDutyFunction))
|
||||
{}
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
std::unique_ptr<Configuration> configuration = nullptr;
|
||||
esp_lcd_panel_io_handle_t ioHandle = nullptr;
|
||||
esp_lcd_panel_handle_t panelHandle = nullptr;
|
||||
lv_display_t* displayHandle = nullptr;
|
||||
|
||||
public:
|
||||
|
||||
explicit RgbDisplay(std::unique_ptr<Configuration> inConfiguration) : configuration(std::move(inConfiguration)) {
|
||||
assert(configuration != nullptr);
|
||||
}
|
||||
|
||||
std::string getName() const final { return "RGB Display"; }
|
||||
std::string getDescription() const final { return "RGB Display"; }
|
||||
|
||||
bool start() override;
|
||||
|
||||
bool stop() override;
|
||||
|
||||
std::shared_ptr<tt::hal::touch::TouchDevice> _Nullable createTouch() final { return configuration->touch; }
|
||||
|
||||
void setBacklightDuty(uint8_t backlightDuty) final {
|
||||
if (configuration->backlightDutyFunction != nullptr) {
|
||||
configuration->backlightDutyFunction(backlightDuty);
|
||||
}
|
||||
}
|
||||
|
||||
bool supportsBacklightDuty() const final { return configuration->backlightDutyFunction != nullptr; }
|
||||
|
||||
lv_display_t* _Nullable getLvglDisplay() const override { return displayHandle; }
|
||||
};
|
||||
|
||||
std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay();
|
||||
Reference in New Issue
Block a user