[−][src]Struct tm1637_gpio_driver::TM1637Adapter
Adapter between your code and the TM1637 via GPIO interface. You can use the GPIO interface/library that you want. Just provide the corresponding "glue" functions so that this adapter can access GPIO.
Be wise when you choose a value for bit_delay_us
. This delay is important
to ensure that changed signals are actually on the pins. My experience showed
that 100 (µs) is a safe value on the Raspberry Pi.
Implementations
impl TM1637Adapter
[src]
pub fn new(
pin_clock_write_fn: Box<dyn Fn(GpioPinValue)>,
pin_dio_write_fn: Box<dyn Fn(GpioPinValue)>,
pin_dio_read_fn: Box<dyn Fn() -> GpioPinValue>,
bit_delay_fn: Box<dyn Fn()>
) -> TM1637Adapter
[src]
pin_clock_write_fn: Box<dyn Fn(GpioPinValue)>,
pin_dio_write_fn: Box<dyn Fn(GpioPinValue)>,
pin_dio_read_fn: Box<dyn Fn() -> GpioPinValue>,
bit_delay_fn: Box<dyn Fn()>
) -> TM1637Adapter
Creates a new object to interact via GPIO with a TM1637.
pin_clock_write_fn
function to write bit to CLK pinpin_dio_write_fn
function to write bit to DIO pinpin_dio_read_fn
function to read value from DIO pinbit_delay_fn
function that is invoked after a bit has been written to a pin. Probably 1 or even 0 µs are fine. This is just to be sure. It depends on your hardware and your GPIO driver.
pub fn set_display_state(&mut self, ds: DisplayState)
[src]
Sets the display state. The display state is the 3rd bit of the "display control"-command. This setting is not committed until a write operation has been made.
pub fn set_brightness(&mut self, brightness: Brightness)
[src]
Sets the brightness of the screen. The brightness are the lower 3 bits of the "display control"-command. This setting is not committed until a write operation has been made.
pub fn write_segments_raw(&self, segments: &[u8], pos: u8)
[src]
Writes all raw segments data beginning at the position into the display registers. It uses auto increment internally to write into all further registers. This functions does an internal check so that not more than 6 registers can be addressed/written.
segments
Raw data describing the bits of the 7 segment display.n
Length of segments array.pos
The start position of the display register. While bytes are written, address is adjusted internally via auto increment. Usually this is 0, if you want to write data to all 7 segment displays.
pub fn write_segment_raw(&self, segments: u8, position: u8)
[src]
This uses fixed address mode (see data sheet) internally to write data to a specific position of the display. Position is 0, 1, 2, or 3.
pub fn write_display_state(&self)
[src]
Send command that sets the display state on the micro controller.
pub fn clear(&self)
[src]
Clears the display.
pub fn encode_number(num: u16) -> [u8; 4]
[src]
Encodes a number from 0 to 9999 on the display.
pub fn encode_digit(digit: u8) -> u8
[src]
Encodes a number/digit from 0 to 9 to it's bit representation on the display. This is not the char (ASCII) representation. It's a number/integer.
pub fn encode_char(c: char) -> u8
[src]
Encodes a char for the 7-segment display. Unknown chars will be a zero byte (space).
Uses mappings::UpCharBits
and mappings::LoCharBits
for the chars. Since there is
no representation for every char in each case (lower, upper) there will be an replacement
for lowercase charts by their uppercase counterpart and vice versa.
pub fn encode_string(str: &str) -> Vec<u8>
[src]
Encodes a string for the 7-segment display. This uses
encode_char
for each character.
Auto Trait Implementations
impl !RefUnwindSafe for TM1637Adapter
impl !Send for TM1637Adapter
impl !Sync for TM1637Adapter
impl Unpin for TM1637Adapter
impl !UnwindSafe for TM1637Adapter
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,