neiam
/lambent_ex
Lambent Aether 5
public · Issues · Pulls 1 · Labels · Forks · Compare · Actions success · Badges · Packages
Log in to mark this repository.
all the bits for the library to wrok except the actual add-button flow
a72ce53 · gmorell · 2023-01-27 05:25
Files changed
modified
README.md
+1
−0
| 29 | 29 | - Firefly |
| 30 | 30 | - Growth |
| 31 | 31 | - ##### TODO |
| 32 | +- Static Image / GIF | |
| 32 | 33 | - Twinkles |
| 33 | 34 | - GSI Receiver |
| 34 | 35 | - FFT Receiver |
modified
assets/tailwind.config.js
+3
−0
| 28 | 28 | ], |
| 29 | 29 | theme: { |
| 30 | 30 | extend: { |
| 31 | + gridTemplateColumns: { | |
| 32 | + '32': 'repeat(32, minmax(0, 1fr))\'' | |
| 33 | + }, | |
| 31 | 34 | colors: { |
| 32 | 35 | brand: "#FD4F00", |
| 33 | 36 | } |
added
lib/lambent_ex/machine/library.ex
+70
−0
| 1 | +defmodule LambentEx.Machines.Library do | |
| 2 | + def machines do [ | |
| 3 | + solid: %{ | |
| 4 | + red: %{ machine: LambentEx.Machine.Steps.Solid, args: %{h: 0}}, | |
| 5 | + blue: %{ machine: LambentEx.Machine.Steps.Solid, args: %{h: 128}}, | |
| 6 | + green: %{ machine: LambentEx.Machine.Steps.Solid, args: %{h: 84}}, | |
| 7 | + | |
| 8 | + wwhite: %{ machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 255, g: 255, b: 190}}, | |
| 9 | + sapphire: %{desc: "jewels", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 0, g: 102, b: 202}}, | |
| 10 | + ruby: %{desc: "jewels", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 155, g: 17, b: 30}}, | |
| 11 | + emerald: %{desc: "jewels", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 4, g: 93, b: 28}}, | |
| 12 | + gold: %{desc: "jewels", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 255, g: 215, b: 0}}, | |
| 13 | + cafe: %{desc: "jewels", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 117, g: 86, b: 56}}, | |
| 14 | + orange: %{desc: "fruit", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 255, g: 204, b: 16}}, | |
| 15 | + plum: %{desc: "fruit", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 122, g: 14, b: 190}}, | |
| 16 | + guava: %{desc: "fruit", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 240, g: 122, b: 190}}, | |
| 17 | + lime: %{desc: "fruit", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 8, g: 255, b: 107}}, | |
| 18 | + lemon: %{desc: "fruit", machine: LambentEx.Machine.Steps.SolidRGB, args: %{r: 243, g: 255, b: 7}}, | |
| 19 | + }, | |
| 20 | + chase: %{ | |
| 21 | + red: %{machine: LambentEx.Machine.Steps.Chase, args: %{h: 0}}, | |
| 22 | + blue: %{machine: LambentEx.Machine.Steps.Chase, args: %{h: 128}}, | |
| 23 | + green: %{machine: LambentEx.Machine.Steps.Chase, args: %{h: 84}}, | |
| 24 | + yellow: %{machine: LambentEx.Machine.Steps.Chase, args: %{h: 42}}, | |
| 25 | + pink: %{machine: LambentEx.Machine.Steps.Chase, args: %{h: 212}}, | |
| 26 | + purple: %{machine: LambentEx.Machine.Steps.Chase, args: %{h: 170}}, | |
| 27 | + }, | |
| 28 | + scapes: %{ | |
| 29 | + vista: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 240, h_h: 120}}, | |
| 30 | + love: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 230, h_h: 20}}, | |
| 31 | + ocean: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 90, h_h: 160}}, | |
| 32 | + forest: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 60, h_h: 90}}, | |
| 33 | + royal: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 34, h_h: 43}}, | |
| 34 | + sunny: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 245, h_h: 10}}, | |
| 35 | + night: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 250, h_h: 20}}, | |
| 36 | + fire: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 240, h_h: 120, v: 128}}, | |
| 37 | + vapor: %{machine: LambentEx.Machine.Steps.Scape, args: %{h_l: 150, h_h: 220}}, | |
| 38 | + }, | |
| 39 | + rocker: %{ | |
| 40 | + vapor: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [136, 245]}}, | |
| 41 | + halloween: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [13, 187]}}, | |
| 42 | + halloween_2: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [13, 187, 85]}}, | |
| 43 | + xmas: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [0,85]}}, | |
| 44 | + rgb: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [0,85,171]}}, | |
| 45 | + cmy: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [42,127,212]}}, | |
| 46 | + cmyrgb: %{machine: LambentEx.Machine.Steps.Rocker, args: %{h: [0,42,85,127,171,212]}}, | |
| 47 | + }, | |
| 48 | + ] | |
| 49 | + end | |
| 50 | +end | |
| 51 | + | |
| 52 | +defmodule LambentEx.Machines.Library.Worker do | |
| 53 | + @moduledoc false | |
| 54 | + use GenServer | |
| 55 | + | |
| 56 | + @impl true | |
| 57 | + def init(stack) do | |
| 58 | + {:ok, stack} | |
| 59 | + end | |
| 60 | + | |
| 61 | + @impl true | |
| 62 | + def handle_call(:pop, _from, [head | tail]) do | |
| 63 | + {:reply, head, tail} | |
| 64 | + end | |
| 65 | + | |
| 66 | + @impl true | |
| 67 | + def handle_cast({:push, element}, state) do | |
| 68 | + {:noreply, [element | state]} | |
| 69 | + end | |
| 70 | +end |
modified
lib/lambent_ex/machine/steps/solid.ex
+47
−0
| 43 | 43 | {:reply, read(state), state} |
| 44 | 44 | end |
| 45 | 45 | end |
| 46 | + | |
| 47 | + | |
| 48 | +defmodule LambentEx.Machine.Steps.SolidRGB.Cfg do | |
| 49 | + # @enforce_keys [:h] | |
| 50 | + defstruct [:r, :g, :b, id: 0] | |
| 51 | +end | |
| 52 | + | |
| 53 | +defmodule LambentEx.Machine.Steps.SolidRGB do | |
| 54 | + @moduledoc false | |
| 55 | + use GenServer | |
| 56 | + | |
| 57 | + @registry :lambent_steps | |
| 58 | + @cls :solid | |
| 59 | + | |
| 60 | + alias LambentEx.Machine.Steps.SolidRGB.Cfg | |
| 61 | + alias LambentEx.Utils.Color | |
| 62 | + | |
| 63 | + defp n(opts) do | |
| 64 | + "#{@cls}-#{opts[:name]}-#{opts[:id]}" | |
| 65 | + end | |
| 66 | + | |
| 67 | + def start_link(opts) do | |
| 68 | + GenServer.start_link(__MODULE__, opts, name: via_tuple(n(opts))) | |
| 69 | + end | |
| 70 | + | |
| 71 | + def init(opts) do | |
| 72 | + opts = opts |> Map.put(:status, opts.id) | |
| 73 | + cfg = struct(%LambentEx.Machine.Steps.SolidRGB.Cfg{}, opts) | |
| 74 | + {:ok, cfg} | |
| 75 | + end | |
| 76 | + | |
| 77 | + defp via_tuple(name) do | |
| 78 | + {:via, Registry, {@registry, name}} | |
| 79 | + end | |
| 80 | + | |
| 81 | + defp read(state) do | |
| 82 | + [state.r, state.g, state.b] | |
| 83 | + end | |
| 84 | + | |
| 85 | + def handle_cast(:step, state) do | |
| 86 | + {:noreply, state} | |
| 87 | + end | |
| 88 | + | |
| 89 | + def handle_call(:read, _from, state) do | |
| 90 | + {:reply, read(state), state} | |
| 91 | + end | |
| 92 | +end |
modified
lib/lambent_ex/util/color.ex
+4
−0
| 129 | 129 | def cme, do: cm |> Stream.cycle() |> Enum.take(900) |
| 130 | 130 | def cye, do: cy |> Stream.cycle() |> Enum.take(900) |
| 131 | 131 | def cke, do: ck |> Stream.cycle() |> Enum.take(900) |
| 132 | + | |
| 133 | + # misc | |
| 134 | + def hex(val) when is_float(val), do: trunc(val) |> hex | |
| 135 | + def hex(val), do: Integer.to_string(val, 16) |> String.pad_leading(2, ["0"]) | |
| 132 | 136 | end |
modified
lib/lambent_ex_web/components/core_components.ex
+1
−1
Click to load diff…
modified
lib/lambent_ex_web/live/machines/index.ex
+16
−3
Click to load diff…
modified
lib/lambent_ex_web/live/machines/index.html.heex
+17
−4
Click to load diff…
added
lib/lambent_ex_web/live/machines/library_form_component.ex
+102
−0
Click to load diff…
added
lib/lambent_ex_web/live/machines/library_form_component.html.heex
+69
−0
Click to load diff…
modified
lib/lambent_ex_web/router.ex
+1
−0
Click to load diff…
Parents: c60da79