run cargo fmt over all examples
parent
973b1d8982
commit
559b0efdae
|
|
@ -1,17 +1,14 @@
|
||||||
// the library for the embedded linux device
|
// the library for the embedded linux device
|
||||||
extern crate linux_embedded_hal as lin_hal;
|
extern crate linux_embedded_hal as lin_hal;
|
||||||
use lin_hal::spidev::{self, SpidevOptions};
|
use lin_hal::spidev::{self, SpidevOptions};
|
||||||
use lin_hal::{Pin, Spidev};
|
|
||||||
use lin_hal::sysfs_gpio::Direction;
|
use lin_hal::sysfs_gpio::Direction;
|
||||||
use lin_hal::Delay;
|
use lin_hal::Delay;
|
||||||
|
use lin_hal::{Pin, Spidev};
|
||||||
|
|
||||||
// the eink library
|
// the eink library
|
||||||
extern crate epd_waveshare;
|
extern crate epd_waveshare;
|
||||||
use epd_waveshare::{
|
use epd_waveshare::{
|
||||||
epd1in54::{
|
epd1in54::{Buffer1in54, EPD1in54},
|
||||||
EPD1in54,
|
|
||||||
Buffer1in54,
|
|
||||||
},
|
|
||||||
graphics::{Display, DisplayRotation},
|
graphics::{Display, DisplayRotation},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
@ -19,7 +16,7 @@ use epd_waveshare::{
|
||||||
// Graphics
|
// Graphics
|
||||||
extern crate embedded_graphics;
|
extern crate embedded_graphics;
|
||||||
use embedded_graphics::coord::Coord;
|
use embedded_graphics::coord::Coord;
|
||||||
use embedded_graphics::fonts::{Font6x8};
|
use embedded_graphics::fonts::Font6x8;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
//use embedded_graphics::primitives::{Circle, Line};
|
//use embedded_graphics::primitives::{Circle, Line};
|
||||||
use embedded_graphics::Drawing;
|
use embedded_graphics::Drawing;
|
||||||
|
|
@ -51,7 +48,9 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
let cs_pin = Pin::new(26); //BCM7 CE0
|
let cs_pin = Pin::new(26); //BCM7 CE0
|
||||||
cs_pin.export().expect("cs_pin export");
|
cs_pin.export().expect("cs_pin export");
|
||||||
while !cs_pin.is_exported() {}
|
while !cs_pin.is_exported() {}
|
||||||
cs_pin.set_direction(Direction::Out).expect("cs_pin Direction");
|
cs_pin
|
||||||
|
.set_direction(Direction::Out)
|
||||||
|
.expect("cs_pin Direction");
|
||||||
cs_pin.set_value(1).expect("cs_pin Value set to 1");
|
cs_pin.set_value(1).expect("cs_pin Value set to 1");
|
||||||
|
|
||||||
// Configure Busy Input Pin
|
// Configure Busy Input Pin
|
||||||
|
|
@ -78,7 +77,6 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
// Configure Delay
|
// Configure Delay
|
||||||
let mut 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(&mut spi, cs_pin, busy, dc, rst, &mut delay)?;
|
let mut epd = EPD1in54::new(&mut spi, cs_pin, busy, dc, rst, &mut delay)?;
|
||||||
|
|
@ -128,12 +126,14 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
|
|
||||||
// Display updated frame
|
// Display updated frame
|
||||||
epd.update_frame(&mut spi, &display.buffer()).unwrap();
|
epd.update_frame(&mut spi, &display.buffer()).unwrap();
|
||||||
epd.display_frame(&mut spi).expect("display frame new graphics");
|
epd.display_frame(&mut spi)
|
||||||
|
.expect("display frame new graphics");
|
||||||
delay.delay_ms(5000u16);
|
delay.delay_ms(5000u16);
|
||||||
|
|
||||||
// a quickly moving `Hello World!`
|
// a quickly moving `Hello World!`
|
||||||
display.set_rotation(DisplayRotation::Rotate0);
|
display.set_rotation(DisplayRotation::Rotate0);
|
||||||
epd.set_lut(&mut spi, Some(RefreshLUT::QUICK)).expect("SET LUT QUICK error");
|
epd.set_lut(&mut spi, Some(RefreshLUT::QUICK))
|
||||||
|
.expect("SET LUT QUICK error");
|
||||||
let limit = 20;
|
let limit = 20;
|
||||||
for i in 0..limit {
|
for i in 0..limit {
|
||||||
println!("Moving Hello World. Loop {} from {}", (i + 1), limit);
|
println!("Moving Hello World. Loop {} from {}", (i + 1), limit);
|
||||||
|
|
@ -150,7 +150,8 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
);
|
);
|
||||||
|
|
||||||
epd.update_frame(&mut spi, &display.buffer()).unwrap();
|
epd.update_frame(&mut spi, &display.buffer()).unwrap();
|
||||||
epd.display_frame(&mut spi).expect("display frame new graphics");
|
epd.display_frame(&mut spi)
|
||||||
|
.expect("display frame new graphics");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the EPD to sleep
|
// Set the EPD to sleep
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,14 @@
|
||||||
// the library for the embedded linux device
|
// the library for the embedded linux device
|
||||||
extern crate linux_embedded_hal as lin_hal;
|
extern crate linux_embedded_hal as lin_hal;
|
||||||
use lin_hal::spidev::{self, SpidevOptions};
|
use lin_hal::spidev::{self, SpidevOptions};
|
||||||
use lin_hal::{Pin, Spidev};
|
|
||||||
use lin_hal::sysfs_gpio::Direction;
|
use lin_hal::sysfs_gpio::Direction;
|
||||||
use lin_hal::Delay;
|
use lin_hal::Delay;
|
||||||
|
use lin_hal::{Pin, Spidev};
|
||||||
|
|
||||||
// the eink library
|
// the eink library
|
||||||
extern crate epd_waveshare;
|
extern crate epd_waveshare;
|
||||||
use epd_waveshare::{
|
use epd_waveshare::{
|
||||||
epd2in9::{
|
epd2in9::{Buffer2in9, EPD2in9},
|
||||||
EPD2in9,
|
|
||||||
Buffer2in9,
|
|
||||||
},
|
|
||||||
graphics::{Display, DisplayRotation},
|
graphics::{Display, DisplayRotation},
|
||||||
prelude::*,
|
prelude::*,
|
||||||
};
|
};
|
||||||
|
|
@ -19,7 +16,7 @@ use epd_waveshare::{
|
||||||
// Graphics
|
// Graphics
|
||||||
extern crate embedded_graphics;
|
extern crate embedded_graphics;
|
||||||
use embedded_graphics::coord::Coord;
|
use embedded_graphics::coord::Coord;
|
||||||
use embedded_graphics::fonts::{Font6x8};
|
use embedded_graphics::fonts::Font6x8;
|
||||||
use embedded_graphics::prelude::*;
|
use embedded_graphics::prelude::*;
|
||||||
//use embedded_graphics::primitives::{Circle, Line};
|
//use embedded_graphics::primitives::{Circle, Line};
|
||||||
use embedded_graphics::Drawing;
|
use embedded_graphics::Drawing;
|
||||||
|
|
@ -52,7 +49,9 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
let cs_pin = Pin::new(26); //BCM7 CE0
|
let cs_pin = Pin::new(26); //BCM7 CE0
|
||||||
cs_pin.export().expect("cs_pin export");
|
cs_pin.export().expect("cs_pin export");
|
||||||
while !cs_pin.is_exported() {}
|
while !cs_pin.is_exported() {}
|
||||||
cs_pin.set_direction(Direction::Out).expect("cs_pin Direction");
|
cs_pin
|
||||||
|
.set_direction(Direction::Out)
|
||||||
|
.expect("cs_pin Direction");
|
||||||
cs_pin.set_value(1).expect("cs_pin Value set to 1");
|
cs_pin.set_value(1).expect("cs_pin Value set to 1");
|
||||||
|
|
||||||
// Configure Busy Input Pin
|
// Configure Busy Input Pin
|
||||||
|
|
@ -79,7 +78,6 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
// Configure Delay
|
// Configure Delay
|
||||||
let mut 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 = EPD2in9::new(&mut spi, cs_pin, busy, dc, rst, &mut delay)?;
|
let mut epd = EPD2in9::new(&mut spi, cs_pin, busy, dc, rst, &mut delay)?;
|
||||||
|
|
@ -132,12 +130,14 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
|
|
||||||
// Display updated frame
|
// Display updated frame
|
||||||
epd.update_frame(&mut spi, &display.buffer()).unwrap();
|
epd.update_frame(&mut spi, &display.buffer()).unwrap();
|
||||||
epd.display_frame(&mut spi).expect("display frame new graphics");
|
epd.display_frame(&mut spi)
|
||||||
|
.expect("display frame new graphics");
|
||||||
delay.delay_ms(5000u16);
|
delay.delay_ms(5000u16);
|
||||||
|
|
||||||
// a quickly moving `Hello World!`
|
// a quickly moving `Hello World!`
|
||||||
display.set_rotation(DisplayRotation::Rotate0);
|
display.set_rotation(DisplayRotation::Rotate0);
|
||||||
epd.set_lut(&mut spi, Some(RefreshLUT::QUICK)).expect("SET LUT QUICK error");
|
epd.set_lut(&mut spi, Some(RefreshLUT::QUICK))
|
||||||
|
.expect("SET LUT QUICK error");
|
||||||
let limit = 20;
|
let limit = 20;
|
||||||
for i in 0..limit {
|
for i in 0..limit {
|
||||||
println!("Moving Hello World. Loop {} from {}", (i + 1), limit);
|
println!("Moving Hello World. Loop {} from {}", (i + 1), limit);
|
||||||
|
|
@ -154,7 +154,8 @@ fn run() -> Result<(), std::io::Error> {
|
||||||
);
|
);
|
||||||
|
|
||||||
epd.update_frame(&mut spi, &display.buffer()).unwrap();
|
epd.update_frame(&mut spi, &display.buffer()).unwrap();
|
||||||
epd.display_frame(&mut spi).expect("display frame new graphics");
|
epd.display_frame(&mut spi)
|
||||||
|
.expect("display frame new graphics");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the EPD to sleep
|
// Set the EPD to sleep
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue