


Mix deps.get # Downloads the appropriate system We need this stuff in here or Phoenix has no clue what it should do.īack to keybored_ui and run the following:Įxport MIX_TARGET =rpi0 # or rpi3a, rpi4 or what matches your hardware
#Liveview broadcast full
The reason we set up the full Phoenix config in here is that the config in a dependency, such as keybored_ui which we treat as a dependency, is not inherited by your application. Keep your secret key base very secret, don’t betray your signing salt, use this for fun not function. The later part is essentially copy-pasted from the Nerves UI guide. OR, and this is certainly an option, you change your WiFi access point to have the same credentials as mine.
#Liveview broadcast code
# Nerves root filesystem is read-only, so disable the code reloader code_reloader: false # Use Jason for JSON parsing in PhoenixĬonfig :phoenix, :json_library, Jason #.įor the WiFi I suggest you change your SSID and PSK in the configuration to match your actual WiFI. # Start the server since we're running in a release instead of through `mix` server: true, Secret_key_base: "HEY05EB1dFVSu6KykKHuS4rQPQzSHv4F7mGVB/gnDLrIu75wE/ytBXy2Ta元A6RA", Let’s add it to the router.ex file by replacing the existing entry for "/" with:Ĭonfig :keybored_ui, KeyboredUIWeb.Endpoint,Ĭache_static_manifest: "priv/static/cache_manifest.json",


Our render-function renders the assigns by showing an SVG dot on the screen and printing out some recent events.
#Liveview broadcast update
We add the event information to the events list and for particular events we let a function called process_movements/2 update the dot. We add the handle_info/3 callback matching for the input events we expect to be working with. We set up some initial state with the list of devices, an empty list of events and. start_link( KeyboredUI.Inputter, nil, name: Keybored.Inputter)Īs we mount the LiveView we pull the list of devices and subscribe to the “inputs” topic. The fundamental steps are taken from the Nerves documentation for User Interfaces which has a whole thing about setting up a “poncho” project with Phoenix.įirst, make sure you have installed Nerves and have Elixir working.ĭefmodule KeyboredUI.Inputter do use GenServer def start_link(_) do GenServer. You will need a Raspberry Pi device, an SD card reader and some patience with me. Let’s stick to the slightly simpler demo and unpack the process. The docs for that one are sparse, steps are likely missing. That one includes Tailwind CSS, basic Ecto migrations with SQLite and some other niceties but it is another demo. I have also made a slightly more involved demo project for an event that you can find on my GitHub. This is just one way to do something fun with Nerves and LiveView in a fairly minimal way. There are may compelling first demos we could arguably make to achieve it. There is also a video covering this exact project that I made. I haven’t run into any short compelling demos of getting these started together. Phoenix LiveView is currently my favorite way of making full-stack web development cohesive and keeping the complexity as low as possible for it. Nerves is a fantastic way of working with hardware along with the BEAM virtual machine and it is great fun for hobbyist projects like Raspberry Pis. I’ve played with Nerves for almost as long as I’ve been learning and using Elixir.
