e7fb5fb38f
- RLCD device.properties: DefaultDark (focus UI visible), fontSize 18
(+28% vs 14: small 10->14, default 14->18, large 18->24, icons 16->20/36->48)
- ST7305 driver: honor invertColor config (was ignored), call
esp_lcd_panel_invert_color after init
- DisplayDevice: add supportsInvertColor + set/get, and
supportsMonochromeThreshold/set/get (ST7305 only)
- EspLcdDisplay: implement invert via panelHandle, and mono threshold via
global g_mono_threshold shared with esp_lvgl_port
- DisplaySettings: new fields invertColor (default true to preserve current
inverted look) and monochromeThreshold (default 60 best for DefaultDark per
user testing, range 20-230)
- Lvgl.cpp: apply invert + threshold at boot from settings
- Display app: add Invert colors switch (if supportsInvertColor) + Mono
threshold slider with live preview and persistence
- esp_lvgl_port_disp.c (components override for hash mismatch): fix B/W
conversion
BEFORE: blue >16 only -> crushed colors, no gray handling
AFTER: proper luminance Y=0.299R+0.587G+0.114B with adjustable threshold
(default 60), no Bayer dithering dots. Crisp text on reflective
- Launcher/button/list wrappers reverted to stock DefaultDark (no white
focus hacks) per user request - focus UI now uses default outline which
survives luminance threshold
Verified on waveshare-esp32-s3-rlcd /dev/cu.usbmodem1101:
- Build 2877200 bytes, flash hash verified
- Invert toggle works, threshold slider live (60 best per test)
- Font bump visible, focus UI visible for button navigation
- No dithering dots
Docs: LVGL mono https://docs.lvgl.io/9.2/porting/display.html#monochrome-displays
Themes: https://docs.lvgl.io/9.2/details/common-widget-features/styles/themes.html
Co-authored-by: Hermes Agent <hermes@noreply>
109 lines
3.6 KiB
C++
109 lines
3.6 KiB
C++
#include "St7305Display.h"
|
|
#include "esp_lcd_st7305.h"
|
|
|
|
#include <Tactility/Logger.h>
|
|
#include <esp_lcd_panel_ops.h>
|
|
#include <esp_lvgl_port.h>
|
|
|
|
static const auto LOGGER = tt::Logger("ST7305");
|
|
|
|
bool St7305Display::createIoHandle(esp_lcd_panel_io_handle_t& outHandle) {
|
|
LOGGER.info("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) {
|
|
LOGGER.error("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) {
|
|
LOGGER.error("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) {
|
|
LOGGER.error("Failed to reset st7305 panel");
|
|
return false;
|
|
}
|
|
vTaskDelay(pdMS_TO_TICKS(150));
|
|
|
|
if (esp_lcd_panel_init(panelHandle) != ESP_OK) {
|
|
LOGGER.error("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) {
|
|
LOGGER.warn("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
|
|
}
|
|
};
|
|
}
|