Skip to content

nerves-project/nerves_leds

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Nerves.Leds

Build Status Hex version

Simple API to drive leds exposed by linux /sys/class/leds. Designed for use with Nerves, but works on any distribution of Linux with /sys/class/leds.

Installation

Add nerves_leds to your list of dependencies in mix.exs:

def deps do
  [{:nerves_leds, "~> 0.8.1"}]
end

Configuration & Usage

Configure your LEDs mappings:

# config/config.exs
config :nerves_leds, names: [ error: "led0", connect: "led1" ]

Now, you can use predefined states in your app:

alias Nerves.Leds

Leds.set(connect: true)
Leds.set(connect: :heartbeat)
Leds.set(connect: false, error: :slowblink)

You can also define your own states:

# config/config.exs
config :nerves_leds, states: [
    fastblink: [ trigger: "timer", delay_off: 40, delay_on: 30 ],
    blip: [ trigger: "timer", delay_off: 1000, delay_on: 100 ]]

For situations where the number of LEDs are not known at compile time, you can enumerate the LEDs:

Leds.enumerate()

More Details

See the documentation for the full description of the API and configuration.