PCA9622Matrix8x8 (pca9622matrix8x8 v0.1.3)

Copy Markdown

Driver for the switch-science "I2C 8x8 LED matrix" board (https://www.switch-science.com/products/2071), which multiplexes an 8x8 LED matrix over I2C using the PCA9622 constant-current LED driver.

start_link/1 accepts:

  • :bus_name - the I2C bus to open (default: "i2c-2")
  • :i2c_address - the PCA9622's I2C address (default: 0x50)
  • :reflesh_interval - column refresh interval in ms (default: 10)
  • :initial_matrix - initial 8x8 matrix to display
  • :name - GenServer name to register under (default: PCA9622Matrix8x8); pass nil to start unnamed, which allows multiple boards to run at once. When a name other than the default is used (or nil), pass the returned pid/name explicitly to set_matrix/2, set_matrix_bit/4 and stop/1.

Summary

Functions

Turns every LED on the board fully off. Takes a raw I2C ref (from Circuits.I2C.open/1 or init_led/2), not a GenServer.

Turns every LED on the board fully on. Takes a raw I2C ref (from Circuits.I2C.open/1 or init_led/2), not a GenServer. Useful as a quick hardware sanity check.

Returns a specification to start this module under a supervisor.

Replaces the whole 8x8 matrix that is currently displayed.

Builds an 8x8 matrix (as used by set_matrix/2) with every pixel set to value. value may be 0/1, or any other term treated as falsy/truthy.

Sets a single pixel (x, y) of the currently displayed matrix to value (0 or 1).

Starts the LED matrix driver GenServer. See the moduledoc for available opts.

Stops the LED matrix driver GenServer, turning all LEDs off and closing the I2C bus.

Functions

all_off(ref, i2c_address \\ 80)

Turns every LED on the board fully off. Takes a raw I2C ref (from Circuits.I2C.open/1 or init_led/2), not a GenServer.

all_on(ref, i2c_address \\ 80)

Turns every LED on the board fully on. Takes a raw I2C ref (from Circuits.I2C.open/1 or init_led/2), not a GenServer. Useful as a quick hardware sanity check.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

set_matrix(server \\ __MODULE__, mat)

Replaces the whole 8x8 matrix that is currently displayed.

mat is an 8x8 tuple of tuples of 0/1, e.g. as built from PCA9622Matrix8x8.CharGen.digit_strlist/2 output.

set_matrix_all(value)

Builds an 8x8 matrix (as used by set_matrix/2) with every pixel set to value. value may be 0/1, or any other term treated as falsy/truthy.

set_matrix_bit(server \\ __MODULE__, x, y, value)

Sets a single pixel (x, y) of the currently displayed matrix to value (0 or 1).

start_link(opts \\ [])

Starts the LED matrix driver GenServer. See the moduledoc for available opts.

stop(server \\ __MODULE__)

Stops the LED matrix driver GenServer, turning all LEDs off and closing the I2C bus.