View Source TM1638 (tm1638 v0.1.0)

Link to this section Summary

Functions

Clear the display Turn off every led

Example: TM1638.display_segment(tm,1, "") -> set the i-th 7-segment display (and all the following, according to the length of value1) all the 7-segment displays after the #i are filled by the characters in value1 this could be one-character string (so 7-segment #i is set to that character) or a longer string, and the following 7-segment displays are modified accordingly

Displays text starting from the correct position

Receive the bytes_count from the board

Get the data buttons the four octets read on rpi ver B it takes around 16ms to get the whole 4 bits

Set single led to on or off the leds are on the bit 0 of the odd addresses (led_0 on address 1, led_1 on address 3)

Set Leds values accepts an integer in range 0..255 and sets all leds according to the bits in integer

Send a byte (STROBE must be Low)

Send a command

Send a data at address

Set the data modes :param wr_mode: read_mode (read the key scan) or write_mode (write data) :param addr_mode: incr_addr (automatic address increased) or fixed_addr

Turn off (physically) the leds

Turn on the display and set the brightness The pulse width used is set to

Link to this section Types

@type bit() :: 1 | 0
@type brightness() :: 1..7
@type pin() :: non_neg_integer()
@type t() :: map()

Link to this section Functions

@spec clear_display(t()) :: t()

Clear the display Turn off every led

@spec clock_high(t()) :: t()
@spec clock_low(t()) :: t()
@spec cs_disable(t()) :: t()
@spec cs_enable(t()) :: t()
@spec data_high(t()) :: t()
@spec data_low(t()) :: t()
@spec data_set_to(t(), bit()) :: t()
Link to this function

display_moving_text(tm, text, speed \\ 500)

View Source
@spec display_moving_text(t(), String.t(), integer()) :: t()
Link to this function

display_segment(tm, index, value)

View Source
@spec display_segment(t(), integer(), byte()) :: t()

Example: TM1638.display_segment(tm,1, "") -> set the i-th 7-segment display (and all the following, according to the length of value1) all the 7-segment displays after the #i are filled by the characters in value1 this could be one-character string (so 7-segment #i is set to that character) or a longer string, and the following 7-segment displays are modified accordingly

Link to this function

display_text(tm, text, start \\ 0)

View Source
@spec display_text(t(), String.t(), integer()) :: t()
@spec display_text(t(), [String.t()], integer()) :: t()

Displays text starting from the correct position

Link to this function

get_bytes(tm, bytes_count \\ 4)

View Source
@spec get_bytes(t(), integer()) :: t()

Receive the bytes_count from the board

@spec get_data(t()) :: t()

Get the data buttons the four octets read on rpi ver B it takes around 16ms to get the whole 4 bits

@spec init(list()) :: {:ok, t()}
Link to this function

init(dio, clk, stb, brightness \\ 3)

View Source
@spec init(pin(), pin(), pin(), integer()) :: t()
@spec init_display(t()) :: t()
@spec led(t(), 0..7, bit()) :: t()

Set single led to on or off the leds are on the bit 0 of the odd addresses (led_0 on address 1, led_1 on address 3)

@spec leds(t(), byte()) :: t()

Set Leds values accepts an integer in range 0..255 and sets all leds according to the bits in integer

Link to this function

send_byte(tm, data, counter \\ 8)

View Source
@spec send_byte(t(), byte(), integer()) :: t()

Send a byte (STROBE must be Low)

Sending a bit from a byte consists of setting the STROBE to low Then setting to CLOCK to low, sending the bit via dio and setting the clock back to HIGH..

@spec send_command(t(), byte()) :: t()

Send a command

Link to this function

send_data(tm, address, data)

View Source
@spec send_data(t(), byte(), byte()) :: t()

Send a data at address

Link to this function

set_data_mode(tm, wr_mode, addr_mode)

View Source
@spec set_data_mode(t(), byte(), byte()) :: t()

Set the data modes :param wr_mode: read_mode (read the key scan) or write_mode (write data) :param addr_mode: incr_addr (automatic address increased) or fixed_addr

@spec turn_off(t()) :: t()

Turn off (physically) the leds

@spec turn_on(t()) :: t()

Turn on the display and set the brightness The pulse width used is set to:

0 => 1/16 1 => 2/16 2 => 4/16 3 => 10/16 4 => 11/16 5 => 12/16 6 => 13/16 7 => 14/16