Fledex.Animation.Manager (fledex v0.8.0)

Copy Markdown View Source

Note

You probably do not want to use this module directly but use the DSL defined in Fledex

The animation manager manages several animations (and potentially several led strips at the same time. Usually you don't start the service yourself, but it gets automatically started when calling use Fledex and gets used by the Fledex macros. Thus, you rarely have to interact with it directly.

The 3 main functions are:

Summary

Types

The various configurations the manager accepts.

Functions

provides a child_spec of this module so that it can easily be added to a supervision tree.

Register a set of configurations (animations, jobs, ...) for a specific led strip. This function can be called as many times as desired to reconfigure the strip. It should be noted that any animation, job, ... that was defined before calling this function again, will be stopped if they are not part of the configuration anymore. Newly defined animations will be started.

Register a new LED strip with the specific strip_name. The LED strip needs to be configured, either through a simple module (for predefined configurations) or a tuple with module and keyword list to adjust the configuration.(see LedStrip for details).

This starts a new Fledex.Animation.Manager. Only a single animation manager will be started even if called several times (thus it's safe to call it repeatedly). In general you want to start the function without options, since they are only for debugging purposes.

Unregisters a previously registered led strip. All resources related to the led strip will be freed.

Types

config_t()

The various configurations the manager accepts.

The key of the map is the worker name and the value is it's corresponding configuration

Functions

child_spec(init_arg)

@spec child_spec(keyword()) :: Supervisor.child_spec()

provides a child_spec of this module so that it can easily be added to a supervision tree.

register_config(strip_name, config)

@spec register_config(atom(), config_t()) :: :ok

Register a set of configurations (animations, jobs, ...) for a specific led strip. This function can be called as many times as desired to reconfigure the strip. It should be noted that any animation, job, ... that was defined before calling this function again, will be stopped if they are not part of the configuration anymore. Newly defined animations will be started.

Note

The animation functions might get called quite frequently and therefore any work within them should be kept to a minimum.

register_strip(strip_name, drivers, strip_config)

@spec register_strip(atom(), Fledex.LedStrip.drivers_config_t(), keyword()) :: :ok

Register a new LED strip with the specific strip_name. The LED strip needs to be configured, either through a simple module (for predefined configurations) or a tuple with module and keyword list to adjust the configuration.(see LedStrip for details).

start_link(opts \\ [])

@spec start_link(keyword()) :: {:ok, pid()}

This starts a new Fledex.Animation.Manager. Only a single animation manager will be started even if called several times (thus it's safe to call it repeatedly). In general you want to start the function without options, since they are only for debugging purposes.

unregister_strip(strip_name)

@spec unregister_strip(atom()) :: :ok

Unregisters a previously registered led strip. All resources related to the led strip will be freed.