Struct Max7219

Source
pub struct Max7219<SPI> {
    pub spi: SPI,
}
Expand description

A MAX7219 chip.

Currently, this driver does not support daisy-chaining multiple MAX7219 chips.

Fields§

§spi: SPI

Implementations§

Source§

impl<SPI> Max7219<SPI>
where SPI: SpiDevice,

Source

pub async fn power_on(&mut self) -> Result<(), SPI::Error>

Power on the display.

Source

pub async fn power_off(&mut self) -> Result<(), SPI::Error>

Power off the display.

Source

pub async fn clear(&mut self) -> Result<(), SPI::Error>

Clear the display by setting all digits to empty.

Source

pub async fn set_intensity(&mut self, intensity: u8) -> Result<(), SPI::Error>

Set intensity level on the display,from 0x00 (dimmest) to 0x0F (brightest).

Source

pub async fn set_decode_mode( &mut self, mode: DecodeMode, ) -> Result<(), SPI::Error>

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

See DecodeMode for more information.

Source

pub async fn write_digit_bytes( &mut self, digit: u8, value: u8, ) -> Result<(), SPI::Error>

Write a byte to a digit on the display.

A typical 7-segment display has the following layout:

    A
   ---
F |   | B
  | G |
   ---
E |   | C
  | D |
   ---  . DP
Byte76543210
SegmentDPABCDEFG

To display the number 5, for example, the byte 0b0101_1011 would be sent to the display.

Source

pub async fn write_str( &mut self, string: &[u8; 8], dots: u8, ) -> Result<(), SPI::Error>

Write byte string to the display

§Arguments
  • 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)
Source

pub async fn write_integer(&mut self, value: i32) -> Result<(), SPI::Error>

Write a right justified integer with sign.

Source

pub async fn write_hex(&mut self, value: u32) -> Result<(), SPI::Error>

Write a right justified hex formatted integer with sign.

Source

pub async fn write_raw(&mut self, raw: &[u8; 8]) -> Result<(), SPI::Error>

Write a raw value to the display.

Source

pub async fn set_test(&mut self, enable: bool) -> Result<(), SPI::Error>

Enable or disable the display test mode.

Source

pub const fn new(spi: SPI) -> Self

Create a new instance of the MAX7219 driver.

After creating a new instance, you should call the Max7219::init method to initialize the display.

Source

pub async fn set_scan_limit(&mut self, limit: u8) -> Result<(), SPI::Error>

Set the number of digits to scan (display). The value should be between 1 and 8.

Source

pub async fn init(&mut self) -> Result<(), SPI::Error>

Initialize the display with the default settings.

Auto Trait Implementations§

§

impl<SPI> Freeze for Max7219<SPI>
where SPI: Freeze,

§

impl<SPI> RefUnwindSafe for Max7219<SPI>
where SPI: RefUnwindSafe,

§

impl<SPI> Send for Max7219<SPI>
where SPI: Send,

§

impl<SPI> Sync for Max7219<SPI>
where SPI: Sync,

§

impl<SPI> Unpin for Max7219<SPI>
where SPI: Unpin,

§

impl<SPI> UnwindSafe for Max7219<SPI>
where SPI: UnwindSafe,

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.