[−][src]Crate epd_gde021a1
A simple Driver for the DGE021A1 ePaper Controller (172x72 B/W via SPI)
- Built using
embedded-hal
traits. - Graphics support is added through
embedded-graphics
crate
Examples
One full example can be found in the examples/ folder
Firstly initialize the display ...
use stm32l0xx_hal::{pac, gpio::*, prelude::*, spi::*, rcc::{Config,RccExt}}; use epd_gde021A1::GDE021A1; let dp = pac::Peripherals::take().unwrap(); let cp = cortex_m::Peripherals::take().unwrap(); // Configure the clock let mut rcc = dp.RCC.freeze(Config::hsi16()); // Acquire the GPIOx peripheral. // This also enables the clock for GPIOx in the RCC register. let gpioa = dp.GPIOA.split(&mut rcc); let gpiob = dp.GPIOB.split(&mut rcc); // Configure the pins let chip_sel = gpioa.pa15.into_push_pull_output(); let data_cmd = gpiob.pb11.into_push_pull_output(); let reset = gpiob.pb2.into_push_pull_output(); let busy = gpiob.pb8.into_pull_up_input(); // Configure the SPI let mosi = gpiob.pb5; let clk = gpiob.pb3; let spi = dp.SPI1.spi((clk, NoMiso, mosi), MODE_0, 1_000_000.hz(), &mut rcc); // Get the time delay let mut delay = cp.SYST.delay(rcc.clocks); // Finally initialize the display structure let mut disp = GDE021A1::new(spi, reset, Some(chip_sel), data_cmd, busy); disp.init(&mut delay).expect("could not init display");
Secondly use the created display by writing to the RAM buffer and finally refreshing the chip.
extern crate embedded_graphics; use embedded_graphics::{ pixelcolor::BinaryColor, style::{PrimitiveStyle, TextStyle}, primitives::Circle, fonts::{Font6x8, Text}, prelude::*, }; disp.clear(); // All pixels turn white - RAM buffer only // Draw a circle on the RAM buffer let elem = Circle::new(Point::new(140, 36), 25) .into_styled(PrimitiveStyle::with_fill(BinaryColor::On)); elem.draw(&mut disp); // Draw inside the RAM buffer // Draw some text let elem = Text::new("Hello Rust!", Point::new(1, 8)) .into_styled(TextStyle::new(Font6x8, BinaryColor::On)); elem.draw(&mut disp); // Draw inside the RAM buffer // ePaper display needs to be refreshed - write the RAM buffer to the chip disp.refresh(&mut delay).expect("could not flush display");
Features
graphics
(enabled by default)
Enable the graphics
feature in Cargo.toml
to get access to features in the
embedded-graphics
crate. This adds the .draw()
method to the GDE021A1
struct which
accepts any embedded-graphics
compatible item.
Structs
GDE021A1 | The ePaper GDE021A1 Driver data structure |
Enums
Color | The ePaper supports four grey levels per pixel as color |
Error | Errors that can occur while using the display |