From 2bffa138eada06171dd2630a0ee8b6224f0ed346 Mon Sep 17 00:00:00 2001 From: Jesse Van Volkinburg Date: Wed, 15 Jul 2020 17:44:02 -0700 Subject: [PATCH] add :colors to state, fix init_colors Also switch back to 500ms for feedback... 850 feels way too long on the real keypad --- lib/rgb_matrix/animation/simon.ex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/rgb_matrix/animation/simon.ex b/lib/rgb_matrix/animation/simon.ex index 30c3cf1..28454f7 100644 --- a/lib/rgb_matrix/animation/simon.ex +++ b/lib/rgb_matrix/animation/simon.ex @@ -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) @@ -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}) @@ -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 @@ -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