Add embedded, gui, and simulator in same repo
This commit is contained in:
parent
0a1f5f2dfb
commit
256341cd5e
1
gui
Submodule
1
gui
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 12afc17f90756988b9011240e6884fa0e3fb48ef
|
||||
12
simulator/Cargo.toml
Normal file
12
simulator/Cargo.toml
Normal file
@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "gui-test"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
embedded-graphics = "0.8.1"
|
||||
embedded-graphics-simulator = "0.7.0"
|
||||
embedded-layout = "0.4.1"
|
||||
heapless = "0.8.0"
|
||||
profont = "0.7.0"
|
||||
gui = { path = "../gui/" }
|
||||
43
simulator/src/main.rs
Normal file
43
simulator/src/main.rs
Normal file
@ -0,0 +1,43 @@
|
||||
use embedded_graphics::{geometry::Size, pixelcolor::Rgb565};
|
||||
use embedded_graphics_simulator::{
|
||||
sdl2::Keycode, OutputSettingsBuilder, SimulatorDisplay, SimulatorEvent, Window,
|
||||
};
|
||||
|
||||
use gui::*;
|
||||
|
||||
fn main() -> Result<(), core::convert::Infallible> {
|
||||
let display = SimulatorDisplay::<Rgb565>::new(Size::new(240, 320));
|
||||
|
||||
let output_settings = OutputSettingsBuilder::new().scale(1).build();
|
||||
let mut window = Window::new("Hello World", &output_settings);
|
||||
|
||||
let mut gui = Gui::new(display);
|
||||
|
||||
'running: loop {
|
||||
gui.draw()?;
|
||||
window.update(gui.display_ref());
|
||||
|
||||
for event in window.events() {
|
||||
match event {
|
||||
SimulatorEvent::Quit => break 'running,
|
||||
SimulatorEvent::KeyDown { keycode, .. } => {
|
||||
let action: GuiAction = match keycode {
|
||||
Keycode::Left => GuiAction::Left,
|
||||
Keycode::Right => GuiAction::Right,
|
||||
Keycode::Up => GuiAction::Up,
|
||||
Keycode::Down => GuiAction::Down,
|
||||
Keycode::Return => GuiAction::Select,
|
||||
Keycode::Backspace => GuiAction::Back,
|
||||
_ => continue,
|
||||
};
|
||||
|
||||
gui = gui.action(action);
|
||||
gui.fill_black()?;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user