mirror of
https://github.com/yuri91/ili9341-rs.git
synced 2024-11-28 01:00:58 +00:00
Merge pull request #1 from jamwaffles/update-embedded-graphics
Update embedded graphics to version 0.4.7
This commit is contained in:
commit
400080cc5b
2 changed files with 13 additions and 8 deletions
|
@ -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"]
|
||||
|
|
19
src/lib.rs
19
src/lib.rs
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue