started with veml6030 app
parent
80593baf75
commit
1ab19a8bd1
|
@ -0,0 +1,4 @@
|
|||
# Used by "mix format"
|
||||
[
|
||||
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
|
||||
]
|
|
@ -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/
|
|
@ -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 <https://hexdocs.pm/veml6030>.
|
||||
|
|
@ -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
|
||||
|
||||
<<integer::16>> = <<
|
||||
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
|
|
@ -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
|
|
@ -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
|
|
@ -0,0 +1 @@
|
|||
ExUnit.start()
|
|
@ -0,0 +1,8 @@
|
|||
defmodule Veml6030Test do
|
||||
use ExUnit.Case
|
||||
doctest Veml6030
|
||||
|
||||
test "greets the world" do
|
||||
assert Veml6030.hello() == :world
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue