Fledex.Supervisor.AnimationSystem (fledex v0.6.0)

View Source

This module starts and supervises all the services required for running animations. You rarely will use this module directly, but rather use it through the Fledex DSL.

This includes:

  • The animation manager
  • The job scheduler
  • The messaging services
  • The workers

You can start the whole subsystem by calling

AnimationSystem.start_link/0

It's more common to add it to a Supervision tree by calling:

 Supervisor.start_link(AnimationSystem.child_spec(opts), strategy: :one_for_one)

or for adding it to a dynamic supervisor:

DynamicSupervisor.start_child(AnimationSystem.child_spec(opts))

or for adding in a livebook to a Kino supervisor:

Kino.start_child(AnimationSystem.child_spec(opts))

The dynamic options are probably not something you want to do manually, but it's something you want to trigger when calling use Fledex.

Once the AnimationSystem is up and running you can add led strips through start_led_strip/3

Summary

Functions

This is a child_spec that can be used when starting the AnimationSystem under a supervision tree.

This starts a new led_strip to which we can send some led sequences, and, if we update it in regular intervals, can play an animation

starts the AnimationSystem and all necessary subsystems

stops the Supervisor and all it's attached services

Functions

child_spec(init_arg)

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

This is a child_spec that can be used when starting the AnimationSystem under a supervision tree.

start_led_strip(strip_name, drivers \\ Null, strip_config \\ [])

@spec start_led_strip(atom(), Fledex.LedStrip.drivers_config_t(), keyword()) ::
  GenServer.on_start()

This starts a new led_strip to which we can send some led sequences, and, if we update it in regular intervals, can play an animation

start_link(init_args \\ [])

@spec start_link(keyword()) ::
  {:ok, pid()}
  | {:error, {:already_started, pid()} | {:shutdown, term()} | term()}

starts the AnimationSystem and all necessary subsystems

stop(reason \\ :normal, timeout \\ :infinity)

@spec stop(term(), timeout()) :: :ok

stops the Supervisor and all it's attached services