From 0363e8527f9c18949a52cda9e16772f426cff531 Mon Sep 17 00:00:00 2001 From: Chris Date: Wed, 10 Oct 2018 16:22:41 +0200 Subject: [PATCH] Adapted examples to previous commit --- examples/embedded_linux_epd1in54/src/main.rs | 26 ++++++++--------- examples/embedded_linux_epd4in2/src/main.rs | 30 ++++++++++---------- examples/stm32f3discovery/src/main.rs | 26 ++++++++--------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/examples/embedded_linux_epd1in54/src/main.rs b/examples/embedded_linux_epd1in54/src/main.rs index 8754d94..e1969e4 100644 --- a/examples/embedded_linux_epd1in54/src/main.rs +++ b/examples/embedded_linux_epd1in54/src/main.rs @@ -113,40 +113,40 @@ fn run() -> Result<(), std::io::Error> { // Setup of the needed pins is finished here // Now the "real" usage of the eink-waveshare-rs crate begins - let mut epd = EPD1in54::new(spi, cs_pin, busy_in, dc, rst, &mut delay)?; + let mut epd = EPD1in54::new(&mut spi, cs_pin, busy_in, dc, rst, &mut delay)?; // Clear the full screen - epd.clear_frame()?; - epd.display_frame()?; + epd.clear_frame(&mut spi)?; + epd.display_frame(&mut spi)?; // Speeddemo let small_buffer = [Color::Black.get_byte_value(), 16 as u8 / 8 * 16 as u8]; let number_of_runs = 100; for i in 0..number_of_runs { let offset = i * 8 % 150; - epd.update_partial_frame(&small_buffer, 25 + offset, 25 + offset, 16, 16)?; - epd.display_frame()?; + epd.update_partial_frame(&mut spi, &small_buffer, 25 + offset, 25 + offset, 16, 16)?; + epd.display_frame(&mut spi)?; } // Clear the full screen - epd.clear_frame()?; - epd.display_frame()?; + epd.clear_frame(&mut spi)?; + epd.display_frame(&mut spi)?; // Draw some squares - let mut small_buffer = [Color::Black.get_byte_value(), 160 as u8 / 8 * 160 as u8]; - epd.update_partial_frame(&small_buffer, 20, 20, 160, 160)?; + let mut small_buffer = [Color::Black.get_byte_value(), 160 as u8 / 8 * 160 as u8]; + epd.update_partial_frame(&mut spi, &small_buffer, 20, 20, 160, 160)?; small_buffer = [Color::White.get_byte_value(), 80 as u8 / 8 * 80 as u8]; - epd.update_partial_frame(&small_buffer, 60, 60, 80, 80)?; + epd.update_partial_frame(&mut spi, &small_buffer, 60, 60, 80, 80)?; small_buffer = [Color::Black.get_byte_value(), 8]; - epd.update_partial_frame(&small_buffer, 96, 96, 8, 8)?; + epd.update_partial_frame(&mut spi, &small_buffer, 96, 96, 8, 8)?; // Display updated frame - epd.display_frame()?; + epd.display_frame(&mut spi)?; // Set the EPD to sleep - epd.sleep()?; + epd.sleep(&mut spi)?; Ok(()) } diff --git a/examples/embedded_linux_epd4in2/src/main.rs b/examples/embedded_linux_epd4in2/src/main.rs index cf74b42..e45ed0d 100644 --- a/examples/embedded_linux_epd4in2/src/main.rs +++ b/examples/embedded_linux_epd4in2/src/main.rs @@ -108,7 +108,7 @@ fn main() -> Result<(), std::io::Error> { //TODO: wait for Digital::InputPin //fixed currently with the HackInputPin, see further above - let mut epd4in2 = EPD4in2::new(spi, cs, busy_in, dc, rst, &mut delay).expect("eink inialize error"); + let mut epd4in2 = EPD4in2::new(&mut spi, cs, busy_in, dc, rst, &mut delay).expect("eink inialize error"); //let mut buffer = [0u8, epd4in2.get_width() / 8 * epd4in2.get_height()]; let mut buffer = [0u8; 15000]; @@ -129,29 +129,29 @@ fn main() -> Result<(), std::io::Error> { graphics.draw_vertical_line(200, 50, 200, &Color::Black); - epd4in2.update_frame(graphics.get_buffer()).expect("display and transfer error"); - epd4in2.display_frame().expect("Display Frame Error"); + epd4in2.update_frame(&mut spi, graphics.get_buffer())?; + epd4in2.display_frame(&mut spi)?; delay.delay_ms(3000u16); - epd4in2.clear_frame().expect("clear frame error"); + epd4in2.clear_frame(&mut spi)?; //Test fast updating a bit more let mut small_buffer = [0x00; 128]; let mut circle_graphics = Graphics::new(32,32, &mut small_buffer); circle_graphics.draw_circle(16,16, 10, &Color::Black); - epd4in2.update_partial_frame(circle_graphics.get_buffer(), 16,16, 32, 32).expect("Partial Window Error"); - epd4in2.display_frame().expect("Display Frame Error"); + epd4in2.update_partial_frame(&mut spi, circle_graphics.get_buffer(), 16,16, 32, 32)?; + epd4in2.display_frame(&mut spi)?; - epd4in2.update_partial_frame(circle_graphics.get_buffer(), 128,64, 32, 32).expect("Partial Window Error"); - epd4in2.display_frame().expect("Display Frame Error"); + epd4in2.update_partial_frame(&mut spi, circle_graphics.get_buffer(), 128,64, 32, 32)?; + epd4in2.display_frame(&mut spi)?; - epd4in2.update_partial_frame(circle_graphics.get_buffer(), 320,24, 32, 32).expect("Partial Window Error"); - epd4in2.display_frame().expect("Display Frame Error"); + epd4in2.update_partial_frame(&mut spi, circle_graphics.get_buffer(), 320,24, 32, 32)?; + epd4in2.display_frame(&mut spi)?; - epd4in2.update_partial_frame(circle_graphics.get_buffer(), 160,240, 32, 32).expect("Partial Window Error"); - epd4in2.display_frame().expect("Display Frame Error"); + epd4in2.update_partial_frame(&mut spi, circle_graphics.get_buffer(), 160,240, 32, 32)?; + epd4in2.display_frame(&mut spi)?; delay.delay_ms(3000u16); @@ -162,10 +162,10 @@ fn main() -> Result<(), std::io::Error> { graphics.draw_string_8x8(16, 16, "hello", &Color::Black); graphics.draw_char_8x8(250, 250, '#', &Color::Black); graphics.draw_char_8x8(300, 16, '7', &Color::Black); - epd4in2.update_frame(graphics.get_buffer()).expect("display and transfer error"); - epd4in2.display_frame().expect("Display Frame Error"); + epd4in2.update_frame(&mut spi, graphics.get_buffer())?; + epd4in2.display_frame(&mut spi)?; delay.delay_ms(3000u16); - epd4in2.sleep() + epd4in2.sleep(&mut spi) } diff --git a/examples/stm32f3discovery/src/main.rs b/examples/stm32f3discovery/src/main.rs index 1de6e4a..3dd32ac 100644 --- a/examples/stm32f3discovery/src/main.rs +++ b/examples/stm32f3discovery/src/main.rs @@ -119,7 +119,7 @@ fn main() -> ! { let miso = gpioa.pa6.into_af5(&mut gpioa.moder, &mut gpioa.afrl); let mosi = gpioa.pa7.into_af5(&mut gpioa.moder, &mut gpioa.afrl); - let spi = Spi::spi1( + let mut spi = Spi::spi1( p.SPI1, (sck, miso, mosi), SPI_MODE, @@ -130,42 +130,42 @@ fn main() -> ! { // // Setup of the needed pins is finished here // // Now the "real" usage of the eink-waveshare-rs crate begins - let mut epd = EPD1in54::new(spi, cs, busy, dc, rst, &mut delay).unwrap(); + let mut epd = EPD1in54::new(&mut spi, cs, busy, dc, rst, &mut delay).unwrap(); // Clear the full screen - epd.clear_frame().unwrap(); - epd.display_frame().unwrap(); + epd.clear_frame(&mut spi).unwrap(); + epd.display_frame(&mut spi).unwrap(); // Speeddemo let small_buffer = [Color::Black.get_byte_value(), 16 as u8 / 8 * 16 as u8]; let number_of_runs = 100; for i in 0..number_of_runs { let offset = i * 8 % 150; - epd.update_partial_frame(&small_buffer, 25 + offset, 25 + offset, 16, 16).unwrap(); - epd.display_frame().unwrap(); + epd.update_partial_frame(&mut spi, &small_buffer, 25 + offset, 25 + offset, 16, 16).unwrap(); + epd.display_frame(&mut spi).unwrap(); } // Clear the full screen - epd.clear_frame().unwrap(); - epd.display_frame().unwrap(); + epd.clear_frame(&mut spi).unwrap(); + epd.display_frame(&mut spi).unwrap(); // Draw some squares let mut small_buffer = [Color::Black.get_byte_value(), 160 as u8 / 8 * 160 as u8]; - epd.update_partial_frame(&small_buffer, 20, 20, 160, 160).unwrap(); + epd.update_partial_frame(&mut spi, &small_buffer, 20, 20, 160, 160).unwrap(); small_buffer = [Color::White.get_byte_value(), 80 as u8 / 8 * 80 as u8]; - epd.update_partial_frame(&small_buffer, 60, 60, 80, 80).unwrap(); + epd.update_partial_frame(&mut spi, &small_buffer, 60, 60, 80, 80).unwrap(); small_buffer = [Color::Black.get_byte_value(), 8]; - epd.update_partial_frame(&small_buffer, 96, 96, 8, 8).unwrap(); + epd.update_partial_frame(&mut spi, &small_buffer, 96, 96, 8, 8).unwrap(); // Display updated frame - epd.display_frame().unwrap(); + epd.display_frame(&mut spi).unwrap(); // Set the EPD to sleep - epd.sleep().unwrap(); + epd.sleep(&mut spi).unwrap(); loop {} }