use embedded_graphics::{pixelcolor::BinaryColor, prelude::*}; use embedded_graphics_simulator::{ BinaryColorTheme, OutputSettingsBuilder, SimulatorDisplay, SimulatorEvent, Window, }; use std::thread; use std::time::Duration; use ui::{HelloDisplay, HelloEvent}; const DISPLAY_W: i32 = 128; const DISPLAY_H: i32 = 64; fn main() { let mut display: SimulatorDisplay = SimulatorDisplay::new(Size::new(DISPLAY_W as u32, DISPLAY_H as u32)); let output_settings = OutputSettingsBuilder::new() .theme(BinaryColorTheme::OledBlue) .build(); let mut window = Window::new("Example", &output_settings); let mut hello: HelloDisplay = HelloDisplay::new(); 'running: loop { hello.draw(&mut display).unwrap(); window.update(&display); hello.event(HelloEvent::Tick); for event in window.events() { match event { SimulatorEvent::MouseButtonUp { .. } => { println!("Click event"); hello.event(HelloEvent::Button); } SimulatorEvent::MouseWheel { scroll_delta, .. } => { hello.event(HelloEvent::Knob(scroll_delta.y)); } SimulatorEvent::Quit => break 'running, _ => {} } } thread::sleep(Duration::from_millis(30)); } }