ssd1322/lib.rs
1//! Driver library for the Solomon Systech SSD1322 dot matrix OLED display driver.
2//!
3//! This driver is intended to work on embedded platforms using any implementation of the
4//! `embedded-hal` trait library.
5//!
6//! Because the SSD1322 supports displays as large as 480x128 @ 4bpp, the primary API uses a
7//! `Region` abstraction to allow writing a stream of pixel data from an iterator onto a
8//! rectangular sub-region of the display area. This avoids the requirement to buffer the entire
9//! display RAM in the host, since such a buffer would consume a colossal (for a μC) 30kiB of RAM.
10//!
11//! To use the driver:
12//!
13//! - Use your platform's `embedded-hal` implementation to obtain the necessary I/Os where your
14//! SSD1322 display is connected. For example, in 4-wire SPI mode, you will need a configured SPI
15//! master device and one GPIO push-pull output pin device.
16//!
17//! - Construct a `DisplayInterface`, for example an `SpiInterface`, which will take ownership of
18//! the I/Os you just obtained.
19//!
20//! - Construct a `Display`, which will take ownership of the `DisplayInterface` along with the
21//! display resolution and offset parameters.
22//!
23//! - Referring to your display module's datasheet, create a `Config` to set the various parameters
24//! in the chip appropriately for the OLEDs in your display module, and send it to the display
25//! with `Display::init`.
26//!
27//! - To draw, call `Display::region` or `Display::overscanned_region` to obtain a region instance
28//! for the rectangular area where you want to write image information. Use the `draw_packed` or
29//! `draw` methods of the region to write image data supplied by an iterator. The region is
30//! intended to be short-lived and will mutably borrow the display, so the compiler will prevent
31//! accidental clashing writes.
32//!
33//! - Other functions of the device, such as sleep mode, vertical pan, and contrast control, are
34//! available via methods on `Display`.
35//!
36//! Example code is available in the `examples` folder.
37
38#![cfg_attr(not(feature = "std"), no_std)]
39
40#[cfg(feature = "std")]
41extern crate core;
42
43pub mod command;
44pub mod config;
45pub mod display;
46pub mod interface;
47
48// Re-exports for primary API.
49pub use crate::command::{consts, ComLayout, ComScanDirection};
50pub use crate::config::Config;
51pub use crate::display::{Display, PixelCoord};
52pub use crate::interface::spi::SpiInterface;