Skip to content

Commit

Permalink
add :colors to state, fix init_colors
Browse files Browse the repository at this point in the history
Also switch back to 500ms for feedback... 850 feels way too long on the real keypad
  • Loading branch information
Jesse Van Volkinburg committed Jul 16, 2020
1 parent 0610e74 commit 2bffa13
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/rgb_matrix/animation/simon.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ defmodule RGBMatrix.Animation.Simon do

defmodule State do
@moduledoc false
defstruct [:leds, :simon_sequence, :state]
defstruct [:leds, :simon_sequence, :state, :colors]
end

@black Chameleon.RGB.new(0, 0, 0)
Expand All @@ -31,7 +31,7 @@ defmodule RGBMatrix.Animation.Simon do
{0, state}
end

@impl true
@impl true
def render(%{state: :start_sequence} = state, _config) do
colors = state.leds |> Enum.map(&{&1.id, @black})

Expand Down Expand Up @@ -85,7 +85,7 @@ defmodule RGBMatrix.Animation.Simon do
rest -> %{state | state: {:expecting_input, rest}}
end

{850, colors, state}
{500, colors, state}
end

@impl true
Expand Down Expand Up @@ -133,7 +133,7 @@ defmodule RGBMatrix.Animation.Simon do
HSV.new((:rand.uniform() * 360) |> trunc(), 100, 100)
end

defp init_colors() do
defp init_colors(state) do
colors = for led <- state.leds, into: %{}, do: {led.id, random_color()}
%{state | colors: colors}
end
Expand Down

0 comments on commit 2bffa13

Please sign in to comment.