Skip to content

Commit

Permalink
Formatting the code according to the standard
Browse files Browse the repository at this point in the history
  • Loading branch information
a-maze-d committed Apr 6, 2024
1 parent 195eefc commit 311477b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/fledex.ex
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ defmodule Fledex do
`Fledex.Component.Clock` example.
"""

# @spec led_strip(atom, atom | keyword, Macro.t) :: Macro.t | map()
# @spec led_strip(atom, atom | keyword, Macro.t) :: Macro.t | map()
defmacro led_strip(strip_name, strip_options \\ :kino, do: block) do
configs_ast = Dsl.ast_extract_configs(block)

Expand Down
2 changes: 1 addition & 1 deletion lib/fledex/animation/animator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ defmodule Fledex.Animation.Animator do
alias Fledex.Utils.PubSub

@type config_t :: %{
optional(:type) => (:animation | :static | :job | :coordinator),
optional(:type) => :animation | :static | :job | :coordinator,
optional(:def_func) => (map -> Leds.t()),
optional(:options) => keyword | nil,
optional(:effects) => [{module, keyword}],
Expand Down
13 changes: 10 additions & 3 deletions lib/fledex/component/clock.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,25 @@ defmodule Fledex.Component.Clock do
@impl true
def configure(name, options) do
trigger_name = Keyword.fetch!(options, :trigger_name)
{helper_color, hour_color, minute_color} = Keyword.get(options, :colors, {:davy_s_grey, :red, :blue})

{helper_color, hour_color, minute_color} =
Keyword.get(options, :colors, {:davy_s_grey, :red, :blue})

use Fledex

led_strip name, :config do
component :minute, Dot,
component(:minute, Dot,
color: minute_color,
count: 60,
trigger_name: create_name(trigger_name, :minute)
component :hour, Dot,
)

component(:hour, Dot,
color: hour_color,
count: 24,
trigger_name: create_name(trigger_name, :hour)
)

static create_name(trigger_name, :helper) do
leds(5) |> light(helper_color, 5) |> repeat(12)
end
Expand Down
4 changes: 3 additions & 1 deletion lib/fledex/component/dot.ex
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ defmodule Fledex.Component.Dot do
animation name do
triggers when is_map(triggers) and is_map_key(triggers, trigger_name) ->
leds(count) |> light(color, triggers[trigger_name])
_triggers -> leds()

_triggers ->
leds()
end
end
end
1 change: 1 addition & 0 deletions lib/fledex/component/thermometer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ defmodule Fledex.Component.Thermometer do
# @spec configure(atom, keyword) :: %{atom => Animator.config_t()}
def configure(name, options) when is_atom(name) and is_list(options) do
name_helper = String.to_atom("#{name}.helper")

case Keyword.keyword?(options) do
true ->
%{
Expand Down
5 changes: 3 additions & 2 deletions lib/fledex/utils/dsl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,13 @@ defmodule Fledex.Utils.Dsl do
end

def configure_strip(_strip_name, :config, config), do: config

def configure_strip(strip_name, strip_options, config) do
# if is_atom(strip_options) and strip_options == :config do
# config
# else
Manager.register_strip(strip_name, strip_options)
Manager.register_config(strip_name, config)
Manager.register_strip(strip_name, strip_options)
Manager.register_config(strip_name, config)
# end
end

Expand Down
1 change: 1 addition & 0 deletions lib/fledex/utils/pubsub.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule Fledex.Utils.PubSub do
defdelegate subscribe(pubsub, topic), to: Phoenix.PubSub
defdelegate unsubscribe(pubsub, topic), to: Phoenix.PubSub
defdelegate broadcast(pubsub, topic, message), to: Phoenix.PubSub

def simple_broadcast(message) when is_map(message) do
broadcast(:fledex, "trigger", {:trigger, message})
end
Expand Down

0 comments on commit 311477b

Please sign in to comment.