1// Copyright © 2025 David Haig
2// SPDX-License-Identifier: MIT
3
4use alloc::rc::Rc;
5use embassy_time::Instant;
6use slint::{
7 platform::{
8 software_renderer::{self, MinimalSoftwareWindow},
9 Platform, WindowAdapter,
10 },
11 PlatformError,
12};
13
14pub const DISPLAY_WIDTH: usize = 800;
15pub const DISPLAY_HEIGHT: usize = 480;
16pub type TargetPixelType = software_renderer::Rgb565Pixel;
17
18pub struct StmBackend {
19 window: Rc<MinimalSoftwareWindow>,
20}
21
22impl StmBackend {
23 pub fn new(window: Rc<MinimalSoftwareWindow>) -> Self {
24 Self { window }
25 }
26}
27
28impl Platform for StmBackend {
29 fn create_window_adapter(&self) -> Result<Rc<dyn WindowAdapter>, PlatformError> {
30 let window: Rc = self.window.clone();
31 crate::info!("create_window_adapter called");
32 Ok(window)
33 }
34
35 fn duration_since_start(&self) -> core::time::Duration {
36 Instant::now().duration_since(earlier:Instant::from_secs(seconds:0)).into()
37 }
38}
39