View Source IS31FL3733 (is31fl3733 v0.1.2)

I2C driver for the IS31FL3733 12x16 dot matrix LED driver.

This driver tries to follow the data-sheet as closely as possible, so it's recommended to be familiar with it: http://www.issi.com/WW/pdf/IS31FL3733.pdf

NOTE: Currently only PWM mode is supported. The auto-breath feature has not yet been implemented in this driver.

example-usage

Example Usage

iex> # each bit is one LED, 24 * 8 == 16 * 12
...> led_state_data = String.duplicate(<<255>>, 24)
...>
...> # each byte is one LED
...> led_pwm_data = String.duplicate(<<255>>, 16 * 12)
...>
...> # turn on all the LEDs in PWM mode
...> ic =
...>   "i2c-1"
...>   |> IS31FL3733.open(0x50)
...>   |> IS31FL3733.set_global_current_control(0x3C)
...>   |> IS31FL3733.set_swy_pull_up_resistor(:"32k")
...>   |> IS31FL3733.set_csx_pull_down_resistor(:"32k")
...>   |> IS31FL3733.set_led_on_off(0x00, led_state_data)
...>   |> IS31FL3733.set_led_pwm(0x00, led_pwm_data)
...>   |> IS31FL3733.disable_software_shutdown()
...>
...> ic
#IS31FL3733<"i2c-1@0x50">

Link to this section Summary

Functions

Closes an I2C connection.

Disables software shutdown, allowing LEDs to be turned on.

Enables software shutdown, causing all LEDs to be turned off.

Opens an I2C connection and resets the configuration.

Reports open LEDs.

Reports short LEDs.

Resets the internal state and configuration to defaults.

Sets the internal pull-down resistor for the CSx pins.

Sets the global current control of the CSx pins.

Sets the LED mode.

Sets the on/off state of individual LEDs.

Sets the PWM value of individual LEDs.

Sets the internal pull-up resistor for the SWy pins.

Sets the sync mode.

Link to this section Types

Link to this type

current_control_value()

View Source
@type current_control_value() :: 0..255
@type led_mode() :: :breathing | :pwm
@type led_on_off_register() :: 0..23
@type led_pwm_register() :: 0..191
@type resistor() :: :none | :"500" | :"1k" | :"2k" | :"4k" | :"8k" | :"16k" | :"32k"
@type sync_mode() :: :single | :primary | :secondary
@opaque t()

Link to this section Functions

@spec close(state :: t()) :: :ok

Closes an I2C connection.

examples

Examples

iex> ic = IS31FL3733.open("i2c-1", 0x50)
...> IS31FL3733.close(ic)
:ok
Link to this function

disable_software_shutdown(state)

View Source
@spec disable_software_shutdown(state :: t()) :: t()

Disables software shutdown, allowing LEDs to be turned on.

Software shutdown is enable by default.

examples

Examples

iex> ic = IS31FL3733.open("i2c-1", 0x50)
...> IS31FL3733.disable_software_shutdown(ic)
#IS31FL3733<"i2c-1@0x50">
Link to this function

enable_software_shutdown(state)

View Source
@spec enable_software_shutdown(state :: t()) :: t()

Enables software shutdown, causing all LEDs to be turned off.

Software shutdown is enable by default.

examples

Examples

iex> ic = IS31FL3733.open("i2c-1", 0x50)
...> IS31FL3733.enable_software_shutdown(ic)
#IS31FL3733<"i2c-1@0x50">
@spec open(
  bus_name :: binary() | charlist(),
  address :: IS31FL3733.I2CBehavior.address()
) :: t()

Opens an I2C connection and resets the configuration.

The address can be determined by consulting page 9, table 1 in the data-sheet.

examples

Examples

iex> IS31FL3733.open("i2c-1", 0x50)
#IS31FL3733<"i2c-1@0x50">
@spec report_open_leds(state :: t()) :: {t(), binary()}

Reports open LEDs.

This will return a report of which LEDs are open in the circuit, i.e. missing LEDs.

The report is returned as a binary, where each byte represents the open state of 8 LEDs. The arrangements follow the same structure as the LED on/off states.

See page 14, table 6 in the data-sheet for details.

examples

Examples

iex> ic = IS31FL3733.open("i2c-1", 0x50)
...> {_ic, report} = IS31FL3733.report_open_leds(ic)
...> report
<<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>
Link to this function

report_short_leds(state)

View Source
@spec report_short_leds(state :: t()) :: {t(), binary()}

Reports short LEDs.

This will return a report of which LEDs are shorted in the circuit.

The report is returned as a binary, where each byte represents the short state of 8 LEDs. The arrangements follow the same structure as the LED on/off states.

See page 14, table 6 in the data-sheet for details.

examples

Examples

iex> ic = IS31FL3733.open("i2c-1", 0x50)
...> {_ic, report} = IS31FL3733.report_short_leds(ic)
...> report
<<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>
@spec reset(state :: t()) :: t()

Resets the internal state and configuration to defaults.

examples

Examples

iex> ic = IS31FL3733.open("i2c-1", 0x50)
...> IS31FL3733.reset(ic)
#IS31FL3733<"i2c-1@0x50">
Link to this function

set_csx_pull_down_resistor(state, resistor)

View Source
@spec set_csx_pull_down_resistor(state :: t(), resistor :: resistor()) :: t()

Sets the internal pull-down resistor for the CSx pins.

By default, there is no pull-down resistor set.

Resistor values:

  • :none
  • :"500"
  • :"1k"
  • :"2k"
  • :"4k"
  • :"8k"
  • :"16k"
  • :"32k"

examples

Examples

iex> ic = IS31FL3733.open("i2c-1", 0x50)
...> IS31FL3733.set_csx_pull_down_resistor(ic, :"32k")
#IS31FL3733<"i2c-1@0x50">
Link to this function

set_global_current_control(state, value)

View Source
@spec set_global_current_control(state :: t(), value :: current_control_value()) ::
  t()

Sets the global current control of the CSx pins.

See page 18, table 14 in the data-sheet for details on how this affects the current output of the CSx pins.

examples

Examples

iex> ic = IS31FL3733.open("i2c-1", 0x50)
...> IS31FL3733.set_global_current_control(ic, 0x3C)
#IS31FL3733<"i2c-1@0x50">
Link to this function

set_led_mode(state, atom)

View Source
@spec set_led_mode(state :: t(), led_mode :: led_mode()) :: t()

Sets the LED mode.

The default mode is :pwm.

Modes:

  • :breathing - Use the auto-breath feature
  • :pwm - Manually set the PWM of each LED

examples

Examples

iex> ic = IS31FL3733.open("i2c-1", 0x50)
...> IS31FL3733.set_led_mode(ic, :pwm)
#IS31FL3733<"i2c-1@0x50">

iex> ic = IS31FL3733.open("i2c-1", 0x50)
...> IS31FL3733.set_led_mode(ic, :breathing)
#IS31FL3733<"i2c-1@0x50">
Link to this function

set_led_on_off(state, start_register, data)

View Source
@spec set_led_on_off(
  state :: t(),
  start_register :: led_on_off_register(),
  data :: binary()
) :: t()

Sets the on/off state of individual LEDs.

Each register controls 8 LEDs (one byte, each bit turns one LED on or off). E.g.: register 0x00 addresses row SW1, columns CS1 through CS8, and register 0x01 addresses row SW1, columns CS9 through CS16, and so on.

You can send more than one byte to the register, and each subsequent byte will internally increment the register by one. This allows you to set the on/off state of the whole matrix with one call.

See page 14, table 6 in the data-sheet for details on how to address each LED.

examples

Examples

iex> # each bit is one LED, 24 * 8 == 12 * 16
...> led_state_data = String.duplicate(<<255>>, 24)
...> # turns on all LEDs in the matrix:
...> ic = IS31FL3733.open("i2c-1", 0x50)
...> IS31FL3733.set_led_on_off(ic, 0x00, led_state_data)
#IS31FL3733<"i2c-1@0x50">
Link to this function

set_led_pwm(state, start_register, data)

View Source
@spec set_led_pwm(
  state :: t(),
  start_register :: led_pwm_register(),
  data :: binary()
) :: t()

Sets the PWM value of individual LEDs.

Each register controls 1 LED (one byte, gives possible values 0..255). E.g. register 0x00 addresses row SW1, column CS1, and register 0x01 addresses row SW1, column CS2, and so on.

You can send more than one byte to the register, and each subsequent byte will internally increment the register by one. This allows you to set the PWM values of the whole matrix with one call.

See page 15, figure 9 in the data-sheet for details on how to address each LED.

examples

Examples

iex> # each byte is one LED
...> led_pwm_data = String.duplicate(<<255>>, 16 * 12)
...> # sets the PWM value to max for all LEDs:
...> ic = IS31FL3733.open("i2c-1", 0x50)
...> IS31FL3733.set_led_pwm(ic, 0x00, led_pwm_data)
#IS31FL3733<"i2c-1@0x50">
Link to this function

set_swy_pull_up_resistor(state, resistor)

View Source
@spec set_swy_pull_up_resistor(state :: t(), resistor :: resistor()) :: t()

Sets the internal pull-up resistor for the SWy pins.

By default, there is no pull-up resistor set.

Resistor values:

  • :none
  • :"500"
  • :"1k"
  • :"2k"
  • :"4k"
  • :"8k"
  • :"16k"
  • :"32k"

examples

Examples

iex> ic = IS31FL3733.open("i2c-1", 0x50)
...> IS31FL3733.set_swy_pull_up_resistor(ic, :"32k")
#IS31FL3733<"i2c-1@0x50">
Link to this function

set_sync_mode(state, sync_mode)

View Source
@spec set_sync_mode(state :: t(), sync_mode :: sync_mode()) :: t()

Sets the sync mode.

The default sync mode is :single.

Modes:

  • :single - A single IC controlling a 12x16 matrix of LEDs
  • :primary - This IC is the primary among a set of others and supplies the clock signal.
  • :secondary - This IC is a secondary and receives its clock signal from the primary.

examples

Examples

iex> ic = IS31FL3733.open("i2c-1", 0x50)
...> IS31FL3733.set_sync_mode(ic, :primary)
#IS31FL3733<"i2c-1@0x50">