pub trait SevenSegment<E> {
// Required methods
fn update_buffer_with_digit(&mut self, index: Index, value: u8);
fn update_buffer_with_dot(&mut self, index: Index, dot_on: bool);
fn update_buffer_with_colon(&mut self, colon_on: bool);
fn update_buffer_with_char(
&mut self,
index: Index,
value: AsciiChar,
) -> Result<(), Error>;
fn update_buffer_with_float(
&mut self,
index: Index,
value: f32,
fractional_digits: u8,
base: u8,
) -> Result<(), Error>;
}
Expand description
Trait enabling using the Adafruit 7-segment LED numeric Backpack.
Required Methods§
Sourcefn update_buffer_with_digit(&mut self, index: Index, value: u8)
fn update_buffer_with_digit(&mut self, index: Index, value: u8)
Update the buffer with a digit value (0 to F) at the specified index.
Sourcefn update_buffer_with_dot(&mut self, index: Index, dot_on: bool)
fn update_buffer_with_dot(&mut self, index: Index, dot_on: bool)
Update the buffer to turn the . on or off at the specified index.
Sourcefn update_buffer_with_colon(&mut self, colon_on: bool)
fn update_buffer_with_colon(&mut self, colon_on: bool)
Update the buffer to turn the : on or off.
Implementations on Foreign Types§
Source§impl<I2C, E> SevenSegment<E> for HT16K33<I2C>
impl<I2C, E> SevenSegment<E> for HT16K33<I2C>
Source§fn update_buffer_with_digit(&mut self, index: Index, value: u8)
fn update_buffer_with_digit(&mut self, index: Index, value: u8)
Update the buffer with a hex digit value (0x00 to 0x0F) at the specified index
§Arguments
index
- Digit index.value
- Value 0x00 to 0x0F.
§Examples
use ht16k33::i2c_mock::I2cMock;
use ht16k33::HT16K33;
use adafruit_7segment::{SevenSegment, Index};
// Create an I2C device.
let mut i2c = I2cMock::new();
// The I2C device address.
const DISP_I2C_ADDR: u8 = 112;
let mut ht16k33 = HT16K33::new(i2c, DISP_I2C_ADDR);
// Set first digit to 9.
ht16k33.update_buffer_with_digit(Index::One, 9);
Source§fn update_buffer_with_dot(&mut self, index: Index, dot_on: bool)
fn update_buffer_with_dot(&mut self, index: Index, dot_on: bool)
Update the buffer to turn the . on or off at the specified index
§Arguments
index
- Digit index.dot_on
- Enable or disable the dot.
§Examples
use ht16k33::i2c_mock::I2cMock;
use ht16k33::HT16K33;
use adafruit_7segment::{SevenSegment, Index};
// Create an I2C device.
let mut i2c = I2cMock::new();
// The I2C device address.
const DISP_I2C_ADDR: u8 = 112;
let mut ht16k33 = HT16K33::new(i2c, DISP_I2C_ADDR);
// Enable dot for first digit.
ht16k33.update_buffer_with_dot(Index::One, true);
Source§fn update_buffer_with_colon(&mut self, colon_on: bool)
fn update_buffer_with_colon(&mut self, colon_on: bool)
Update the buffer to turn the : on or off.
§Arguments
colon_on
- Enable or disable the colon.
§Examples
use ht16k33::i2c_mock::I2cMock;
use ht16k33::HT16K33;
use adafruit_7segment::{SevenSegment, Index};
// Create an I2C device.
let mut i2c = I2cMock::new();
// The I2C device address.
const DISP_I2C_ADDR: u8 = 112;
let mut ht16k33 = HT16K33::new(i2c, DISP_I2C_ADDR);
// Enable the colon.
ht16k33.update_buffer_with_colon(true);
Source§fn update_buffer_with_char(
&mut self,
index: Index,
value: AsciiChar,
) -> Result<(), Error>
fn update_buffer_with_char( &mut self, index: Index, value: AsciiChar, ) -> Result<(), Error>
Update the buffer with an ascii character at the specified index.
§Arguments
index
- Digit index.value
- Ascii character.
§Examples
use ht16k33::i2c_mock::I2cMock;
use ht16k33::HT16K33;
use adafruit_7segment::{SevenSegment, Index, AsciiChar};
// Create an I2C device.
let mut i2c = I2cMock::new();
// The I2C device address.
const DISP_I2C_ADDR: u8 = 112;
let mut ht16k33 = HT16K33::new(i2c, DISP_I2C_ADDR);
// Set first digit to 'c'.
ht16k33.update_buffer_with_char(Index::One, AsciiChar::new('c')).expect("Failed to encode char to buffer!");
Source§fn update_buffer_with_float(
&mut self,
index: Index,
value: f32,
fractional_digits: u8,
base: u8,
) -> Result<(), Error>
fn update_buffer_with_float( &mut self, index: Index, value: f32, fractional_digits: u8, base: u8, ) -> Result<(), Error>
Update the buffer with a formatted float not starting before the specified index The logic for this is copied mostly from from the adafruit library. Only difference is this allows the start index to be > 0
§Arguments
index
- Digit index.value
- float value.fractional_digits
- Number of fractional digits.base
- Base to use.
§Examples
use ht16k33::i2c_mock::I2cMock;
use ht16k33::HT16K33;
use adafruit_7segment::{SevenSegment, Index};
// Create an I2C device.
let mut i2c = I2cMock::new();
// The I2C device address.
const DISP_I2C_ADDR: u8 = 112;
let mut ht16k33 = HT16K33::new(i2c, DISP_I2C_ADDR);
// Write 9.9 from pos 2
ht16k33.update_buffer_with_float(Index::Two, 9.9, 1, 10);