acid/firmware2/src/ui/mod.rs

40 lines
1.1 KiB
Rust
Raw Normal View History

// #![cfg_attr(not(feature = "simulator"), no_main)]
2026-01-10 19:21:13 +01:00
use alloc::boxed::Box;
#[cfg(feature = "limit-fps")]
use crate::FRAME_DURATION_MIN;
use crate::{
2026-01-12 01:03:27 +01:00
SIGNAL_LCD_SUBMIT, SIGNAL_UI_RENDER, ui::backend::SlintBackend,
2026-01-10 19:21:13 +01:00
};
2025-12-31 22:24:26 +01:00
pub mod backend;
2026-01-10 19:21:13 +01:00
pub mod window_adapter;
2025-12-31 22:24:26 +01:00
slint::include_modules!();
2026-01-10 19:21:13 +01:00
#[embassy_executor::task]
pub async fn run_renderer_task(backend: SlintBackend) {
slint::platform::set_platform(Box::new(backend)).expect("backend already initialized");
let main = AppWindow::new().unwrap();
// Instead of having a `loop` in the non-async `SlintBackend::run_event_loop`, we achieve
// async by having only one iteration of the loop run, and `await`ing here.
// The following block is analogous to `main.run()`.
{
main.show().unwrap();
loop {
slint::run_event_loop().unwrap();
SIGNAL_LCD_SUBMIT.signal(());
#[cfg(feature = "limit-fps")]
embassy_time::Timer::after(FRAME_DURATION_MIN).await;
SIGNAL_UI_RENDER.wait().await;
}
#[expect(unreachable_code)]
main.hide().unwrap();
}
}