fix examples
parent
9ac06ead28
commit
99d328575f
|
|
@ -108,16 +108,16 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
rst.set_value(1).expect("rst Value set to 1");
|
rst.set_value(1).expect("rst Value set to 1");
|
||||||
|
|
||||||
// Configure Delay
|
// Configure Delay
|
||||||
let delay = Delay {};
|
let mut delay = Delay {};
|
||||||
|
|
||||||
|
|
||||||
// Setup of the needed pins is finished here
|
// Setup of the needed pins is finished here
|
||||||
// Now the "real" usage of the eink-waveshare-rs crate begins
|
// Now the "real" usage of the eink-waveshare-rs crate begins
|
||||||
let mut epd = EPD1in54::new(spi, cs_pin, busy_in, dc, rst, delay)?;
|
let mut epd = EPD1in54::new(spi, cs_pin, busy_in, dc, rst, &mut delay)?;
|
||||||
|
|
||||||
// Clear the full screen
|
// Clear the full screen
|
||||||
epd.clear_frame();
|
epd.clear_frame()?;
|
||||||
epd.display_frame();
|
epd.display_frame()?;
|
||||||
|
|
||||||
// Speeddemo
|
// Speeddemo
|
||||||
let small_buffer = [Color::Black.get_byte_value(), 16 as u8 / 8 * 16 as u8];
|
let small_buffer = [Color::Black.get_byte_value(), 16 as u8 / 8 * 16 as u8];
|
||||||
|
|
@ -129,8 +129,8 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the full screen
|
// Clear the full screen
|
||||||
epd.clear_frame();
|
epd.clear_frame()?;
|
||||||
epd.display_frame();
|
epd.display_frame()?;
|
||||||
|
|
||||||
// Draw some squares
|
// Draw some squares
|
||||||
let mut small_buffer = [Color::Black.get_byte_value(), 160 as u8 / 8 * 160 as u8];
|
let mut small_buffer = [Color::Black.get_byte_value(), 160 as u8 / 8 * 160 as u8];
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,10 @@ use lin_hal::Delay;
|
||||||
// from https://github.com/rudihorn/max31865/blob/extra_examples/examples/rpi.rs
|
// from https://github.com/rudihorn/max31865/blob/extra_examples/examples/rpi.rs
|
||||||
// (slightly changed now as OutputPin doesn't provide is_high and is_low anymore)
|
// (slightly changed now as OutputPin doesn't provide is_high and is_low anymore)
|
||||||
extern crate embedded_hal;
|
extern crate embedded_hal;
|
||||||
use embedded_hal::digital::{InputPin};
|
use embedded_hal::{
|
||||||
|
digital::{InputPin},
|
||||||
|
};
|
||||||
|
use embedded_hal::prelude::*;
|
||||||
|
|
||||||
struct HackInputPin<'a> {
|
struct HackInputPin<'a> {
|
||||||
pin: &'a Pin
|
pin: &'a Pin
|
||||||
|
|
@ -59,7 +62,7 @@ impl<'a> InputPin for HackInputPin<'a> {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fn main() {
|
fn main() -> Result<(), std::io::Error> {
|
||||||
|
|
||||||
// Configure SPI
|
// Configure SPI
|
||||||
// Settings are taken from
|
// Settings are taken from
|
||||||
|
|
@ -97,7 +100,7 @@ fn main() {
|
||||||
rst.set_direction(Direction::Out).expect("rst Direction");
|
rst.set_direction(Direction::Out).expect("rst Direction");
|
||||||
rst.set_value(1).expect("rst Value set to 1");
|
rst.set_value(1).expect("rst Value set to 1");
|
||||||
|
|
||||||
let delay = Delay {};
|
let mut delay = Delay {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -105,7 +108,7 @@ fn main() {
|
||||||
|
|
||||||
//TODO: wait for Digital::InputPin
|
//TODO: wait for Digital::InputPin
|
||||||
//fixed currently with the HackInputPin, see further above
|
//fixed currently with the HackInputPin, see further above
|
||||||
let mut epd4in2 = EPD4in2::new(spi, cs, busy_in, dc, rst, delay).expect("eink inialize error");
|
let mut epd4in2 = EPD4in2::new(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, epd4in2.get_width() / 8 * epd4in2.get_height()];
|
||||||
let mut buffer = [0u8; 15000];
|
let mut buffer = [0u8; 15000];
|
||||||
|
|
@ -129,7 +132,7 @@ fn main() {
|
||||||
epd4in2.update_frame(graphics.get_buffer()).expect("display and transfer error");
|
epd4in2.update_frame(graphics.get_buffer()).expect("display and transfer error");
|
||||||
epd4in2.display_frame().expect("Display Frame Error");
|
epd4in2.display_frame().expect("Display Frame Error");
|
||||||
|
|
||||||
epd4in2.delay_ms(3000);
|
delay.delay_ms(3000u16);
|
||||||
|
|
||||||
epd4in2.clear_frame().expect("clear frame error");
|
epd4in2.clear_frame().expect("clear frame error");
|
||||||
|
|
||||||
|
|
@ -150,7 +153,7 @@ fn main() {
|
||||||
epd4in2.update_partial_frame(circle_graphics.get_buffer(), 160,240, 32, 32).expect("Partial Window Error");
|
epd4in2.update_partial_frame(circle_graphics.get_buffer(), 160,240, 32, 32).expect("Partial Window Error");
|
||||||
epd4in2.display_frame().expect("Display Frame Error");
|
epd4in2.display_frame().expect("Display Frame Error");
|
||||||
|
|
||||||
epd4in2.delay_ms(3000);
|
delay.delay_ms(3000u16);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -162,7 +165,7 @@ fn main() {
|
||||||
epd4in2.update_frame(graphics.get_buffer()).expect("display and transfer error");
|
epd4in2.update_frame(graphics.get_buffer()).expect("display and transfer error");
|
||||||
epd4in2.display_frame().expect("Display Frame Error");
|
epd4in2.display_frame().expect("Display Frame Error");
|
||||||
|
|
||||||
epd4in2.delay_ms(3000);
|
delay.delay_ms(3000u16);
|
||||||
|
|
||||||
epd4in2.sleep().expect("sleeping error");
|
epd4in2.sleep()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ fn main() -> ! {
|
||||||
// rst.set_value(1).expect("rst Value set to 1");
|
// rst.set_value(1).expect("rst Value set to 1");
|
||||||
|
|
||||||
// // Configure Delay
|
// // Configure Delay
|
||||||
let delay = Delay::new(cp.SYST, clocks);
|
let mut delay = Delay::new(cp.SYST, clocks);
|
||||||
|
|
||||||
// copied from the l3gd20 example
|
// copied from the l3gd20 example
|
||||||
// The `L3gd20` abstraction exposed by the `f3` crate requires a specific pin configuration to
|
// The `L3gd20` abstraction exposed by the `f3` crate requires a specific pin configuration to
|
||||||
|
|
@ -130,7 +130,7 @@ fn main() -> ! {
|
||||||
|
|
||||||
// // Setup of the needed pins is finished here
|
// // Setup of the needed pins is finished here
|
||||||
// // Now the "real" usage of the eink-waveshare-rs crate begins
|
// // Now the "real" usage of the eink-waveshare-rs crate begins
|
||||||
let mut epd = EPD1in54::new(spi, cs, busy, dc, rst, delay).unwrap();
|
let mut epd = EPD1in54::new(spi, cs, busy, dc, rst, &mut delay).unwrap();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue