| 1 | // Copyright © 2025 David Haig |
| 2 | // SPDX-License-Identifier: MIT |
| 3 | |
| 4 | use alloc::rc::Rc; |
| 5 | use embassy_time::Instant; |
| 6 | use slint::{ |
| 7 | platform::{ |
| 8 | software_renderer::{self, MinimalSoftwareWindow}, |
| 9 | Platform, WindowAdapter, |
| 10 | }, |
| 11 | PlatformError, |
| 12 | }; |
| 13 | |
| 14 | pub const DISPLAY_WIDTH: usize = 800; |
| 15 | pub const DISPLAY_HEIGHT: usize = 480; |
| 16 | pub type TargetPixelType = software_renderer::Rgb565Pixel; |
| 17 | |
| 18 | pub struct StmBackend { |
| 19 | window: Rc<MinimalSoftwareWindow>, |
| 20 | } |
| 21 | |
| 22 | impl StmBackend { |
| 23 | pub fn new(window: Rc<MinimalSoftwareWindow>) -> Self { |
| 24 | Self { window } |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | impl 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 | |