View Source Fledex.LedStrip (fledex v0.3.0)

This module defines a GenServer that manages the LED strip (be it a real one with the Fledex.Driver.Impl.Spi or a virtual one with e.g. the Fledex.Driver.Impl.Kino).

You would start an LedStrip for every led strip you have.

The Fledex.LedStrip will take several Fledex.Leds definitions and merge them together to be displayed on a single LED strip.

The role the LedStrip plays is similar to the one a window server plays on a normal computer, except that a window server would manage several screens, whereas here each LED strip would get its own.

Summary

Functions

Change some aspect of a configuration for a specific strip. The configuration will be updated and the old value will be returned.

Returns a specification to start this module under a supervisor.

Drop a previously defined namespace.

Checks whether the specified namespace already exists

In some circumstances it might be necessary to reinitialize a driver. Most of the time you don't need to call this. If you do, you will surely know about it :)

Sets the leds in a specific strip and namespace.

Functions

Link to this function

change_config(strip_name \\ __MODULE__, config_path, value)

View Source
@spec change_config(atom(), [atom()], any()) :: {:ok, any()}

Change some aspect of a configuration for a specific strip. The configuration will be updated and the old value will be returned.

Caution: No error checking is performed, so you might end up with a useless configuration

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

define_namespace(strip_name \\ __MODULE__, namespace)

View Source
@spec define_namespace(atom(), atom()) :: :ok | {:error, String.t()}

Define a new namespace

Link to this function

drop_namespace(strip_name \\ __MODULE__, namespace)

View Source
@spec drop_namespace(atom(), atom()) :: :ok

Drop a previously defined namespace.

Link to this function

exist_namespace(strip_name \\ __MODULE__, namespace)

View Source
@spec exist_namespace(atom(), atom()) :: boolean()

Checks whether the specified namespace already exists

Link to this function

reinit_drivers(strip_name \\ __MODULE__)

View Source
@spec reinit_drivers(atom()) :: :ok

In some circumstances it might be necessary to reinitialize a driver. Most of the time you don't need to call this. If you do, you will surely know about it :)

Link to this function

set_leds(strip_name \\ __MODULE__, namespace, leds)

View Source
@spec set_leds(atom(), atom(), [pos_integer()]) :: :ok | {:error, String.t()}

Sets the leds in a specific strip and namespace.

Note: repeated calls of this function will result in previously set leds will be overwritten. We are passing a list of leds which means every led will be rewritten, except if we define a 'shorter" led sequence. In that case some leds might retain their previously set value.

Link to this function

start_link(strip_name \\ __MODULE__, config \\ :none)

View Source
@spec start_link(atom() | {:global, any()} | {:via, atom(), any()}, atom() | map()) ::
  :ignore | {:error, any()} | {:ok, pid()}