feat: add image support

This commit is contained in:
chux0519 2019-11-15 19:17:03 +08:00
parent 7224c33523
commit 3846d907cb
2 changed files with 11 additions and 0 deletions

BIN
rust.raw Normal file

Binary file not shown.

View File

@ -1,4 +1,5 @@
use embedded_graphics::fonts::Font6x8; use embedded_graphics::fonts::Font6x8;
use embedded_graphics::image::Image;
use embedded_graphics::pixelcolor::BinaryColor; use embedded_graphics::pixelcolor::BinaryColor;
use embedded_graphics::prelude::*; use embedded_graphics::prelude::*;
use embedded_graphics::primitives::{Circle, Line, Rectangle}; use embedded_graphics::primitives::{Circle, Line, Rectangle};
@ -6,6 +7,8 @@ use embedded_graphics::Drawing;
use linux_embedded_hal::I2cdev; use linux_embedded_hal::I2cdev;
use machine_ip; use machine_ip;
use ssd1306::{mode::GraphicsMode, Builder}; use ssd1306::{mode::GraphicsMode, Builder};
use std::thread::sleep;
use std::time::Duration;
fn main() { fn main() {
let i2c = I2cdev::new("/dev/i2c-1").unwrap(); let i2c = I2cdev::new("/dev/i2c-1").unwrap();
@ -50,6 +53,14 @@ fn main() {
.translate(Point::new(0, 56)) .translate(Point::new(0, 56))
.into_iter(), .into_iter(),
); );
disp.flush().unwrap();
sleep(Duration::from_secs(2));
disp.clear();
let im: Image<BinaryColor> =
Image::new(include_bytes!("../rust.raw"), 64, 64).translate(Point::new(32, 0));
disp.draw(im.into_iter());
disp.flush().unwrap(); disp.flush().unwrap();
} }