mirror of
https://github.com/Feliix42/ssd1675.git
synced 2024-11-24 03:36:30 +00:00
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:
parent
51e049ae08
commit
6eb63d55a4
4 changed files with 42 additions and 17 deletions
|
@ -53,6 +53,7 @@ pub enum DeepSleepMode {
|
|||
DiscardRAM,
|
||||
}
|
||||
|
||||
/// A command that can be issued to the controller.
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum Command {
|
||||
/// Set the MUX of gate lines, scanning sequence and direction
|
||||
|
@ -211,7 +212,8 @@ macro_rules! pack {
|
|||
}
|
||||
|
||||
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::*;
|
||||
|
||||
let mut buf = [0u8; 4];
|
||||
|
@ -304,7 +306,8 @@ impl Command {
|
|||
}
|
||||
|
||||
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::*;
|
||||
|
||||
let (command, data) = match self {
|
||||
|
|
|
@ -36,6 +36,9 @@ pub struct Builder<'a> {
|
|||
#[derive(Debug)]
|
||||
pub struct BuilderError {}
|
||||
|
||||
/// Display configuration.
|
||||
///
|
||||
/// Passed to Display::new. Use `Builder` to construct a `Config`.
|
||||
pub struct Config<'a> {
|
||||
pub(crate) dummy_line_period: Command,
|
||||
pub(crate) gate_line_width: Command,
|
||||
|
|
|
@ -5,12 +5,23 @@ const RESET_DELAY_MS: u8 = 10;
|
|||
|
||||
const MAX_SPI_SPEED_HZ: u32 = 20_000_000;
|
||||
|
||||
/// Trait implemented by displays to provide implemenation of core functionality.
|
||||
pub trait DisplayInterface {
|
||||
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>;
|
||||
|
||||
/// Send data for a command.
|
||||
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);
|
||||
|
||||
/// Wait for the controller to indicate it is not busy.
|
||||
fn busy_wait(&self);
|
||||
}
|
||||
|
||||
|
|
38
src/lib.rs
38
src/lib.rs
|
@ -13,21 +13,29 @@
|
|||
//! * A [display configuration][Config]
|
||||
//! * 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
|
||||
//! 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
|
||||
//! interface and a Config a Display instance can be created. Optionally the Display can be
|
||||
//! 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
|
||||
//! passing black/white and red buffers.
|
||||
//! 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 promoted to a [GraphicDisplay], which allows it to use the
|
||||
//! 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:
|
||||
//!
|
||||
//! * [reset]
|
||||
//! * [clear]
|
||||
//! * [update]
|
||||
//! * [sleep]
|
||||
//! 1. [reset](display/struct.Display.html#method.reset)
|
||||
//! 1. [clear](graphics/struct.GraphicDisplay.html#method.clear)
|
||||
//! 1. [update](graphics/struct.GraphicDisplay.html#method.update)
|
||||
//! 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;
|
||||
|
||||
|
@ -36,11 +44,11 @@ extern crate embedded_hal as hal;
|
|||
extern crate std;
|
||||
|
||||
mod color;
|
||||
mod command;
|
||||
mod config;
|
||||
mod display;
|
||||
mod graphics;
|
||||
mod interface;
|
||||
pub mod command;
|
||||
pub mod config;
|
||||
pub mod display;
|
||||
pub mod graphics;
|
||||
pub mod interface;
|
||||
|
||||
pub use color::Color;
|
||||
pub use config::Builder;
|
||||
|
|
Loading…
Reference in a new issue