[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 = [
"slint/unsafe-single-threaded",
"esp-hal/esp32s3",
"esp-hal/unstable", # required for PSRAM support
"esp-hal/unstable", # required for PSRAM support
"esp-hal/psram",
"embedded-hal",
"embedded-hal-bus",
@ -106,7 +106,7 @@ esp32-s3-lcd-ev-board = [
esope-sld-c-w-s3 = [
"slint/unsafe-single-threaded",
"esp-hal/esp32s3",
"esp-hal/unstable", # required for PSRAM support
"esp-hal/unstable", # required for PSRAM support
"esp-hal/psram",
"embedded-hal",
"embedded-hal-bus",

View file

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

View file

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

View file

@ -76,6 +76,10 @@ pub fn init() {}
mod embassy;
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;
}