From e003fe4197045cdb916579ca25a4dbd58d166597 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20Dos=C3=A9?= Date: Sun, 5 Jul 2020 15:14:31 -0700 Subject: [PATCH] Fix formatting, remove unfinished effect --- .formatter.exs | 7 +- lib/rgb_matrix/effect/hue_wave.ex | 7 +- lib/rgb_matrix/effect/solid_reactive.ex | 7 +- lib/rgb_matrix/effect/splash.ex | 94 ------------------------- 4 files changed, 9 insertions(+), 106 deletions(-) delete mode 100644 lib/rgb_matrix/effect/splash.ex diff --git a/.formatter.exs b/.formatter.exs index a895ce4..5b2bcb7 100644 --- a/.formatter.exs +++ b/.formatter.exs @@ -1,8 +1,7 @@ # Used by "mix format" [ - inputs: [ - "{mix,.formatter}.exs", - "{config,lib,test}/**/*.{ex,exs}", - "dialyzer.ignore.exs" + inputs: ["*.{ex,exs}", "{config,lib,test}/**/*.{ex,exs}"], + locals_without_parens: [ + field: 3 ] ] diff --git a/lib/rgb_matrix/effect/hue_wave.ex b/lib/rgb_matrix/effect/hue_wave.ex index d8e0be0..834c992 100644 --- a/lib/rgb_matrix/effect/hue_wave.ex +++ b/lib/rgb_matrix/effect/hue_wave.ex @@ -18,19 +18,19 @@ defmodule RGBMatrix.Effect.HueWave do description: """ Controls the speed at which the wave moves across the matrix. """ - field(:speed, :integer, default: 4, min: 0, max: 32) + field :speed, :integer, default: 4, min: 0, max: 32 @doc name: "Width", description: """ The rate of change of the wave, higher values means it's more spread out. """ - field(:width, :integer, default: 20, min: 10, max: 100, step: 10) + field :width, :integer, default: 20, min: 10, max: 100, step: 10 @doc name: "Direction", description: """ The direction the wave travels across the matrix. """ - field(:direction, :option, + field :direction, :option, default: :right, options: [ :right, @@ -38,7 +38,6 @@ defmodule RGBMatrix.Effect.HueWave do :up, :down ] - ) end defmodule State do diff --git a/lib/rgb_matrix/effect/solid_reactive.ex b/lib/rgb_matrix/effect/solid_reactive.ex index 8468e00..e00bba4 100644 --- a/lib/rgb_matrix/effect/solid_reactive.ex +++ b/lib/rgb_matrix/effect/solid_reactive.ex @@ -17,26 +17,25 @@ defmodule RGBMatrix.Effect.SolidReactive do description: """ The speed at which the hue shifts back to base. """ - field(:speed, :integer, default: 4, min: 0, max: 32) + field :speed, :integer, default: 4, min: 0, max: 32 @doc name: "Distance", description: """ The distance that the hue shifts on key-press. """ - field(:distance, :integer, default: 180, min: 0, max: 360, step: 10) + field :distance, :integer, default: 180, min: 0, max: 360, step: 10 @doc name: "Direction", description: """ The direction (through the color wheel) that the hue shifts on key-press. """ - field(:direction, :option, + field :direction, :option, default: :random, options: [ :random, :negative, :positive ] - ) end defmodule State do diff --git a/lib/rgb_matrix/effect/splash.ex b/lib/rgb_matrix/effect/splash.ex deleted file mode 100644 index bb7fce3..0000000 --- a/lib/rgb_matrix/effect/splash.ex +++ /dev/null @@ -1,94 +0,0 @@ -defmodule RGBMatrix.Effect.Splash do - @moduledoc """ - Full gradient & value pulse away from key hits then fades value out. - """ - - alias Chameleon.HSV - alias RGBMatrix.Effect - - use Effect - - # import RGBMatrix.Utils, only: [mod: 2] - - defmodule Config do - use RGBMatrix.Effect.Config - end - - defmodule State do - defstruct [:tick, :leds, :hits] - end - - @delay_ms 17 - - @impl true - def new(leds, _config) do - {0, %State{tick: 0, leds: leds, hits: %{}}} - end - - @impl true - def render(state, _config) do - %{tick: tick, leds: leds, hits: hits} = state - - {colors, hits} = - Enum.map_reduce(leds, hits, fn led, hits -> - color = HSV.new(0, 100, 0) - - {hits, color} = - Enum.reduce(hits, {hits, color}, fn {hit_led, hit_tick}, {hits, color} -> - dx = led.x - hit_led.x - dy = led.y - hit_led.y - dist = :math.sqrt(dx * dx + dy * dy) - color = effect(color, dist, tick - hit_tick) - - {hits, color} - end) - - {{led.id, color}, hits} - end) - - # for (uint8_t i = led_min; i < led_max; i++) { - # RGB_MATRIX_TEST_LED_FLAGS(); - # HSV hsv = rgb_matrix_config.hsv; - # hsv.v = 0; - # for (uint8_t j = start; j < count; j++) { - # int16_t dx = g_led_config.point[i].x - g_last_hit_tracker.x[j]; - # int16_t dy = g_led_config.point[i].y - g_last_hit_tracker.y[j]; - # uint8_t dist = sqrt16(dx * dx + dy * dy); - # uint16_t tick = scale16by8(g_last_hit_tracker.tick[j], rgb_matrix_config.speed); - # hsv = effect_func(hsv, dx, dy, dist, tick); - # } - # hsv.v = scale8(hsv.v, rgb_matrix_config.hsv.v); - # RGB rgb = hsv_to_rgb(hsv); - # rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); - # } - - {colors, @delay_ms, %{state | tick: tick + 1, hits: hits}} - end - - def effect(color, dist, hit_tick) do - # uint16_t effect = tick - dist; - # if (effect > 255) effect = 255; - # hsv.h += effect; - # hsv.v = qadd8(hsv.v, 255 - effect); - # return hsv; - - # effect = trunc(if effect > 360, do: 360, else: effect) - - value = 100 - hit_tick - trunc(dist * 20) - value = if value < 0, do: 0, else: value - - %{color | h: 0, v: value} - - # if dist < 5 do - # HSV.new(0, 100, 100) - # else - # color - # end - end - - @impl true - def interact(state, _config, led) do - # {:ignore, %{state | hits: Map.put(state.hits, led, state.tick)}} - {:ignore, %{state | hits: %{led => state.tick}}} - end -end