View Source Fledex (fledex v0.3.0)

This module should provide some simple macros that allow to define the led strip and to update it. The code you would write (in livebook) would look something like the following:

  use Fledex
  led_strip :strip_name, ;kino do
    animation :john do
      config = %{
        num_leds: 50,
        reversed: true
      }

      leds(50)
        |> rainbow(config)
    end
  end

Summary

Functions

By using this module, the Fledex macros are made available.

This introduces a new animation (animation) that will be played over and over again until it is changed.

NOT YET IMPLEMENTED (thus, those are just some thoughts)

Add an effect to an animation

This function returns the currently configured macros/functions that can be used in a fledex led_strip

This introduces a new led_strip.

The static macro is equal to the animation macro, but it will not receive any triggers.

Functions

Link to this macro

__using__(opts)

View Source (macro)
@spec __using__(keyword()) :: Macro.t()

By using this module, the Fledex macros are made available.

This macro does also include the Fledex.Leds and the Fledex.Color.Names and are therefore available without namespace.

Take a look at the various livebook examples on how to use the Fledex macros

Link to this macro

animation(name, options \\ [], list)

View Source (macro)
@spec animation(atom(), keyword(), Macro.t()) :: Macro.t()

This introduces a new animation (animation) that will be played over and over again until it is changed.

Therefore we give it a name to know whether it changes

Link to this macro

component(name, type, options \\ [], list)

View Source (macro)
@spec component(atom(), module(), keyword(), Macro.t()) :: Macro.t()

NOT YET IMPLEMENTED (thus, those are just some thoughts)

A component is a pre-defined animation that reacts to some input. We might have a thermometer component that defines the display of a thermometer:

  • input: single value
  • display is a range (positive, 0, negative)
  • ...

The do: block should retun the expected parameters for the component. For our thermometer component the parameters might be:

  • the value,
  • the display colors,
  • the range of our scale

Thus, it might look something like the following:

do
  %Thermometer{
    value: 10,
    negative: :blue,
    positive: :red,
    range: -10..30,
    steps: 1,
  }
end
Link to this macro

effect(module, options \\ [], list)

View Source (macro)
@spec effect(module(), keyword(), Macro.t()) :: Macro.t()

Add an effect to an animation

This macro allows to add an effect to an animation (or even a component (TODO: figure out whether an effect on a static component makes any sense, it would mean that the static component suddenly would need to be animated)

You simply warp the animation inside a effect block. It's possible to have severeal nested effects. In that case they will all be executed in sequence.

Example:

use Fledex
alias Fledex.Effect.Wanish
led_strip :john, :kino do
  effect Wanish, trigger_name: :john do
    animation :test do
      _triggers ->
        leds(1) |> light(:red) |> repeat(50)
    end
  end
end
@spec fledex_config() :: %{required(atom()) => module()}

This function returns the currently configured macros/functions that can be used in a fledex led_strip

Link to this macro

led_strip(strip_name, strip_options \\ :kino, list)

View Source (macro)
@spec led_strip(atom(), atom() | keyword(), Macro.t()) :: Macro.t()

This introduces a new led_strip.

Link to this macro

static(name, options \\ [], list)

View Source (macro)
@spec static(atom(), keyword(), Macro.t()) :: Macro.t()

The static macro is equal to the animation macro, but it will not receive any triggers.

Therefore, there will not be any repainting and the def_func will not receive any parameter. It will only be painted once at definition time.