[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot] 2025-07-14 11:38:13 +00:00 committed by Simon Hausmann
parent 3c64a19127
commit 26f217d12c
4 changed files with 64 additions and 89 deletions

View file

@ -91,7 +91,7 @@ esp32-s3-box-3 = [
esp32-s3-lcd-ev-board = [ esp32-s3-lcd-ev-board = [
"slint/unsafe-single-threaded", "slint/unsafe-single-threaded",
"esp-hal/esp32s3", "esp-hal/esp32s3",
"esp-hal/unstable", # required for PSRAM support "esp-hal/unstable", # required for PSRAM support
"esp-hal/psram", "esp-hal/psram",
"embedded-hal", "embedded-hal",
"embedded-hal-bus", "embedded-hal-bus",
@ -106,7 +106,7 @@ esp32-s3-lcd-ev-board = [
esope-sld-c-w-s3 = [ esope-sld-c-w-s3 = [
"slint/unsafe-single-threaded", "slint/unsafe-single-threaded",
"esp-hal/esp32s3", "esp-hal/esp32s3",
"esp-hal/unstable", # required for PSRAM support "esp-hal/unstable", # required for PSRAM support
"esp-hal/psram", "esp-hal/psram",
"embedded-hal", "embedded-hal",
"embedded-hal-bus", "embedded-hal-bus",

View file

@ -15,12 +15,13 @@ use embedded_graphics_framebuf::FrameBuf;
use slint::platform::software_renderer::Rgb565Pixel; use slint::platform::software_renderer::Rgb565Pixel;
use slint::PhysicalSize; use slint::PhysicalSize;
use alloc::alloc::{alloc, handle_alloc_error};
use alloc::boxed::Box; use alloc::boxed::Box;
use alloc::rc::Rc; use alloc::rc::Rc;
use core::cell::RefCell;
use core::alloc::Layout; use core::alloc::Layout;
use alloc::alloc::{alloc, handle_alloc_error}; use core::cell::RefCell;
use eeprom24x::{Eeprom24x, SlaveAddr};
use esp_hal::clock::CpuClock; use esp_hal::clock::CpuClock;
use esp_hal::dma::{DmaDescriptor, DmaTxBuf, ExternalBurstConfig, CHUNK_SIZE}; use esp_hal::dma::{DmaDescriptor, DmaTxBuf, ExternalBurstConfig, CHUNK_SIZE};
use esp_hal::gpio::{Level, Output, OutputConfig}; use esp_hal::gpio::{Level, Output, OutputConfig};
@ -39,7 +40,6 @@ use esp_hal::timer::{timg::TimerGroup, AnyTimer};
use esp_hal::Config as HalConfig; use esp_hal::Config as HalConfig;
use esp_println::logger::init_logger_from_env; use esp_println::logger::init_logger_from_env;
use log::{error, info}; use log::{error, info};
use eeprom24x::{Eeprom24x, SlaveAddr};
use embassy_executor::Spawner; use embassy_executor::Spawner;
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
@ -108,7 +108,6 @@ pub fn init() {
.expect("Slint platform already initialized"); .expect("Slint platform already initialized");
} }
/// FrameBufferBackend wrapper for a PSRAM-backed [Rgb565; N] slice. /// FrameBufferBackend wrapper for a PSRAM-backed [Rgb565; N] slice.
pub struct PSRAMFrameBuffer<'a> { pub struct PSRAMFrameBuffer<'a> {
buf: &'a mut [Rgb565; LCD_BUFFER_SIZE], buf: &'a mut [Rgb565; LCD_BUFFER_SIZE],
@ -193,7 +192,8 @@ impl slint::platform::Platform for EspBackend {
core::ptr::write_bytes(fb_ptr, 0, FRAME_BYTES); core::ptr::write_bytes(fb_ptr, 0, FRAME_BYTES);
} }
let psram_buf: &'static mut [u8] = unsafe { core::slice::from_raw_parts_mut(fb_ptr, FRAME_BYTES) }; let psram_buf: &'static mut [u8] =
unsafe { core::slice::from_raw_parts_mut(fb_ptr, FRAME_BYTES) };
// Verify PSRAM buffer allocation and alignment // Verify PSRAM buffer allocation and alignment
let buf_ptr = psram_buf.as_ptr() as usize; let buf_ptr = psram_buf.as_ptr() as usize;
@ -246,22 +246,11 @@ impl slint::platform::Platform for EspBackend {
let dpi_config = DpiConfig::default() let dpi_config = DpiConfig::default()
.with_clock_mode(ClockMode { .with_clock_mode(ClockMode {
polarity: if pclk_active_neg { polarity: if pclk_active_neg { Polarity::IdleHigh } else { Polarity::IdleLow },
Polarity::IdleHigh phase: if pclk_active_neg { Phase::ShiftHigh } else { Phase::ShiftLow },
} else {
Polarity::IdleLow
},
phase: if pclk_active_neg {
Phase::ShiftHigh
} else {
Phase::ShiftLow
},
}) })
.with_frequency(Rate::from_hz(pclk_hz)) .with_frequency(Rate::from_hz(pclk_hz))
.with_format(Format { .with_format(Format { enable_2byte_mode: true, ..Default::default() })
enable_2byte_mode: true,
..Default::default()
})
// Use exact timing values that work with Conway's implementation // Use exact timing values that work with Conway's implementation
.with_timing(FrameTiming { .with_timing(FrameTiming {
horizontal_active_width: 320, horizontal_active_width: 320,
@ -274,21 +263,9 @@ impl slint::platform::Platform for EspBackend {
vsync_width: 4, vsync_width: 4,
hsync_position: 43 + 4, // (= back_porch + pulse = 47) Conway's working value hsync_position: 43 + 4, // (= back_porch + pulse = 47) Conway's working value
}) })
.with_vsync_idle_level(if vsync_idle_low { .with_vsync_idle_level(if vsync_idle_low { Level::Low } else { Level::High })
Level::Low .with_hsync_idle_level(if hsync_idle_low { Level::Low } else { Level::High })
} else { .with_de_idle_level(if de_idle_high { Level::High } else { Level::Low })
Level::High
})
.with_hsync_idle_level(if hsync_idle_low {
Level::Low
} else {
Level::High
})
.with_de_idle_level(if de_idle_high {
Level::High
} else {
Level::Low
})
.with_disable_black_region(false); .with_disable_black_region(false);
let mut dpi = Dpi::new(lcd_cam.lcd, peripherals.DMA_CH2, dpi_config) let mut dpi = Dpi::new(lcd_cam.lcd, peripherals.DMA_CH2, dpi_config)
@ -368,32 +345,33 @@ impl slint::platform::Platform for EspBackend {
// Spawn Conway update task on app core (core 1) // Spawn Conway update task on app core (core 1)
let mut cpu_control = CpuControl::new(peripherals.CPU_CTRL); let mut cpu_control = CpuControl::new(peripherals.CPU_CTRL);
let _app_core = cpu_control.start_app_core(unsafe { &mut *core::ptr::addr_of_mut!(APP_CORE_STACK) }, move || { let _app_core = cpu_control.start_app_core(
// Initialize TimerGroup and timer1 for app core Embassy time driver unsafe { &mut *core::ptr::addr_of_mut!(APP_CORE_STACK) },
let timg1 = TimerGroup::new(unsafe { esp_hal::peripherals::TIMG1::steal() }); move || {
let timer1: AnyTimer = timg1.timer0.into(); // Initialize TimerGroup and timer1 for app core Embassy time driver
// Initialize Embassy time driver on app core let timg1 = TimerGroup::new(unsafe { esp_hal::peripherals::TIMG1::steal() });
esp_hal_embassy::init([timer0, timer1]); let timer1: AnyTimer = timg1.timer0.into();
// SAFETY: PSRAM_BUF_PTR and PSRAM_BUF_LEN are published before // Initialize Embassy time driver on app core
let psram_ptr = unsafe { PSRAM_BUF_PTR }; esp_hal_embassy::init([timer0, timer1]);
let psram_len = unsafe { PSRAM_BUF_LEN }; // SAFETY: PSRAM_BUF_PTR and PSRAM_BUF_LEN are published before
// Wait until PSRAM is ready let psram_ptr = unsafe { PSRAM_BUF_PTR };
loop { let psram_len = unsafe { PSRAM_BUF_LEN };
if PSRAM_READY.try_take().is_some() { // Wait until PSRAM is ready
break; loop {
if PSRAM_READY.try_take().is_some() {
break;
}
// Simple spin wait
core::hint::spin_loop();
} }
// Simple spin wait // Initialize and run Embassy executor on app core
core::hint::spin_loop(); static EXECUTOR: StaticCell<Executor> = StaticCell::new();
} let executor = EXECUTOR.init(Executor::new());
// Initialize and run Embassy executor on app core executor.run(|spawner| {
static EXECUTOR: StaticCell<Executor> = StaticCell::new(); spawner.spawn(slint_task(psram_ptr, psram_len)).ok();
let executor = EXECUTOR.init(Executor::new()); });
executor.run(|spawner| { },
spawner );
.spawn(slint_task(psram_ptr, psram_len))
.ok();
});
});
// Core 0: Only send DMA frames in a loop // Core 0: Only send DMA frames in a loop
loop { loop {
@ -418,22 +396,17 @@ impl slint::platform::Platform for EspBackend {
} }
} }
} }
} }
} }
#[embassy_executor::task] #[embassy_executor::task]
async fn slint_task(psram_ptr: *mut u8, _psram_len: usize) { async fn slint_task(psram_ptr: *mut u8, _psram_len: usize) {
// Reconstruct the framebuffer // Reconstruct the framebuffer
let fb: &mut [Rgb565; LCD_BUFFER_SIZE] = let fb: &mut [Rgb565; LCD_BUFFER_SIZE] =
unsafe { &mut *(psram_ptr as *mut [Rgb565; LCD_BUFFER_SIZE]) }; unsafe { &mut *(psram_ptr as *mut [Rgb565; LCD_BUFFER_SIZE]) };
let mut frame_buf = FrameBuf::new( let mut frame_buf =
PSRAMFrameBuffer::new(fb), FrameBuf::new(PSRAMFrameBuffer::new(fb), LCD_H_RES_USIZE.into(), LCD_V_RES_USIZE.into());
LCD_H_RES_USIZE.into(),
LCD_V_RES_USIZE.into(),
);
let mut ticker = Ticker::every(embassy_time::Duration::from_millis(100)); let mut ticker = Ticker::every(embassy_time::Duration::from_millis(100));
loop { loop {
@ -447,4 +420,3 @@ async fn slint_task(psram_ptr: *mut u8, _psram_len: usize) {
ticker.next().await; ticker.next().await;
} }
} }

View file

@ -13,4 +13,3 @@ target = "xtensa-esp32s3-none-elf"
[unstable] [unstable]
build-std = ["core", "alloc"] build-std = ["core", "alloc"]

View file

@ -76,6 +76,10 @@ pub fn init() {}
mod embassy; mod embassy;
pub mod prelude { pub mod prelude {
#[cfg(any(feature = "esp32-s3-box-3", feature = "esp32-s3-lcd-ev-board", feature = "esope-sld-c-w-s3"))] #[cfg(any(
feature = "esp32-s3-box-3",
feature = "esp32-s3-lcd-ev-board",
feature = "esope-sld-c-w-s3"
))]
pub use esp_hal; pub use esp_hal;
} }