Skip to content

Commit

Permalink
Launcher add a reboot button
Browse files Browse the repository at this point in the history
  • Loading branch information
axelson committed Jul 9, 2019
1 parent d371a3e commit 07dadd6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions fw/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ config :nerves_init_gadget,
node_name: "murphy"

config :launcher, :backlight_module, Fw.Backlight
config :launcher, :reboot_mfa, {Nerves.Runtime, :reboot, []}

# Cannot write update files to a read-only file system. Plus we don't need
# accurate timezones
Expand Down
13 changes: 13 additions & 0 deletions launcher/lib/launcher/scenes/home.ex
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ defmodule Launcher.Scene.Home do
id: :btn_sleep_screen,
t: {10, screen_height - 50}
)
|> Scenic.Components.button("Reboot", id: :btn_reboot, t: {150, screen_height - 50})

{:ok, state, push: graph}
end
Expand Down Expand Up @@ -65,6 +66,11 @@ defmodule Launcher.Scene.Home do
{:halt, state}
end

def filter_event({:click, :btn_reboot}, _from, state) do
reboot()
{:halt, state}
end

def filter_event({:click, :btn_sleep_screen}, _from, state) do
state = sleep_screen(state)
{:halt, state}
Expand Down Expand Up @@ -100,4 +106,11 @@ defmodule Launcher.Scene.Home do
end
%{state | sleep: false}
end

defp reboot do
case Application.get_env(:launcher, :reboot_mfa) do
nil -> Logger.info("No reboot mfa set")
{mod, fun, args} -> apply(mod, fun, args)
end
end
end

0 comments on commit 07dadd6

Please sign in to comment.