Document some more items and make some more public

The newly made public items are so that arbitrary commands can be sent.
This commit is contained in:
Wesley Moore 2018-12-26 14:03:02 +11:00
parent 51e049ae08
commit 6eb63d55a4
No known key found for this signature in database
GPG key ID: BF67766C0BC2D0EE
4 changed files with 42 additions and 17 deletions

View file

@ -53,6 +53,7 @@ pub enum DeepSleepMode {
DiscardRAM, DiscardRAM,
} }
/// A command that can be issued to the controller.
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum Command { pub enum Command {
/// Set the MUX of gate lines, scanning sequence and direction /// Set the MUX of gate lines, scanning sequence and direction
@ -211,7 +212,8 @@ macro_rules! pack {
} }
impl Command { impl Command {
pub(crate) fn execute<I: DisplayInterface>(&self, interface: &mut I) -> Result<(), I::Error> { /// Execute the command, transmitting any associated data as well.
pub fn execute<I: DisplayInterface>(&self, interface: &mut I) -> Result<(), I::Error> {
use self::Command::*; use self::Command::*;
let mut buf = [0u8; 4]; let mut buf = [0u8; 4];
@ -304,7 +306,8 @@ impl Command {
} }
impl<'buf> BufCommand<'buf> { impl<'buf> BufCommand<'buf> {
pub(crate) fn execute<I: DisplayInterface>(&self, interface: &mut I) -> Result<(), I::Error> { /// Execute the command, transmitting the associated buffer as well.
pub fn execute<I: DisplayInterface>(&self, interface: &mut I) -> Result<(), I::Error> {
use self::BufCommand::*; use self::BufCommand::*;
let (command, data) = match self { let (command, data) = match self {

View file

@ -36,6 +36,9 @@ pub struct Builder<'a> {
#[derive(Debug)] #[derive(Debug)]
pub struct BuilderError {} pub struct BuilderError {}
/// Display configuration.
///
/// Passed to Display::new. Use `Builder` to construct a `Config`.
pub struct Config<'a> { pub struct Config<'a> {
pub(crate) dummy_line_period: Command, pub(crate) dummy_line_period: Command,
pub(crate) gate_line_width: Command, pub(crate) gate_line_width: Command,

View file

@ -5,12 +5,23 @@ const RESET_DELAY_MS: u8 = 10;
const MAX_SPI_SPEED_HZ: u32 = 20_000_000; const MAX_SPI_SPEED_HZ: u32 = 20_000_000;
/// Trait implemented by displays to provide implemenation of core functionality.
pub trait DisplayInterface { pub trait DisplayInterface {
type Error; type Error;
/// Send a command to the controller.
///
/// Prefer calling `execute` on a [Commmand](../command/enum.Command.html) over calling this
/// directly.
fn send_command(&mut self, command: u8) -> Result<(), Self::Error>; fn send_command(&mut self, command: u8) -> Result<(), Self::Error>;
/// Send data for a command.
fn send_data(&mut self, data: &[u8]) -> Result<(), Self::Error>; fn send_data(&mut self, data: &[u8]) -> Result<(), Self::Error>;
/// Reset the controller.
fn reset<D: hal::blocking::delay::DelayMs<u8>>(&mut self, delay: &mut D); fn reset<D: hal::blocking::delay::DelayMs<u8>>(&mut self, delay: &mut D);
/// Wait for the controller to indicate it is not busy.
fn busy_wait(&self); fn busy_wait(&self);
} }

View file

@ -13,21 +13,29 @@
//! * A [display configuration][Config] //! * A [display configuration][Config]
//! * A [Display] //! * A [Display]
//! //!
//! The `Interface` captures the details of the hardware connection to the SSD1675 controller. This //! The [Interface] captures the details of the hardware connection to the SSD1675 controller. This
//! includes an SPI device and some GPIO pins. The SSD1675 can control many different displays that //! includes an SPI device and some GPIO pins. The SSD1675 can control many different displays that
//! vary in dimensions, rotation, and driving characteristics. The [Config] captures these details. //! vary in dimensions, rotation, and driving characteristics. The [Config] captures these details.
//! To aid in constructing the `Config` there is a [Builder] interface. Finally when you have an //! To aid in constructing the [Config] there is a [Builder] interface. Finally when you have an
//! interface and a Config a Display instance can be created. Optionally the Display can be //! interface and a [Config] a [Display] instance can be created.
//! promoted to a [GraphicDisplay], which allows it to use the functionality from the //!
//! [embedded-graphics crate]. The plain display only provides the ability to update the display by //! Optionally the [Display] can be promoted to a [GraphicDisplay], which allows it to use the
//! passing black/white and red buffers. //! functionality from the [embedded-graphics crate][embedded-graphics]. The plain display only
//! provides the ability to update the display by passing black/white and red buffers.
//! //!
//! To update the display you will typically follow this flow: //! To update the display you will typically follow this flow:
//! //!
//! * [reset] //! 1. [reset](display/struct.Display.html#method.reset)
//! * [clear] //! 1. [clear](graphics/struct.GraphicDisplay.html#method.clear)
//! * [update] //! 1. [update](graphics/struct.GraphicDisplay.html#method.update)
//! * [sleep] //! 1. [sleep](display/struct.Display.html#method.deep_sleep)
//!
//! [Interface]: interface/struct.Interface.html
//! [Display]: display/struct.Display.html
//! [GraphicDisplay]: display/struct.GraphicDisplay.html
//! [Config]: config/struct.Config.html
//! [Builder]: config/struct.Builder.html
//! [embedded-graphics]: https://crates.io/crates/embedded-graphics
extern crate embedded_hal as hal; extern crate embedded_hal as hal;
@ -36,11 +44,11 @@ extern crate embedded_hal as hal;
extern crate std; extern crate std;
mod color; mod color;
mod command; pub mod command;
mod config; pub mod config;
mod display; pub mod display;
mod graphics; pub mod graphics;
mod interface; pub mod interface;
pub use color::Color; pub use color::Color;
pub use config::Builder; pub use config::Builder;