lightd

package
v0.0.0-...-f2f0a72 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2016 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package lightd implements a daemon that is able to process effects send to it and send them to an external, simpler driver program. It also manages the locking of the light resource.

The external driver program should fulfill the following requirements For eulenfunk, the driver program is called radio-led.

lightd can be controlled by a simple line based network protocol, which currently supports the following commands:

!lock -- Try to acquire lock or block until available. !unlock -- Give back lock. !close -- Close the connection. <effect> -- Lines starting without ! are parsed as effect spec.

<effect> can be one of the following:

{<r>,<g>,<b>}
blend{<src-color>|<dst-color>|<duration>}
flash{<duration>|<color>|<repeat>}
fire{<duration>|<color>|<repeat>}
fade{<duration>|<color>|<repeat>}

where <*-color> can be:

{<r>,<g>,<b>}

and where <duration> is something time.ParseDuration() understands. <repeat> is a simple integer.

Examples:

{255,0,255}                     -- The world needs more solid pink.
fire{1ms|{255,255,255}|0}       -- Warm fire effect.
blend{{255,0,0}|{0,255,0}|2s}   -- Blend from red to green.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(cfg *Config, ctx context.Context) error

Run starts lightd with the options specified in `cfg`, cancelling services when `ctx` is cancelled.

func Send

func Send(cfg *Config, effects ...string) error

Send one or more effects to lightd.

Types

type Config

type Config struct {
	// Host where lightd will run
	Host string
	// Port wich lightd will listen on
	Port int
	// DriverBinary is the name of the binary lightd will output rgb triples on.
	DriverBinary string
}

Config offers some adjustment screws to the user of lightd

type Locker

type Locker struct {
	// contains filtered or unexported fields
}

Locker is a utility to hold a lock on the LED resource

func NewLocker

func NewLocker(cfg *Config) (*Locker, error)

NewLocker will create a new Locker connected to the lightd at `cfg.Host` and `cfg.Port`.

func (*Locker) Close

func (lk *Locker) Close() error

Close will close the connection used by Locker NOTE: No Unlock is done!

func (*Locker) Lock

func (lk *Locker) Lock() error

Lock will give you exclusive access to the LED or waits until it can be locked.

func (*Locker) Unlock

func (lk *Locker) Unlock() error

Unlock returns the exclusive access right to the next waiting or lightd.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL