Merge pull request #1 from jamwaffles/update-embedded-graphics

Update embedded graphics to version 0.4.7
This commit is contained in:
Yuri Iozzelli 2019-05-02 23:26:23 +02:00 committed by GitHub
commit 400080cc5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 8 deletions

View file

@ -13,8 +13,8 @@ repository = "https://github.com/yuri91/ili9341-rs"
embedded-hal = "0.2.1"
[dependencies.embedded-graphics]
version = "0.1.1"
optional = true
version = "0.4.7"
[features]
default = ["graphics"]

View file

@ -276,13 +276,13 @@ where
}
}
#[cfg(feature = "graphics")]
use embedded_graphics::Drawing;
#[cfg(feature = "graphics")]
use embedded_graphics::drawable;
#[cfg(feature = "graphics")]
use embedded_graphics::{drawable::Pixel, pixelcolor::PixelColorU16, Drawing};
#[cfg(feature = "graphics")]
impl<E, SPI, CS, DC, RESET> Drawing for Ili9341<SPI, CS, DC, RESET>
impl<E, SPI, CS, DC, RESET> Drawing<PixelColorU16> for Ili9341<SPI, CS, DC, RESET>
where
SPI: spi::Transfer<u8, Error = E> + spi::Write<u8, Error = E>,
CS: OutputPin,
@ -292,16 +292,21 @@ where
{
fn draw<T>(&mut self, item_pixels: T)
where
T: Iterator<Item = drawable::Pixel>,
T: Iterator<Item = drawable::Pixel<PixelColorU16>>,
{
for (pos, color) in item_pixels {
for Pixel(pos, color) in item_pixels {
self.draw_raw(
pos.0 as u16,
pos.1 as u16,
pos.0 as u16,
pos.1 as u16,
if color == 0 { &[0xff,0xff] } else { &[0,0] },
).expect("Failed to communicate with device");
if color == PixelColorU16(0) {
&[0xff, 0xff]
} else {
&[0, 0]
},
)
.expect("Failed to communicate with device");
}
}
}