[][src]Struct max7219::MAX7219

pub struct MAX7219<CONNECTOR> { /* fields omitted */ }

Handles communication with the MAX7219 chip for segmented displays. Each display can be connected in series with another and controlled via a single connection. The actual connection interface is selected via constructor functions.

Methods

impl<CONNECTOR> MAX7219<CONNECTOR> where
    CONNECTOR: Connector, 
[src]

pub fn power_on(&mut self) -> Result<(), PinError>[src]

Powers on all connected displays

Errors

  • PinError - returned in case there was an error setting a PIN on the device

pub fn power_off(&mut self) -> Result<(), PinError>[src]

Powers off all connected displays

Errors

  • PinError - returned in case there was an error setting a PIN on the device

pub fn clear_display(&mut self, addr: usize) -> Result<(), PinError>[src]

Clears display by settings all digits to empty

Arguments

  • addr - display to address as connected in series (0 -> last)

Errors

  • PinError - returned in case there was an error setting a PIN on the device

pub fn set_intensity(
    &mut self,
    addr: usize,
    intensity: u8
) -> Result<(), PinError>
[src]

Sets intensity level on the display

Arguments

  • addr - display to address as connected in series (0 -> last)
  • intensity - intensity value to set to 0x00 to 0x0F`

Errors

  • PinError - returned in case there was an error setting a PIN on the device

pub fn set_decode_mode(
    &mut self,
    addr: usize,
    mode: DecodeMode
) -> Result<(), PinError>
[src]

Sets decode mode to be used on input sent to the display chip.

Arguments

  • addr - display to address as connected in series (0 -> last)
  • mode - the decode mode to set

Errors

  • PinError - returned in case there was an error setting a PIN on the device

pub fn write_str(
    &mut self,
    addr: usize,
    string: &[u8; 8],
    dots: u8
) -> Result<(), PinError>
[src]

Writes byte string to the display

Arguments

  • addr - display to address as connected in series (0 -> last)
  • string - the byte string to send 8 bytes long. Unknown characters result in question mark.
  • dots - u8 bit array specifying where to put dots in the string (1 = dot, 0 = not)

Errors

  • PinError - returned in case there was an error setting a PIN on the device

pub fn write_bcd(&mut self, addr: usize, bcd: &[u8; 8]) -> Result<(), PinError>[src]

Writes BCD encoded string to the display

Arguments

  • addr - display to address as connected in series (0 -> last)
  • bcd - the bcd encoded string slice consisting of [0-9,-,E,L,H,P] where upper case input for alphabetic characters results in dot being set. Length of string is always 8 bytes, use spaces for blanking.

Errors

  • PinError - returned in case there was an error setting a PIN on the device

pub fn test(&mut self, addr: usize, is_on: bool) -> Result<(), PinError>[src]

Set test mode on/off

Arguments

  • addr - display to address as connected in series (0 -> last)
  • is_on - whether to turn test mode on or off

Errors

  • PinError - returned in case there was an error setting a PIN on the device

impl<DATA, CS, SCK> MAX7219<PinConnector<DATA, CS, SCK>> where
    DATA: OutputPin,
    CS: OutputPin,
    SCK: OutputPin,
    PinError: From<DATA::Error>,
    PinError: From<CS::Error>,
    PinError: From<SCK::Error>, 
[src]

pub fn from_pins(
    displays: usize,
    data: DATA,
    cs: CS,
    sck: SCK
) -> Result<Self, PinError>
[src]

Construct a new MAX7219 driver instance from DATA, CS and SCK pins.

Arguments

  • displays - number of displays connected in series
  • data - the MOSI/DATA PIN used to send data through to the display set to output mode
  • cs - the CS PIN used to LOAD register on the display set to output mode
  • sck - the SCK clock PIN used to drive the clock set to output mode

Errors

  • PinError - returned in case there was an error setting a PIN on the device

impl<SPI> MAX7219<SpiConnector<SPI>> where
    SPI: Write<u8>,
    PinError: From<()>,
    PinError: From<SPI::Error>, 
[src]

pub fn from_spi(displays: usize, spi: SPI) -> Result<Self, PinError>[src]

Construct a new MAX7219 driver instance from pre-existing SPI in full hardware mode. The SPI will control CS (LOAD) line according to it's internal mode set. If you need the CS line to be controlled manually use MAX7219::from_spi_cs

  • NOTE - make sure the SPI is initialized in MODE_0 with max 10 Mhz frequency.

Arguments

  • displays - number of displays connected in series
  • spi - the SPI interface initialized with MOSI, MISO(unused) and CLK

Errors

  • PinError - returned in case there was an error setting a PIN on the device

impl<SPI, CS> MAX7219<SpiConnectorSW<SPI, CS>> where
    SPI: Write<u8>,
    CS: OutputPin,
    PinError: From<()>,
    PinError: From<SPI::Error>,
    PinError: From<CS::Error>, 
[src]

pub fn from_spi_cs(displays: usize, spi: SPI, cs: CS) -> Result<Self, PinError>[src]

Construct a new MAX7219 driver instance from pre-existing SPI and CS pin set to output. This version of the connection uses the CS pin manually to avoid issues with how the CS mode is handled in hardware SPI implementations.

  • NOTE - make sure the SPI is initialized in MODE_0 with max 10 Mhz frequency.

Arguments

  • displays - number of displays connected in series
  • spi - the SPI interface initialized with MOSI, MISO(unused) and CLK
  • cs - the CS PIN used to LOAD register on the display set to output mode

Errors

  • PinError - returned in case there was an error setting a PIN on the device

Auto Trait Implementations

impl<CONNECTOR> Unpin for MAX7219<CONNECTOR> where
    CONNECTOR: Unpin

impl<CONNECTOR> Sync for MAX7219<CONNECTOR> where
    CONNECTOR: Sync

impl<CONNECTOR> Send for MAX7219<CONNECTOR> where
    CONNECTOR: Send

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]