pub struct TM1637Adapter { /* private fields */ }
Expand description

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

Creates a new object to interact via GPIO with a TM1637. Activates the display and set’s the brightness to the highest value.

  • pin_clock_write_fn function to write bit to CLK pin
  • pin_dio_write_fn function to write bit to DIO pin
  • pin_dio_read_fn function to read value from DIO pin
  • bit_delay_fn function that is invoked after a bit has been written to a pin. It depends on your hardware and your GPIO driver. Sometimes 0 is even fine.

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.

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.

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.

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.

Send command that sets the display state on the micro controller.

Clears the display.

Encodes a number from 0 to 9999 on the display.

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.

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.

Encodes a string for the 7-segment display. This uses encode_char for each character.

Trait Implementations

Formats the value using the given formatter. Read more

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.