Struct Display

Source
pub struct Display {
    pub width: u8,
    pub height: u8,
    pub dc_pin: OutputPin,
    pub cs_pin: OutputPin,
    pub rst_pin: OutputPin,
    pub bl_pin: OutputPin,
    pub protocol: Protocol,
    pub bus: Spi,
    pub memory: Buffer,
}

Fields§

§width: u8§height: u8§dc_pin: OutputPin§cs_pin: OutputPin§rst_pin: OutputPin§bl_pin: OutputPin§protocol: Protocol§bus: Spi§memory: Buffer

Implementations§

Source§

impl Display

Source

pub fn write_command(&mut self, byte: &[u8]) -> Result<()>

Write a command byte to the device. The byte should be of the type &[u8]. The DC pin is set low to indicate that the byte being written is a command byte.

Source

pub fn write_data(&mut self, byte: &[u8]) -> Result<()>

Write a data byte to the device. The byte should be of the type &[u8]. The DC pin is set high to indicate that the byte being written is a data byte

Source

pub fn spi_write_byte(&mut self, byte: &[u8]) -> Result<()>

Raw SPI write byte function. DO NOT USE. use write_command or write_data instead.

Source

pub fn i2c_write_byte(&self, _byte: &[u8]) -> Result<()>

TODO: Add Support for I2C

Source

pub fn reset(&mut self) -> Result<()>

Reset the display.

Source

pub fn render(&mut self) -> Result<()>

The Graphics buffer is stored in the Display { memory: Vec<u8> } field. The ws_oled_driver::gfx library functions work on the memory field. It writes the pixes onto the memory field. The render function dumps the memory field onto the display.

Examples found in repository?
examples/display_fill.rs (line 10)
5fn main() -> Result<()> {
6    let mut device = Device::new()?;
7    device.initialize_components()?;
8    
9    gfx::fill(&mut device.display, 0xFF);
10    device.display.render()?;
11
12    Ok(())
13}
More examples
Hide additional examples
examples/display_line.rs (line 10)
5fn main() -> Result<()> {
6    let mut device = Device::new()?;
7    device.initialize_components()?;
8    
9    gfx::draw_line(&mut device.display, (0, 0), (127, 63));
10    device.display.render()?;
11
12    Ok(())
13}
Source

pub fn initialize(&mut self) -> Result<()>

Initializes the display device.

Source

pub fn new() -> Result<Self>

Initializes SPI protocol for the device.

Trait Implementations§

Source§

impl Debug for Display

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.