Merge pull request #4 from dflemstr/master

Upgrade to embedded-graphics 0.6.0-alpha.2
This commit is contained in:
Yuri Iozzelli 2019-12-18 06:31:05 +01:00 committed by GitHub
commit 490ab33d13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 16 deletions

View file

@ -14,7 +14,7 @@ embedded-hal = "0.2.2"
[dependencies.embedded-graphics] [dependencies.embedded-graphics]
optional = true optional = true
version = "0.4.7" version = "0.6.0-alpha.2"
[features] [features]
default = ["graphics"] default = ["graphics"]

View file

@ -5,13 +5,13 @@ extern crate embedded_hal as hal;
#[cfg(feature = "graphics")] #[cfg(feature = "graphics")]
extern crate embedded_graphics; extern crate embedded_graphics;
use hal::blocking::spi;
use hal::blocking::delay::DelayMs; use hal::blocking::delay::DelayMs;
use hal::spi::{Mode, Phase, Polarity}; use hal::blocking::spi;
use hal::digital::OutputPin; use hal::digital::OutputPin;
use hal::spi::{Mode, Phase, Polarity};
use core::iter::IntoIterator;
use core::fmt::Debug; use core::fmt::Debug;
use core::iter::IntoIterator;
/// SPI mode /// SPI mode
pub const MODE: Mode = Mode { pub const MODE: Mode = Mode {
@ -279,10 +279,10 @@ where
#[cfg(feature = "graphics")] #[cfg(feature = "graphics")]
use embedded_graphics::drawable; use embedded_graphics::drawable;
#[cfg(feature = "graphics")] #[cfg(feature = "graphics")]
use embedded_graphics::{drawable::Pixel, pixelcolor::PixelColorU16, Drawing}; use embedded_graphics::{drawable::Pixel, pixelcolor::Rgb565, Drawing};
#[cfg(feature = "graphics")] #[cfg(feature = "graphics")]
impl<E, SPI, CS, DC, RESET> Drawing<PixelColorU16> for Ili9341<SPI, CS, DC, RESET> impl<E, SPI, CS, DC, RESET> Drawing<Rgb565> 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,19 +292,19 @@ where
{ {
fn draw<T>(&mut self, item_pixels: T) fn draw<T>(&mut self, item_pixels: T)
where where
T: Iterator<Item = drawable::Pixel<PixelColorU16>>, T: IntoIterator<Item = drawable::Pixel<Rgb565>>,
{ {
for Pixel(pos, color) in item_pixels { for Pixel(pos, color) in item_pixels {
use embedded_graphics::pixelcolor::raw::RawData;
self.draw_raw( self.draw_raw(
pos.0 as u16, pos.x as u16,
pos.1 as u16, pos.y as u16,
pos.0 as u16, pos.x as u16,
pos.1 as u16, pos.y as u16,
if color == PixelColorU16(0) { &embedded_graphics::pixelcolor::raw::RawU16::from(color)
&[0xff, 0xff] .into_inner()
} else { .to_le_bytes(),
&[0, 0]
},
) )
.expect("Failed to communicate with device"); .expect("Failed to communicate with device");
} }