Various fixes and improvements (#269)

- Bump version for next release
- Fix default gamma for CYD 2432S032C
- Remember gamma curve setting from Display settings app
- Add UART to Core2 (still has no voltage on Grove port, though)
- LVGL performance improvements: pin to second core and set task priority to "critical"
- Fix build warnings, including deprecations
- Removed deprecated `Thread` constructor
- Fix WaveShare S3 display: Some displays would show a white screen at 12MHz, so I'm putting it back to the
official config values.
This commit is contained in:
Ken Van Hoeylandt
2025-04-01 23:42:56 +02:00
committed by GitHub
parent eb4e9f9649
commit 08029a84dd
30 changed files with 203 additions and 145 deletions
+17 -3
View File
@@ -3,12 +3,26 @@
#include "hal/CydDisplay.h"
#include "hal/CydSdCard.h"
#include <Tactility/kernel/SystemEvents.h>
#include <PwmBacklight.h>
#define CYD_SPI_TRANSFER_SIZE_LIMIT (TWODOTFOUR_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
bool initBoot() {
return driver::pwmbacklight::init(GPIO_NUM_27);
if (!driver::pwmbacklight::init(GPIO_NUM_27)) {
return false;
}
// This display has a weird glitch with gamma during boot, which results in uneven dark gray colours.
// Setting gamma curve index to 0 doesn't work at boot for an unknown reason, so we set the curve index to 1:
tt::kernel::subscribeSystemEvent(tt::kernel::SystemEvent::BootInitLvglEnd, [](auto event) {
auto display = tt::hal::findFirstDevice<tt::hal::display::DisplayDevice>(tt::hal::Device::Type::Display);
assert(display != nullptr);
tt::lvgl::lock(portMAX_DELAY);
display->setGammaCurve(1U);
tt::lvgl::unlock();
});
return true;
}
const tt::hal::Configuration cyd_2432S032c_config = {
@@ -9,6 +9,8 @@
#define CORE2_SPI_TRANSFER_SIZE_LIMIT (CORE2_LCD_DRAW_BUFFER_SIZE * LV_COLOR_DEPTH / 8)
using namespace tt::hal;
extern const tt::hal::Configuration m5stack_core2 = {
.initBoot = initBoot,
.createDisplay = createDisplay,
@@ -74,5 +76,30 @@ extern const tt::hal::Configuration m5stack_core2 = {
.isMutable = false,
.lock = tt::lvgl::getSyncLock() // esp_lvgl_port owns the lock for the display
}
},
.uart {
uart::Configuration {
.name = "Grove",
.port = UART_NUM_1,
.rxPin = GPIO_NUM_32,
.txPin = GPIO_NUM_33,
.rtsPin = GPIO_NUM_NC,
.ctsPin = GPIO_NUM_NC,
.rxBufferSize = 1024,
.txBufferSize = 1024,
.config = {
.baud_rate = 115200,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0,
.source_clk = UART_SCLK_DEFAULT,
.flags = {
.allow_pd = 0,
.backup_before_sleep = 0,
}
}
},
}
};
+2 -3
View File
@@ -137,7 +137,7 @@ static void updatePowerSwitch() {
}
}
static int32_t powerSwitchMain(void*) { // check power switch every 10th of sec
static int32_t powerSwitchMain() { // check power switch every 10th of sec
while (true) {
updatePowerSwitch();
tt::kernel::delayMillis(200);
@@ -148,8 +148,7 @@ static void startPowerSwitchThread() {
powerThread = std::make_unique<tt::Thread>(
"unphone_power_switch",
4096,
powerSwitchMain,
nullptr
[]() { return powerSwitchMain(); }
);
powerThread->start();
}
@@ -23,15 +23,15 @@ std::shared_ptr<tt::hal::display::DisplayDevice> createDisplay() {
esp_lcd_rgb_panel_config_t rgb_panel_config = {
.clk_src = LCD_CLK_SRC_DEFAULT,
.timings = {
.pclk_hz = 12'000'000, // NOTE: original was 14MHz, but we had to slow it down with PSRAM frame buffer,
.pclk_hz = 16'000'000,
.h_res = 800,
.v_res = 480,
.hsync_pulse_width = 10,
.hsync_back_porch = 10,
.hsync_front_porch = 20,
.vsync_pulse_width = 10,
.vsync_back_porch = 10,
.vsync_front_porch = 10,
.hsync_pulse_width = 4,
.hsync_back_porch = 8,
.hsync_front_porch = 8,
.vsync_pulse_width = 4,
.vsync_back_porch = 8,
.vsync_front_porch = 8,
.flags = {
.hsync_idle_low = false,
.vsync_idle_low = false,