mpl3115a2/lib/mpl3115a2.ex

31 lines
765 B
Elixir
Raw Normal View History

2019-10-07 13:04:11 +13:00
defmodule MPL3115A2 do
@moduledoc """
2019-10-07 15:10:06 +13:00
MPL3115A2 Driver for Elixir using ElixirALE.
2019-10-07 13:04:11 +13:00
2019-10-07 15:10:06 +13:00
## Usage:
Add your devices to your config like so:
2019-10-07 13:04:11 +13:00
2019-10-07 15:10:06 +13:00
config :mpl3115a2,
devices: [
%{bus: "i2c-1", address: 0x3d, reset_pin: 17}
]
2019-10-07 13:04:11 +13:00
2019-10-07 15:10:06 +13:00
Then use the functions in [MPL3115A2.Device] to send image data.
Pretty simple.
"""
2019-10-07 13:04:11 +13:00
2019-10-07 15:10:06 +13:00
@doc """
Connect to an MPL3115A2 device.
"""
def connect(config),
do: Supervisor.start_child(MPL3115A2.Supervisor, {MPL3115A2.Device, config})
@doc """
Disconnect an MPL3115A2 device.
2019-10-07 13:04:11 +13:00
"""
2019-10-07 15:10:06 +13:00
def disconnect(device_name) do
Supervisor.terminate_child(MPL3115A2.Supervisor, {MPL3115A2.Device, device_name})
Supervisor.delete_child(MPL3115A2.Supervisor, {MPL3115A2.Device, device_name})
2019-10-07 13:04:11 +13:00
end
end