Struct led_bargraph::Bargraph

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

The bargraph state.

Implementations§

Create a Bargraph for display.

Arguments
  • device - A connected HT16K33 device that drives the display.
  • 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 in preferred.

extern crate ht16k33;
extern crate led_bargraph;

use ht16k33::i2c_mock::I2cMock;
use led_bargraph::Bargraph;

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

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

let mut bargraph = Bargraph::new(i2c, address, None);

Initialize the Bargraph display & the connected HT16K33 device.

Examples


let mut bargraph = Bargraph::new(i2c, address, None);
bargraph.initialize().unwrap();

Clear the Bargraph display.

Examples

let mut bargraph = Bargraph::new(i2c, address, None);
bargraph.clear().unwrap();

Update the Bargraph display, showing range total values with all values from 0 to value filled.

If value is greater than range, then all bars are filled and will blink; automatic re-scaling of the range does not happen because:

  • The bargraph can only scale to a maximum resolution.
  • Users are already familiar with viewing the current range, and dynamically changing the range makes it hard for users to see what’s happening at a glance.
Arguments
  • value - How many values to fill, starting from 0.
  • range - Total number of values to display.
Examples

let mut bargraph = Bargraph::new(i2c, address, None);
bargraph.update(5, 6, false).unwrap();

Enable/Disable continuous blinking of the Bargraph display.

Arguments
  • enabled - Whether to enabled blinking or not.
Examples

let mut bargraph = Bargraph::new(i2c, address, None);
bargraph.set_blink(true).unwrap();

Show the current bargraph display on-screen.

Examples

let mut bargraph = Bargraph::new(i2c, address, None);
bargraph.show().unwrap();

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.