RGBMatrix.Animation behaviour (rgb_matrix v0.1.0) View Source

Provides the behaviour and interface for working with animations.

Link to this section Summary

Functions

Defines a configuration field for an animation.

Gets the current configuration and the configuration schema from an animation.

Sends an interaction event to an animation.

Returns an animation's initial state.

Returns the next state of an animation based on its current state.

Returns a human-readable name for an animation type.

Returns a list of the available types of animations.

Updates the configuration of an animation and returns the updated animation.

Link to this section Types

Specs

animation_state() :: any()

Specs

render_in() :: non_neg_integer() | :never | :ignore

Specs

t() :: %RGBMatrix.Animation{
  config: RGBMatrix.Animation.Config.t(),
  state: any(),
  type: type()
}

Specs

type() ::
  RGBMatrix.Animation.Breathing
  | RGBMatrix.Animation.CycleAll
  | RGBMatrix.Animation.HueWave
  | RGBMatrix.Animation.Pinwheel
  | RGBMatrix.Animation.RandomSolid
  | RGBMatrix.Animation.RandomKeypresses
  | RGBMatrix.Animation.SolidColor
  | RGBMatrix.Animation.SolidReactive
  | nil

Link to this section Functions

Link to this macro

field(name, type, opts \\ [])

View Source (macro)

Defines a configuration field for an animation.

Example:

field :speed, :integer,
  default: 4,
  min: 0,
  max: 32,
  doc: [
    name: "Speed",
    description: """
    Controls the speed at which the wave moves across the matrix.
    """
  ]

Specs

Gets the current configuration and the configuration schema from an animation.

Link to this function

interact(animation, led)

View Source

Specs

interact(animation :: t(), led :: KeyboardLayout.LED.t()) :: {render_in(), t()}

Sends an interaction event to an animation.

Link to this function

new(animation_type, leds)

View Source

Specs

new(animation_type :: type(), leds :: [KeyboardLayout.LED.t()]) :: t()

Returns an animation's initial state.

Specs

render(animation :: t()) :: {render_in(), RGBMatrix.Engine.frame(), t()}

Returns the next state of an animation based on its current state.

Link to this function

type_name(animation_type)

View Source

Specs

type_name(animation_type :: type()) :: String.t()

Returns a human-readable name for an animation type.

Specs

types() :: [type(), ...]

Returns a list of the available types of animations.

Link to this function

update_config(animation, params)

View Source

Specs

update_config(
  animation :: t(),
  params :: RGBMatrix.Animation.Config.update_params()
) :: t()

Updates the configuration of an animation and returns the updated animation.

Link to this section Callbacks