Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dkuku/tm1638

nerves driver for tm1638 led controller
https://github.com/dkuku/tm1638

Last synced: about 2 months ago
JSON representation

nerves driver for tm1638 led controller

Awesome Lists containing this project

README

        

# TM1638 library for elixir/nerves

## Installation

If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `tm1638` to your list of dependencies in `mix.exs`:

```elixir
def deps do
[
{:tm1638, "~> 0.1.0"}
]
end
```

## Configration
```
config :tm1638,
stb: 22,
clk: 24,
dio: 23,
brightness: 3
```
or in livebook
```

Application.put_env(:tm1638, :stb, 22)
Application.put_env(:tm1638, :clk, 24)
Application.put_env(:tm1638, :dio, 23)
Application.put_env(:tm1638, :brightness, 3)
```

## Examples

### iterate over all 8 leds
```
{:ok, tm} = TM1638.init()

TM1638.clear_display(tm)
Enum.each(1..255, fn x ->
TM1638.leds(tm, x)
Process.sleep(10)
end)
TM1638.clear_display(tm)
```

### read buttons every 100 ms
```
defmodule GetData do
def get() do
{:ok, tm} = TM1638.init()
TM1638.get_data(tm)
end
end
Enum.each(1..100, fn _ ->
:timer.tc(GetData, :get, [])
|> IO.inspect
Process.sleep(100)
end)
```

### display moving text
```
TM1638.init()
|> elem(1)
|> TM1638.clear_display()
|> TM1638.display_moving_text("elixir is fun")
|> TM1638.clear_display()
```