[][src]Crate embedded_graphics_simulator

Embedded graphics simulator

It can display all sorts of embedded-graphics test code.

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, egcircle, egline, text_6x8};
use embedded_graphics::pixelcolor::BinaryColor::Off as C0;
use embedded_graphics::pixelcolor::BinaryColor::On as C1;
use embedded_graphics_simulator::{DisplayBuilder, BinaryColorTheme};
use std::thread;
use std::time::Duration;

fn main() {
    let mut display = DisplayBuilder::new()
        .theme(BinaryColorTheme::OledBlue)
        .size(128, 64)
        .build_binary();

    display.draw(text_6x8!("Hello World!"));

    display.draw(egcircle!((96, 32), 31, stroke = Some(C1)));

    display.draw(egline!((32, 32), (1, 32), stroke = Some(C1))
        .translate(icoord!(64, 0)));
    display.draw(egline!((32, 32), (40, 40), stroke = Some(C1))
        .translate(icoord!(64, 0)));

    loop {
        let end = display.run_once();

        if end {
            break;
        }

        thread::sleep(Duration::from_millis(200));
    }
}

Structs

BinaryDisplay

Simulated binary color display

DisplayBuilder

Create a simulator display using the builder pattern

RgbDisplay

Simulated RGB display

Enums

BinaryColorTheme

Color theme for binary displays