Struct ht16k33::HT16K33

source ·
pub struct HT16K33<I2C> { /* private fields */ }
Expand description

The HT16K33 state and configuration.

Implementations

Create an HT16K33 driver.

Arguments
  • i2c - The I2C device to communicate with the HT16K33 chip.
  • logger - A logging instance.
Notes

logger = None will log to the slog-stdlog drain. This makes the library effectively work the same as if it was just using log instead of slog.

Examples
// NOTE: `None` is used for the Logger in these examples for convenience,
// in practice using an actual logger is preferred.

extern crate ht16k33;
use ht16k33::i2c_mock::I2cMock;
use ht16k33::HT16K33;

// Create an I2C device.
let mut i2c = I2cMock::new(None);

// The I2C device address.
let address = 0u8;

let mut ht16k33 = HT16K33::new(i2c, address, None);

Initialize the HT16K33.

Examples

let mut ht16k33 = HT16K33::new(i2c, address, None);
ht16k33.initialize()?;

Return the given I2C device, making this device unusable.

Examples

let mut ht16k33 = HT16K33::new(i2c, address, None);
i2c = ht16k33.destroy();

Return the current display buffer.

Examples

let mut ht16k33 = HT16K33::new(i2c, address, None);
let &buffer = ht16k33.display_buffer();

Return the current oscillator state.

Examples

let mut ht16k33 = HT16K33::new(i2c, address, None);
let oscillator = ht16k33.oscillator();

Return the current display state.

Examples

let mut ht16k33 = HT16K33::new(i2c, address, None);
let display = ht16k33.display();

Return the current dimming state.

Examples

let mut ht16k33 = HT16K33::new(i2c, address, None);
let dimming = ht16k33.dimming();

Enable/disable an LED address in the display buffer.

The buffer must be written using write_display_buffer() for the change to be displayed.

Arguments
  • location - The LED location to update.
  • enabled - Set the LED on (true) or off (false).
Examples
use ht16k33::LedLocation;

let mut ht16k33 = HT16K33::new(i2c, address, None);

let led_location = LedLocation::new(0, 0)?;
ht16k33.update_display_buffer(led_location, true);

Clear contents of the display buffer.

The buffer must be written using write_display_buffer() for the change to be displayed.

Examples

let mut ht16k33 = HT16K33::new(i2c, address, None);
ht16k33.clear_display_buffer();

Control the oscillator.

Arguments
  • oscillator - Set the oscillator On/Off.
Examples
use ht16k33::Oscillator;

let mut ht16k33 = HT16K33::new(i2c, address, None);
ht16k33.set_oscillator(Oscillator::ON)?;

Control the display.

Arguments
  • display - Set the display On/Off.
Examples
use ht16k33::Display;

let mut ht16k33 = HT16K33::new(i2c, address, None);
ht16k33.set_display(Display::HALF_HZ)?;

Control the display dimming.

Arguments
  • dimming - Set the dimming brightness.
Examples
use ht16k33::Dimming;

let mut ht16k33 = HT16K33::new(i2c, address, None);
ht16k33.set_dimming(Dimming::from_u8(4)?)?;

Control an LED.

Arguments
  • location - The LED location to update.
  • enabled - Set the LED on (true) or off (false).
Examples
use ht16k33::LedLocation;

let mut ht16k33 = HT16K33::new(i2c, address, None);

let led_location = LedLocation::new(0, 0)?;
ht16k33.set_led(led_location, true)?;

Write the display buffer to the HT16K33 chip.

Examples

let mut ht16k33 = HT16K33::new(i2c, address, None);
ht16k33.write_display_buffer();

Read the display buffer from the HT16K33 chip.

Examples

let mut ht16k33 = HT16K33::new(i2c, address, None);
ht16k33.read_display_buffer();

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.