Initial commit
This commit is contained in:
7
crates/firmware/Cargo.toml
Normal file
7
crates/firmware/Cargo.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "firmware"
|
||||
edition.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
8
crates/firmware/src/lib.rs
Normal file
8
crates/firmware/src/lib.rs
Normal file
@@ -0,0 +1,8 @@
|
||||
#![no_std]
|
||||
#![doc = "Firmware placeholder crate for PineTime-specific code."]
|
||||
|
||||
/// Returns a static marker used while the firmware crate is still a stub.
|
||||
#[must_use]
|
||||
pub const fn platform_name() -> &'static str {
|
||||
"PineTime"
|
||||
}
|
||||
9
crates/simulator/Cargo.toml
Normal file
9
crates/simulator/Cargo.toml
Normal file
@@ -0,0 +1,9 @@
|
||||
[package]
|
||||
name = "simulator"
|
||||
edition.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
embedded-graphics.workspace = true
|
||||
embedded-graphics-simulator.workspace = true
|
||||
ui.workspace = true
|
||||
31
crates/simulator/src/main.rs
Normal file
31
crates/simulator/src/main.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
//! Minimal simulator experiment using Ratatui, Mousefood, and embedded-graphics-simulator.
|
||||
|
||||
use std::{error::Error, thread, time::Duration};
|
||||
|
||||
use embedded_graphics::{pixelcolor::Rgb888, prelude::Size};
|
||||
use embedded_graphics_simulator::{
|
||||
OutputSettingsBuilder, SimulatorDisplay, SimulatorEvent, Window,
|
||||
};
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let mut display = SimulatorDisplay::<Rgb888>::new(Size::new(240, 240));
|
||||
|
||||
ui::start_ui(&mut display)?;
|
||||
|
||||
let output_settings = OutputSettingsBuilder::new().scale(2).build();
|
||||
let mut window = Window::new("Vaka simulator", &output_settings);
|
||||
|
||||
'running: loop {
|
||||
window.update(&display);
|
||||
|
||||
for event in window.events() {
|
||||
if matches!(event, SimulatorEvent::Quit) {
|
||||
break 'running;
|
||||
}
|
||||
}
|
||||
|
||||
thread::sleep(Duration::from_millis(16));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
12
crates/ui/Cargo.toml
Normal file
12
crates/ui/Cargo.toml
Normal 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
35
crates/ui/src/lib.rs
Normal 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(())
|
||||
}
|
||||
Reference in New Issue
Block a user