[−][src]Crate embedded_graphics_simulator
Embedded graphics simulator
The simulator can be used to test and debug embedded-graphics code, or produce snazzy examples for people to try drivers out without needing physical hardware to run on.
Setup
The simulator uses SDL and its development libraries which must be installed to build and run it.
Linux (apt
)
sudo apt install libsdl2-dev
macOS (brew
)
brew install sdl2
Windows
The Windows install process is a bit more involved, but it does work. See the SDL2 wiki for instructions.
Examples
Simulate a 128x64 SSD1306 OLED
use embedded_graphics::prelude::*; use embedded_graphics::{icoord, circle, line, text_6x8}; use embedded_graphics_simulator::{DisplayBuilder, DisplayTheme}; use std::thread; use std::time::Duration; fn main() { let mut display = DisplayBuilder::new() .theme(DisplayTheme::OledBlue) .size(128, 64) .build(); display.draw(text_6x8!("Hello World!")); display.draw(circle!((96, 32), 31, stroke = Some(1u8.into()))); display.draw(line!((32, 32), (1, 32), stroke = Some(1u8.into())) .translate(icoord!(64, 0))); display.draw(line!((32, 32), (40, 40), stroke = Some(1u8.into())) .translate(icoord!(64, 0))); loop { let end = display.run_once(); if end { break; } thread::sleep(Duration::from_millis(200)); } }
Structs
Display | Create a new window with a simulated display to draw into |
DisplayBuilder | Create a simulator display using the builder pattern |
SimPixelColor | 24 bit RGB pixel type used by the simulator display |
Enums
DisplayTheme | Display theme to use |