mirror of
https://github.com/yuri91/ili9341-rs.git
synced 2024-11-25 08:00:59 +00:00
Support black and white drawing using e_g 0.4.4
This commit is contained in:
parent
12649e377a
commit
303b1da769
1 changed files with 12 additions and 7 deletions
19
src/lib.rs
19
src/lib.rs
|
@ -276,13 +276,13 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "graphics")]
|
|
||||||
use embedded_graphics::Drawing;
|
|
||||||
#[cfg(feature = "graphics")]
|
#[cfg(feature = "graphics")]
|
||||||
use embedded_graphics::drawable;
|
use embedded_graphics::drawable;
|
||||||
|
#[cfg(feature = "graphics")]
|
||||||
|
use embedded_graphics::{drawable::Pixel, pixelcolor::PixelColorU16, Drawing};
|
||||||
|
|
||||||
#[cfg(feature = "graphics")]
|
#[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
|
where
|
||||||
SPI: spi::Transfer<u8, Error = E> + spi::Write<u8, Error = E>,
|
SPI: spi::Transfer<u8, Error = E> + spi::Write<u8, Error = E>,
|
||||||
CS: OutputPin,
|
CS: OutputPin,
|
||||||
|
@ -292,16 +292,21 @@ where
|
||||||
{
|
{
|
||||||
fn draw<T>(&mut self, item_pixels: T)
|
fn draw<T>(&mut self, item_pixels: T)
|
||||||
where
|
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(
|
self.draw_raw(
|
||||||
pos.0 as u16,
|
pos.0 as u16,
|
||||||
pos.1 as u16,
|
pos.1 as u16,
|
||||||
pos.0 as u16,
|
pos.0 as u16,
|
||||||
pos.1 as u16,
|
pos.1 as u16,
|
||||||
if color == 0 { &[0xff,0xff] } else { &[0,0] },
|
if color == PixelColorU16(0) {
|
||||||
).expect("Failed to communicate with device");
|
&[0xff, 0xff]
|
||||||
|
} else {
|
||||||
|
&[0, 0]
|
||||||
|
},
|
||||||
|
)
|
||||||
|
.expect("Failed to communicate with device");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue