run cargo fmt over 4in2 example
parent
bd79ffdbc6
commit
973b1d8982
|
|
@ -1,17 +1,14 @@
|
|||
// the library for the embedded linux device
|
||||
extern crate linux_embedded_hal as lin_hal;
|
||||
use lin_hal::spidev::{self, SpidevOptions};
|
||||
use lin_hal::{Pin, Spidev};
|
||||
use lin_hal::sysfs_gpio::Direction;
|
||||
use lin_hal::Delay;
|
||||
use lin_hal::{Pin, Spidev};
|
||||
|
||||
// the eink library
|
||||
extern crate epd_waveshare;
|
||||
use epd_waveshare::{
|
||||
epd4in2::{
|
||||
EPD4in2,
|
||||
Buffer4in2,
|
||||
},
|
||||
epd4in2::{Buffer4in2, EPD4in2},
|
||||
graphics::{Display, DisplayRotation},
|
||||
prelude::*,
|
||||
};
|
||||
|
|
@ -19,7 +16,7 @@ use epd_waveshare::{
|
|||
// Graphics
|
||||
extern crate embedded_graphics;
|
||||
use embedded_graphics::coord::Coord;
|
||||
use embedded_graphics::fonts::{Font6x8, Font12x16};
|
||||
use embedded_graphics::fonts::{Font12x16, Font6x8};
|
||||
use embedded_graphics::prelude::*;
|
||||
use embedded_graphics::primitives::{Circle, Line};
|
||||
use embedded_graphics::Drawing;
|
||||
|
|
@ -37,7 +34,6 @@ fn main() {
|
|||
}
|
||||
|
||||
fn run() -> Result<(), std::io::Error> {
|
||||
|
||||
// Configure SPI
|
||||
// Settings are taken from
|
||||
let mut spi = Spidev::open("/dev/spidev0.0").expect("spidev directory");
|
||||
|
|
@ -75,8 +71,8 @@ fn run() -> Result<(), std::io::Error> {
|
|||
|
||||
let mut delay = Delay {};
|
||||
|
||||
|
||||
let mut epd4in2 = EPD4in2::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error");
|
||||
let mut epd4in2 =
|
||||
EPD4in2::new(&mut spi, cs, busy, dc, rst, &mut delay).expect("eink initalize error");
|
||||
|
||||
println!("Test all the rotations");
|
||||
let mut buffer = Buffer4in2::default();
|
||||
|
|
@ -117,12 +113,12 @@ fn run() -> Result<(), std::io::Error> {
|
|||
.into_iter(),
|
||||
);
|
||||
|
||||
|
||||
epd4in2.update_frame(&mut spi, &display.buffer()).unwrap();
|
||||
epd4in2.display_frame(&mut spi).expect("display frame new graphics");
|
||||
epd4in2
|
||||
.display_frame(&mut spi)
|
||||
.expect("display frame new graphics");
|
||||
delay.delay_ms(5000u16);
|
||||
|
||||
|
||||
println!("Now test new graphics with default rotation and some special stuff:");
|
||||
display.clear_buffer(Color::White);
|
||||
|
||||
|
|
@ -169,7 +165,6 @@ fn run() -> Result<(), std::io::Error> {
|
|||
.into_iter(),
|
||||
);
|
||||
|
||||
|
||||
// a moving `Hello World!`
|
||||
let limit = 10;
|
||||
for i in 0..limit {
|
||||
|
|
@ -187,12 +182,13 @@ fn run() -> Result<(), std::io::Error> {
|
|||
);
|
||||
|
||||
epd4in2.update_frame(&mut spi, &display.buffer()).unwrap();
|
||||
epd4in2.display_frame(&mut spi).expect("display frame new graphics");
|
||||
epd4in2
|
||||
.display_frame(&mut spi)
|
||||
.expect("display frame new graphics");
|
||||
|
||||
delay.delay_ms(1_000u16);
|
||||
}
|
||||
|
||||
|
||||
println!("Finished tests - going to sleep");
|
||||
epd4in2.sleep(&mut spi)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue