Initial commit

This commit is contained in:
2026-03-20 17:23:49 +01:00
commit 3e016daa9c
15 changed files with 2538 additions and 0 deletions

12
crates/ui/Cargo.toml Normal file
View File

@@ -0,0 +1,12 @@
[package]
name = "ui"
edition.workspace = true
version.workspace = true
[lib]
path = "src/lib.rs"
[dependencies]
mousefood.workspace = true
ratatui.workspace = true
embedded-graphics.workspace = true

35
crates/ui/src/lib.rs Normal file
View File

@@ -0,0 +1,35 @@
#![doc = "Shared UI helpers for firmware and simulator."]
use std::error::Error;
use embedded_graphics::prelude::{Dimensions, DrawTarget};
use mousefood::prelude::*;
use ratatui::{
Terminal,
style::Stylize,
widgets::{Block, Paragraph},
};
/// Returns the first shared text used by the simulator experiment.
#[must_use]
pub const fn hello_world() -> &'static str {
"Hello, world from Ratatui"
}
pub fn start_ui<D>(display: &mut D) -> Result<(), Box<dyn Error>>
where
D: DrawTarget<Color = Rgb888> + Dimensions + 'static,
{
let backend = EmbeddedBackend::new(display, EmbeddedBackendConfig::default());
let mut terminal = Terminal::new(backend)?;
terminal.draw(|frame| {
let widget = Paragraph::new(crate::hello_world().bold().yellow())
.block(Block::bordered().title("Vaka"))
.centered();
frame.render_widget(widget, frame.area());
})?;
Ok(())
}