diff --git a/Cargo.toml b/Cargo.toml index e32a910..57ce53f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ embedded-hal = "0.2.2" [dependencies.embedded-graphics] optional = true -version = "0.4.7" +version = "0.6.0-alpha.2" [features] default = ["graphics"] diff --git a/src/lib.rs b/src/lib.rs index 4277436..c1aac72 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,13 +5,13 @@ extern crate embedded_hal as hal; #[cfg(feature = "graphics")] extern crate embedded_graphics; -use hal::blocking::spi; use hal::blocking::delay::DelayMs; -use hal::spi::{Mode, Phase, Polarity}; +use hal::blocking::spi; use hal::digital::OutputPin; +use hal::spi::{Mode, Phase, Polarity}; -use core::iter::IntoIterator; use core::fmt::Debug; +use core::iter::IntoIterator; /// SPI mode pub const MODE: Mode = Mode { @@ -279,10 +279,10 @@ where #[cfg(feature = "graphics")] use embedded_graphics::drawable; #[cfg(feature = "graphics")] -use embedded_graphics::{drawable::Pixel, pixelcolor::PixelColorU16, Drawing}; +use embedded_graphics::{drawable::Pixel, pixelcolor::Rgb565, Drawing}; #[cfg(feature = "graphics")] -impl Drawing for Ili9341 +impl Drawing for Ili9341 where SPI: spi::Transfer + spi::Write, CS: OutputPin, @@ -292,19 +292,19 @@ where { fn draw(&mut self, item_pixels: T) where - T: Iterator>, + T: IntoIterator>, { for Pixel(pos, color) in item_pixels { + use embedded_graphics::pixelcolor::raw::RawData; + self.draw_raw( - pos.0 as u16, - pos.1 as u16, - pos.0 as u16, - pos.1 as u16, - if color == PixelColorU16(0) { - &[0xff, 0xff] - } else { - &[0, 0] - }, + pos.x as u16, + pos.y as u16, + pos.x as u16, + pos.y as u16, + &embedded_graphics::pixelcolor::raw::RawU16::from(color) + .into_inner() + .to_le_bytes(), ) .expect("Failed to communicate with device"); }