This library contains a driver for E-Paper Modules with Controller GDE021A1 ((172x72 B/W Pixel via SPI)).
It uses the embedded graphics library for the optional graphics support.
A 2018-edition compatible version (Rust 1.31+) is needed.
Resource Needs
- The GED021A1 ePaper Display is Black/White (4 gray levels per pixel)
- Each Pixel value is encoded by 2 bit.
- Before the ePaper display is refreshed all data is written into RAM. A RAM cache storage of (2 bit per 172 x 72 Pixels equals to) 3096 Bytes is mandatory.
- Besides the RAM only the typical SPI peripherals (clock, CLK pin MOSI pin,) and additional arbitrary GPIO pins (Data/Command, Busy, Reset) are needed.
Usage
For example, the initialize sequence is like (on a Cortex MCU, using the embedded hal crate)
Set the default compile target in e.g .cargo/config file to
[build]
target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
in order to support Cortex-M0.
let dp = take.unwrap;
let cp = take.unwrap;
// Configure the clock.
let mut rcc = dp.RCC.freeze;
// Acquire the GPIOx peripheral.
// This also enables the clock for GPIOx in the RCC register.
let gpioa = dp.GPIOA.split;
let gpiob = dp.GPIOB.split;
// The GPIO's
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;
// The SPI
let mosi = gpiob.pb5;
let clk = gpiob.pb3;
let spi = dp.SPI1.spi;
// the time delay
let mut delay = cp.SYST.delay;
// and finally the display structure
let mut disp = GDE021A1 new;
// initialize the display
disp.init.expect;
Once the display is initialized it can be used using the embedded graphics library like e.g. like
// all pixels turn white
disp.clear;
// draw some fancy stuff and graphics via embedded graphics api
let elem = new
.into_styled;
elem.draw;
let elem = new
.into_styled;
elem.draw;
// refresh the epaper
disp.refresh.expect;
Testing
The embedded target is most likely very different from the host. and pre-configured in your .cargo/config file. However, test (specifically in CI environment run on host)
Thus, tests can savely run by specifying your host target like
cargo test --target=x86_64-unknown-linux-gnu
Interface
Interface | Description |
---|---|
DIN | SPI MOSI |
CLK | SPI SCK |
CS | SPI chip select (Low active)- optional |
DC | Data/Command control pin (High for data, and low for command) |
RST | External reset pin (Low for reset) |
BUSY | Busy state output pin (Low for busy) |