started with veml6030 app

master
Stefan Haslinger 2022-03-17 14:50:17 +01:00
parent 80593baf75
commit 1ab19a8bd1
8 changed files with 133 additions and 0 deletions

4
veml6030/.formatter.exs Normal file
View File

@ -0,0 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]

26
veml6030/.gitignore vendored Normal file
View File

@ -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/

21
veml6030/README.md Normal file
View File

@ -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>.

28
veml6030/config.ex Normal file
View File

@ -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

18
veml6030/lib/veml6030.ex Normal file
View File

@ -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

27
veml6030/mix.exs Normal file
View File

@ -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

View File

@ -0,0 +1 @@
ExUnit.start()

View File

@ -0,0 +1,8 @@
defmodule Veml6030Test do
use ExUnit.Case
doctest Veml6030
test "greets the world" do
assert Veml6030.hello() == :world
end
end