Skip to content

Commit

Permalink
Added display flags
Browse files Browse the repository at this point in the history
  • Loading branch information
th0mas committed Jul 21, 2020
1 parent 1fc3544 commit c34167f
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 3 deletions.
4 changes: 3 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ config :logger, backends: [RingLogger]
config :smart_home_firmware,
hub: "192.168.0.14:4000"

if Mix.target() != :host do
if Mix.target() == :host do
import_config "host.exs"
else
import_config "target.exs"
end
14 changes: 14 additions & 0 deletions config/host.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Config

config :smart_home_firmware, :viewport, %{
name: :main_viewport,
default_scene: {SmartHomeFirmware.Display.Scene.Welcome},
size: {800, 480},
opts: [scale: 1.0],
drivers: [
%{
module: Scenic.Driver.Glfw,
opts: [title: "MIX_TARGET=host, app = :smart_home_firmware"]
}
]
}
14 changes: 14 additions & 0 deletions config/rpi3.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Config

config :smart_home_firmware, :viewport, %{
name: :main_viewport,
# default_scene: {NervesScenic.Scene.Crosshair, nil},
default_scene: {SmartHomeFirmware.Display.Scene.Welcome, nil},
size: {800, 480},
opts: [scale: 1.0],
drivers: [
%{
module: Scenic.Driver.Nerves.Rpi
},
]
}
4 changes: 3 additions & 1 deletion config/target.exs
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,6 @@ config :mdns_lite,
# of this file so it overrides the configuration defined above.
# Uncomment to use target specific configurations

# import_config "#{Mix.target()}.exs"
if Mix.target() == :rpi3 do
import_config "#{Mix.target()}.exs"
end
Empty file.
13 changes: 13 additions & 0 deletions lib/smart_home_firmware/display/scene/welcome.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule SmartHomeFirmware.Display.Scene.Welcome do
use Scenic.Scene
alias Scenic.Graph
import Scenic.Primitives
import Scenic.Components

@graph Graph.build()
|> text("Hello World!", font_size: 22, translate: {20, 80})

def init(_scene_args, _opts) do
{:ok, @graph, push: @graph}
end
end
17 changes: 17 additions & 0 deletions lib/smart_home_firmware/display/supervisor.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
defmodule SmartHomeFirmware.Display do
use Supervisor

def start_link(opts) do
Supervisor.start_link(__MODULE__, opts, name: __MODULE__)
end

@impl true
def init(_opts) do
main_viewport_config = Application.get_env(:smart_home_firmware, :viewport)
children = [
{Scenic, viewports: [main_viewport_config]}
]

Supervisor.init(children, strategy: :one_for_one)
end
end
2 changes: 1 addition & 1 deletion lib/smart_home_firmware/feature_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule SmartHomeFirmware.FeatureManager do
# Here we define the flags and associated modules
@feature_flags [
lock: SmartHomeFirmware.Lock,
display: SmartHomeFirmware.NotImplemented
display: SmartHomeFirmware.Display
]

use GenServer
Expand Down
7 changes: 7 additions & 0 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ defmodule SmartHomeFirmware.MixProject do
{:nerves_pack, "~> 0.2", targets: @all_targets},
{:nerves_io_pn532, git: "https://github.com/dwyl/nerves_io_pn532"},

# Scenic Dependencies
{:scenic, "~> 0.10", targets: [:host, :rpi3]},
{:scenic_sensor, "~> 0.7", targets: [:host, :rpi3]},
#Driver for host only
{:scenic_driver_glfw, "~> 0.10", targets: :host},
#RPi driver - NO RPi4 Support! (Yet)
{:scenic_driver_nerves_rpi, "~> 0.10", targets: :rpi3},

# Dependencies for specific targets
{:nerves_system_rpi, "~> 1.12", runtime: false, targets: :rpi},
Expand Down
6 changes: 6 additions & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"dns": {:hex, :dns, "2.1.2", "81c46d39f7934f0e73368355126e4266762cf227ba61d5889635d83b2d64a493", [:mix], [{:socket, "~> 0.3.13", [hex: :socket, repo: "hexpm", optional: false]}], "hexpm", "6818589d8e59c03a2c73001e5cd7a957f99c30a796021aa32445ea14d0f3356b"},
"elixir_make": {:hex, :elixir_make, "0.6.0", "38349f3e29aff4864352084fc736fa7fa0f2995a819a737554f7ebd28b85aaab", [:mix], [], "hexpm", "d522695b93b7f0b4c0fcb2dfe73a6b905b1c301226a5a55cb42e5b14d509e050"},
"excoveralls": {:hex, :excoveralls, "0.13.0", "4e1b7cc4e0351d8d16e9be21b0345a7e165798ee5319c7800b9138ce17e0b38e", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "fe2a56c8909564e2e6764765878d7d5e141f2af3bc8ff3b018a68ee2a218fced"},
"font_metrics": {:hex, :font_metrics, "0.3.1", "025ff9957040eb4d6430c306a4445bad5d9f43ec24448c1647df7cb63b5dd88c", [:mix], [{:msgpax, "~> 2.2", [hex: :msgpax, repo: "hexpm", optional: false]}], "hexpm", "6dff6525d49d84173ce20b4cba2457b2289e83bcc2be19c2aa761dbe9f631033"},
"gen_state_machine": {:hex, :gen_state_machine, "2.1.0", "a38b0e53fad812d29ec149f0d354da5d1bc0d7222c3711f3a0bd5aa608b42992", [:mix], [], "hexpm", "ae367038808db25cee2f2c4b8d0531522ea587c4995eb6f96ee73410a60fa06b"},
"hackney": {:hex, :hackney, "1.16.0", "5096ac8e823e3a441477b2d187e30dd3fff1a82991a806b2003845ce72ce2d84", [:rebar3], [{:certifi, "2.5.2", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.1", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.3.0", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.6", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "3bf0bebbd5d3092a3543b783bf065165fa5d3ad4b899b836810e513064134e18"},
"httpoison": {:hex, :httpoison, "1.7.0", "abba7d086233c2d8574726227b6c2c4f6e53c4deae7fe5f6de531162ce9929a0", [:mix], [{:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: false]}], "hexpm", "975cc87c845a103d3d1ea1ccfd68a2700c211a434d8428b10c323dc95dc5b980"},
Expand All @@ -12,6 +13,7 @@
"mdns_lite": {:hex, :mdns_lite, "0.6.3", "6d5202ed6e985b2195e8f6cac0c81b7df738c9eab89c694ccaf3ca85af5689f0", [:mix], [{:dns, "~> 2.1", [hex: :dns, repo: "hexpm", optional: false]}, {:vintage_net, "~> 0.7", [hex: :vintage_net, repo: "hexpm", optional: true]}], "hexpm", "8552fae85a81ab4d808993eb573775e68e11508e5420b0a5c5d799526cf51d24"},
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
"msgpax": {:hex, :msgpax, "2.2.4", "7b3790ef684089076b63c0f08c2f4b079c6311daeb006b69e4ed2bf67518291e", [:mix], [{:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "b351b6d992d79624a8430a99d21a41b36b1b90edf84326a294e9f4a2de11f089"},
"muontrap": {:hex, :muontrap, "0.6.0", "0f73fcd7c1c7a98a93744b18ca66b718d75450d2d92cd3e535579ae72c76e7f2", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "b5548a8dfb787b4eb7612e0650e9b460aa5d137fd101a0b67da68014631b198c"},
"nerves": {:hex, :nerves, "1.6.3", "ac0155508a6eb0e3c8e92a6c7c0524dbe38dcc289e89cf0ef129df673a89f2ea", [:mix], [{:distillery, "~> 2.1", [hex: :distillery, repo: "hexpm", optional: true]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: true]}], "hexpm", "ce150c9aaf2ccffb2cf2fbfe1da462f363ceb322ee515c0a23394235346f71fc"},
"nerves_firmware_ssh": {:hex, :nerves_firmware_ssh, "0.4.5", "fcf9471bfc65165c4a06bd5065ef397acb073168c0d7afdbf561b6554ae368dd", [:mix], [{:nerves_runtime, "~> 0.6", [hex: :nerves_runtime, repo: "hexpm", optional: false]}], "hexpm", "d463fd9c3c6a658a60735f0bb9824af9362c548224a3c7c46ced7b1b0e966c3f"},
Expand All @@ -38,6 +40,10 @@
"phoenix_client": {:hex, :phoenix_client, "0.11.0", "9e95268313bb266377bafca516e09ff60b24f679ad1f6398b6c303648841002d", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:websocket_client, "~> 1.3", [hex: :websocket_client, repo: "hexpm", optional: false]}], "hexpm", "07d393c91abd0e7c35ce01f19a57faca1d9c2e59098d4d9368ad6a5b3f790797"},
"phoenix_gen_socket_client": {:hex, :phoenix_gen_socket_client, "3.0.0", "1a79d874d64cd635475de2ee18d6253964d304a624f57fae3a9acb44ae8b8702", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:websocket_client, "~> 1.2", [hex: :websocket_client, repo: "hexpm", optional: true]}], "hexpm", "124d72c6f82c7381777522d5491150901acacb74f6e142be3d62aa2ed253eb48"},
"ring_logger": {:hex, :ring_logger, "0.8.0", "b1baddc269099b2afe2ea3a87b8e2b71e57331c0000038ae55090068aac679db", [:mix], [], "hexpm", "9b2f482e4346c13c11ef555f898202d0ddbfda6e2354e5c6e0559d2b4e0cf781"},
"scenic": {:hex, :scenic, "0.10.2", "f4f0a00eed677ac50a7b297375c0323d03f4273580f17c50b877abfaf0c6dc1f", [:make, :mix], [{:elixir_make, "~> 0.5", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:font_metrics, "~> 0.3", [hex: :font_metrics, repo: "hexpm", optional: false]}], "hexpm", "6f1445a77b9ad6bac73ef0677a6c133685042eb69cc666b1516a0a037a76e8f4"},
"scenic_driver_glfw": {:hex, :scenic_driver_glfw, "0.10.1", "df7a11bc1d23415dd48c7796a70a6ad98b9cf77554078d79115d6c6e58b87eda", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:scenic, "~> 0.10", [hex: :scenic, repo: "hexpm", optional: false]}], "hexpm", "d2f2ef0a1d099a6e1904616c0a95ff0fc554342cf7936e6bb73c2d7027e7557e"},
"scenic_driver_nerves_rpi": {:hex, :scenic_driver_nerves_rpi, "0.10.1", "1479d24b9e91e989eef28d6bc6be6cb864e7a60cfb831bef53ead6a37b1502ac", [:make, :mix], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:scenic, "~> 0.10", [hex: :scenic, repo: "hexpm", optional: false]}], "hexpm", "4a3995b3eb4a246fa9e1f282b56885a1f2bc41a6bf57bd98ce10437365f6fa35"},
"scenic_sensor": {:hex, :scenic_sensor, "0.7.0", "a12aed7596fbab025a535f912325da5a087ff704e96f7acb274c3034d832f9ce", [:mix], [], "hexpm", "424b0663b7b2e2ea309231e384f321e35b1a693397f8b49913330405d36ab558"},
"shoehorn": {:hex, :shoehorn, "0.6.0", "f9a1b7d6212cf18ba91c4f71c26076059df33cea4db2eb3c098bfa6673349412", [:mix], [{:distillery, "~> 2.1", [hex: :distillery, repo: "hexpm", optional: true]}], "hexpm", "e54a1f58a121caf8f0f3a355686b2661258b1bc0d4fffef8923bd7b11c2f9d79"},
"socket": {:hex, :socket, "0.3.13", "98a2ab20ce17f95fb512c5cadddba32b57273e0d2dba2d2e5f976c5969d0c632", [], [], "hexpm", "f82ea9833ef49dde272e6568ab8aac657a636acb4cf44a7de8a935acb8957c2e"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.6", "cf344f5692c82d2cd7554f5ec8fd961548d4fd09e7d22f5b62482e5aeaebd4b0", [:make, :mix, :rebar3], [], "hexpm", "bdb0d2471f453c88ff3908e7686f86f9be327d065cc1ec16fa4540197ea04680"},
Expand Down

0 comments on commit c34167f

Please sign in to comment.