From 3846d907cbe7ccf26a4422a14ceb7e80f88ffaea Mon Sep 17 00:00:00 2001 From: chux0519 Date: Fri, 15 Nov 2019 19:17:03 +0800 Subject: [PATCH] feat: add image support --- rust.raw | Bin 0 -> 512 bytes src/main.rs | 11 +++++++++++ 2 files changed, 11 insertions(+) create mode 100644 rust.raw diff --git a/rust.raw b/rust.raw new file mode 100644 index 0000000000000000000000000000000000000000..cbb43ec947d8ef4a5f75d39c4f87e190918a76b0 GIT binary patch literal 512 zcmZY6F;2xW3=P`C-R;^L{VH09o98@7z&XSm{3W` zDPd`Gc!Z?9Dpm^9%G1Uf)l|i|V0PcwRNwrNt3POAJ=6#2^wi$AVUJJt?dKkv7T;Mo z;{|bz6KqQhW?4kdx}f&h*Rd~7IB5wpAMZQMhhE~eN2Gt@L_8hmL0s)zrtN>AQkaUx z?}+U`Q7W%!1)7o9j^=JLJ8LfMG-#o)5j|SJ?ud>sB0gF_uh(w5=<{e?{_hPcwinbe P!S5XDI#;^RdCvU@lavb0 literal 0 HcmV?d00001 diff --git a/src/main.rs b/src/main.rs index 313c4a1..e0ae3f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use embedded_graphics::fonts::Font6x8; +use embedded_graphics::image::Image; use embedded_graphics::pixelcolor::BinaryColor; use embedded_graphics::prelude::*; use embedded_graphics::primitives::{Circle, Line, Rectangle}; @@ -6,6 +7,8 @@ use embedded_graphics::Drawing; use linux_embedded_hal::I2cdev; use machine_ip; use ssd1306::{mode::GraphicsMode, Builder}; +use std::thread::sleep; +use std::time::Duration; fn main() { let i2c = I2cdev::new("/dev/i2c-1").unwrap(); @@ -50,6 +53,14 @@ fn main() { .translate(Point::new(0, 56)) .into_iter(), ); + disp.flush().unwrap(); + sleep(Duration::from_secs(2)); + + disp.clear(); + + let im: Image = + Image::new(include_bytes!("../rust.raw"), 64, 64).translate(Point::new(32, 0)); + disp.draw(im.into_iter()); disp.flush().unwrap(); }