Current section
2 Versions
Jump to
Current section
2 Versions
Compare versions
4
files changed
+71
additions
-54
deletions
| @@ -0,0 +1 @@ | |
| 1 | + 0.2.0 |
| @@ -4,11 +4,11 @@ | |
| 4 4 | {<<"elixir">>,<<"~> 1.5">>}. |
| 5 5 | {<<"files">>, |
| 6 6 | [<<"lib">>,<<"lib/exred_node_rpiphoto.ex">>,<<"mix.exs">>,<<"README.md">>, |
| 7 | - <<"LICENSE">>]}. |
| 7 | + <<"LICENSE">>,<<"VERSION">>]}. |
| 8 8 | {<<"licenses">>,[<<"MIT">>]}. |
| 9 9 | {<<"links">>, |
| 10 10 | [{<<"Exred">>,<<"http://exred.org">>}, |
| 11 | - {<<"GitHub">>,<<"https://github.com/exredorg/exred_node_rpiphoto">>}]}. |
| 11 | + {<<"GitHub">>,<<"https://github.com/exredorg/exred_node_rpiphoto.git">>}]}. |
| 12 12 | {<<"name">>,<<"exred_node_rpiphoto">>}. |
| 13 13 | {<<"requirements">>, |
| 14 14 | [[{<<"app">>,<<"porcelain">>}, |
| @@ -16,9 +16,9 @@ | |
| 16 16 | {<<"optional">>,false}, |
| 17 17 | {<<"repository">>,<<"hexpm">>}, |
| 18 18 | {<<"requirement">>,<<"~> 2.0">>}], |
| 19 | - [{<<"app">>,<<"exred_library">>}, |
| 20 | - {<<"name">>,<<"exred_library">>}, |
| 19 | + [{<<"app">>,<<"exred_nodeprototype">>}, |
| 20 | + {<<"name">>,<<"exred_nodeprototype">>}, |
| 21 21 | {<<"optional">>,false}, |
| 22 22 | {<<"repository">>,<<"hexpm">>}, |
| 23 | - {<<"requirement">>,<<"~> 0.1.11">>}]]}. |
| 24 | - {<<"version">>,<<"0.1.6">>}. |
| 23 | + {<<"requirement">>,<<"~> 0.2">>}]]}. |
| 24 | + {<<"version">>,<<"0.2.0">>}. |
| @@ -1,8 +1,8 @@ | |
| 1 1 | defmodule Exred.Node.Rpiphoto do |
| 2 2 | @moduledoc """ |
| 3 3 | Takes a photo using the Raspberry PI's camera module |
| 4 | - |
| 5 | - **Incoming message format** |
| 4 | + |
| 5 | + **Incoming message format** |
| 6 6 | ```elixir |
| 7 7 | msg = %{ |
| 8 8 | payload :: any, |
| @@ -70,60 +70,75 @@ defmodule Exred.Node.Rpiphoto do | |
| 70 70 | type: "selector", |
| 71 71 | value: "average", |
| 72 72 | attrs: %{options: ["average", "spot", "backlit", "matrix"]} |
| 73 | - }, |
| 73 | + } |
| 74 74 | } |
| 75 75 | @ui_attributes %{ |
| 76 76 | left_icon: "photo_camera", |
| 77 77 | config_order: [:name, :metering, :width, :height, :horizontal_flip, :vertical_flip, :filename] |
| 78 78 | } |
| 79 | - |
| 80 | - |
| 81 | - use Exred.Library.NodePrototype |
| 79 | + |
| 80 | + use Exred.NodePrototype |
| 82 81 | alias Porcelain.Result |
| 83 82 | require Logger |
| 84 83 | |
| 85 | - |
| 86 84 | @impl true |
| 87 85 | def handle_msg(%{} = msg, state) do |
| 88 | - filename = Map.get msg, :filename, state.config.filename.value |
| 89 | - width = Map.get msg, :width, state.config.width.value |
| 90 | - height = Map.get msg, :height, state.config.height.value |
| 91 | - metering = Map.get msg, :metering, state.config.metering.value |
| 92 | - |
| 93 | - horizontal_flip = case Map.get(msg, :horizontal_flip, state.config.horizontal_flip.value) do |
| 94 | - "true" -> "-hf" |
| 95 | - _ -> "" |
| 96 | - end |
| 97 | - vertical_flip = case Map.get(msg, :vertical_flip, state.config.vertical_flip.value) do |
| 98 | - "true" -> "-vf" |
| 99 | - _ -> "" |
| 100 | - end |
| 101 | - |
| 102 | - cmd = [ "/usr/bin/raspistill", |
| 103 | - "-dt", |
| 104 | - "-v" , |
| 105 | - "-o", filename, |
| 106 | - "-w", width, |
| 107 | - "-h", height, |
| 108 | - "-mm", metering, |
| 109 | - "-ex", "sports", |
| 110 | - "-awb", "cloud", |
| 111 | - "--nopreview", |
| 112 | - horizontal_flip, |
| 113 | - vertical_flip, |
| 114 | - "--timeout", "100" |
| 115 | - ] |> Enum.join(" ") |
| 116 | - |
| 117 | - res = %Result{out: output, status: status} = Porcelain.shell( cmd ) |
| 118 | - Logger.info "#{__MODULE__} raspistill return status: #{inspect status}" |
| 119 | - out = Map.put msg, :payload, status |
| 86 | + filename = Map.get(msg, :filename, state.config.filename.value) |
| 87 | + width = Map.get(msg, :width, state.config.width.value) |
| 88 | + height = Map.get(msg, :height, state.config.height.value) |
| 89 | + metering = Map.get(msg, :metering, state.config.metering.value) |
| 90 | + |
| 91 | + horizontal_flip = |
| 92 | + case Map.get(msg, :horizontal_flip, state.config.horizontal_flip.value) do |
| 93 | + "true" -> "-hf" |
| 94 | + _ -> "" |
| 95 | + end |
| 96 | + |
| 97 | + vertical_flip = |
| 98 | + case Map.get(msg, :vertical_flip, state.config.vertical_flip.value) do |
| 99 | + "true" -> "-vf" |
| 100 | + _ -> "" |
| 101 | + end |
| 102 | + |
| 103 | + cmd = |
| 104 | + [ |
| 105 | + "/usr/bin/raspistill", |
| 106 | + "-dt", |
| 107 | + "-v", |
| 108 | + "-o", |
| 109 | + filename, |
| 110 | + "-w", |
| 111 | + width, |
| 112 | + "-h", |
| 113 | + height, |
| 114 | + "-mm", |
| 115 | + metering, |
| 116 | + "-ex", |
| 117 | + "sports", |
| 118 | + "-awb", |
| 119 | + "cloud", |
| 120 | + "--nopreview", |
| 121 | + horizontal_flip, |
| 122 | + vertical_flip, |
| 123 | + "--timeout", |
| 124 | + "100" |
| 125 | + ] |
| 126 | + |> Enum.join(" ") |
| 127 | + |
| 128 | + res = %Result{out: output, status: status} = Porcelain.shell(cmd) |
| 129 | + Logger.info("#{__MODULE__} raspistill return status: #{inspect(status)}") |
| 130 | + out = Map.put(msg, :payload, status) |
| 120 131 | |
| 121 132 | {out, state} |
| 122 133 | end |
| 123 134 | |
| 124 135 | def handle_msg(msg, state) do |
| 125 | - Logger.warn "UNHANDLED MSG node: #{state.node_id} #{get_in(state.config, [:name, :value])} msg: #{inspect msg}" |
| 136 | + Logger.warn( |
| 137 | + "UNHANDLED MSG node: #{state.node_id} #{get_in(state.config, [:name, :value])} msg: #{ |
| 138 | + inspect(msg) |
| 139 | + }" |
| 140 | + ) |
| 141 | + |
| 126 142 | {nil, state} |
| 127 143 | end |
| 128 | - |
| 129 144 | end |
| @@ -1,15 +1,15 @@ | |
| 1 1 | defmodule Exred.Node.Rpiphoto.Mixfile do |
| 2 2 | use Mix.Project |
| 3 3 | |
| 4 | - |
| 5 4 | @description "Takes photos with the RaspberryPi Camera module" |
| 5 | + @version File.read!("VERSION") |> String.trim() |
| 6 6 | |
| 7 7 | def project do |
| 8 8 | [ |
| 9 9 | app: :exred_node_rpiphoto, |
| 10 | - version: "0.1.6", |
| 10 | + version: @version, |
| 11 11 | elixir: "~> 1.5", |
| 12 | - start_permanent: Mix.env == :prod, |
| 12 | + start_permanent: Mix.env() == :prod, |
| 13 13 | deps: deps(), |
| 14 14 | description: @description, |
| 15 15 | package: package(), |
| @@ -22,6 +22,7 @@ defmodule Exred.Node.Rpiphoto.Mixfile do | |
| 22 22 | test: "test --no-start" |
| 23 23 | ] |
| 24 24 | end |
| 25 | + |
| 25 26 | # Run "mix help compile.app" to learn about applications. |
| 26 27 | def application do |
| 27 28 | [ |
| @@ -32,8 +33,8 @@ defmodule Exred.Node.Rpiphoto.Mixfile do | |
| 32 33 | # Run "mix help deps" to learn about dependencies. |
| 33 34 | defp deps do |
| 34 35 | [ |
| 35 | - {:ex_doc, "~> 0.18.0", only: :dev, runtime: false}, |
| 36 | - {:exred_library, "~> 0.1.11"}, |
| 36 | + {:ex_doc, "~> 0.19.0", only: :dev, runtime: false}, |
| 37 | + {:exred_nodeprototype, "~> 0.2"}, |
| 37 38 | {:porcelain, "~> 2.0"} |
| 38 39 | ] |
| 39 40 | end |
| @@ -43,10 +44,10 @@ defmodule Exred.Node.Rpiphoto.Mixfile do | |
| 43 44 | licenses: ["MIT"], |
| 44 45 | maintainers: ["Zsolt Keszthelyi"], |
| 45 46 | links: %{ |
| 46 | - "GitHub" => "https://github.com/exredorg/exred_node_rpiphoto", |
| 47 | + "GitHub" => "https://github.com/exredorg/exred_node_rpiphoto.git", |
| 47 48 | "Exred" => "http://exred.org" |
| 48 49 | }, |
| 49 | - files: ["lib", "mix.exs", "README.md", "LICENSE"] |
| 50 | + files: ["lib", "mix.exs", "README.md", "LICENSE", "VERSION"] |
| 50 51 | } |
| 51 52 | end |
| 52 53 | end |