Fledex.Animation.Manager (fledex v0.6.0)

View Source

The animation manager manages several animations (and potentially serveral led strips at the same time. Usually you don't start the service yoursel, 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:

  • register_strip/2: to add a new led strip. This will also create the necessary Fledex.LedStrip and configures it.
  • unregister_strip/1: this will remove an led strip again
  • register_config/2: this registers (or reregisters) a set of animations. Any animation that is not part of a reregistration will be dropped.

Summary

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 touple 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 serveral times (thus it's save 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

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, configs)

@spec register_config(atom(), %{required(atom()) => map()}) :: :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 touple 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 serveral times (thus it's save 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.