diff --git a/veml6030/.formatter.exs b/veml6030/.formatter.exs new file mode 100644 index 0000000..d2cda26 --- /dev/null +++ b/veml6030/.formatter.exs @@ -0,0 +1,4 @@ +# Used by "mix format" +[ + inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"] +] diff --git a/veml6030/.gitignore b/veml6030/.gitignore new file mode 100644 index 0000000..e20cbae --- /dev/null +++ b/veml6030/.gitignore @@ -0,0 +1,26 @@ +# The directory Mix will write compiled artifacts to. +/_build/ + +# If you run "mix test --cover", coverage assets end up here. +/cover/ + +# The directory Mix downloads your dependencies sources to. +/deps/ + +# Where third-party dependencies like ExDoc output generated docs. +/doc/ + +# Ignore .fetch files in case you like to edit your project deps locally. +/.fetch + +# If the VM crashes, it generates a dump, let's ignore it too. +erl_crash.dump + +# Also ignore archive artifacts (built via "mix archive.build"). +*.ez + +# Ignore package tarball (built via "mix hex.build"). +veml6030-*.tar + +# Temporary files, for example, from tests. +/tmp/ diff --git a/veml6030/README.md b/veml6030/README.md new file mode 100644 index 0000000..481c543 --- /dev/null +++ b/veml6030/README.md @@ -0,0 +1,21 @@ +# Veml6030 + +**TODO: Add description** + +## Installation + +If [available in Hex](https://hex.pm/docs/publish), the package can be installed +by adding `veml6030` to your list of dependencies in `mix.exs`: + +```elixir +def deps do + [ + {:veml6030, "~> 0.1.0"} + ] +end +``` + +Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_doc) +and published on [HexDocs](https://hexdocs.pm). Once published, the docs can +be found at . + diff --git a/veml6030/config.ex b/veml6030/config.ex new file mode 100644 index 0000000..244791b --- /dev/null +++ b/veml6030/config.ex @@ -0,0 +1,28 @@ +defmodule VEML6030.Config do + defstruct [ + gain: :gain_1_4th, + int_time: :it_100_ms, + shutdown: false, + interrupt: false + ] + + def new, do: struct[__MODULE__] + def new(opts), do: struct[__MODULE__, opts] + + def to_integer(config) do + reserved = 0 + persistence_protect = 0 + + <> = << + reserve::3, + gain(config.gain)::2, + reserved::1, + int_time(config.int_time)::4, + persistence_protect::2, + reserved::2 + interrupt(config.interrupt)::1, + shutdown(config.shutdown)::disk_log_1>> + + integer + end +end diff --git a/veml6030/lib/veml6030.ex b/veml6030/lib/veml6030.ex new file mode 100644 index 0000000..2ebf829 --- /dev/null +++ b/veml6030/lib/veml6030.ex @@ -0,0 +1,18 @@ +defmodule Veml6030 do + @moduledoc """ + Documentation for `Veml6030`. + """ + + @doc """ + Hello world. + + ## Examples + + iex> Veml6030.hello() + :world + + """ + def hello do + :world + end +end diff --git a/veml6030/mix.exs b/veml6030/mix.exs new file mode 100644 index 0000000..c06d887 --- /dev/null +++ b/veml6030/mix.exs @@ -0,0 +1,27 @@ +defmodule Veml6030.MixProject do + use Mix.Project + + def project do + [ + app: :veml6030, + version: "0.1.0", + elixir: "~> 1.13", + start_permanent: Mix.env() == :prod, + deps: deps() + ] + end + + # Run "mix help compile.app" to learn about applications. + def application do + [ + extra_applications: [:logger] + ] + end + + # Run "mix help deps" to learn about dependencies. + defp deps do + [ + {:circuits_i2c, "~> 1.0"} + ] + end +end diff --git a/veml6030/test/test_helper.exs b/veml6030/test/test_helper.exs new file mode 100644 index 0000000..869559e --- /dev/null +++ b/veml6030/test/test_helper.exs @@ -0,0 +1 @@ +ExUnit.start() diff --git a/veml6030/test/veml6030_test.exs b/veml6030/test/veml6030_test.exs new file mode 100644 index 0000000..1e7094a --- /dev/null +++ b/veml6030/test/veml6030_test.exs @@ -0,0 +1,8 @@ +defmodule Veml6030Test do + use ExUnit.Case + doctest Veml6030 + + test "greets the world" do + assert Veml6030.hello() == :world + end +end