lor

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultHeartbeatRate = time.Millisecond * 500

DefaultHeartbeatRate represents the timing rate at which LOR vendor software sends a heartbeat to the hardware. This has been determined by monitoring the serial port connection.

Variables

This section is empty.

Functions

func Fade added in v0.3.0

func Fade(unit Unit, ch Channel, from, to float64, dur time.Duration) []byte

func FadeWithEffect added in v0.3.0

func FadeWithEffect(unit Unit, ch Channel, from, to float64, dur time.Duration, effect Effect) []byte

func Heartbeat added in v0.3.0

func Heartbeat() []byte

func MaskedFade added in v0.3.0

func MaskedFade(unit Unit, mask *Mask, from, to float64, dur time.Duration) []byte

func MaskedOn added in v0.3.0

func MaskedOn(unit Unit, mask *Mask) []byte

func MaskedSetBrightness added in v0.3.0

func MaskedSetBrightness(unit Unit, mask *Mask, val float64) []byte

func MaskedSetEffect added in v0.3.0

func MaskedSetEffect(unit Unit, mask *Mask, effect Effect) []byte

func On added in v0.3.0

func On(unit Unit, ch Channel) []byte

func SetBrightness added in v0.3.0

func SetBrightness(unit Unit, ch Channel, val float64) []byte

func SetEffect added in v0.3.0

func SetEffect(unit Unit, ch Channel, effect Effect) []byte

Types

type Channel

type Channel byte

Channel represents a unique, addressable channel belonging to a given Controller's namespace.

type Controller

type Controller struct {
	io.Writer
	Unit Unit
}

Controller represents a LOR unit. ID is the unit's network ID as externally configured.

func NewController added in v0.3.0

func NewController(unit Unit, writer io.Writer) *Controller

NewController returns a new Controller instance using the given io.Writer.

func (Controller) Fade

func (c Controller) Fade(ch Channel, from, to float64, dur time.Duration) (n int, err error)

Fade writes a command payload to fade a channel's brightness from and to the specified values within the specified duration.

func (Controller) FadeWithEffect

func (c Controller) FadeWithEffect(ch Channel, from, to float64, dur time.Duration, effect Effect) (n int, err error)

FadeWithEffect writes a command payload to fade a channel's brightness from and to the specified values within the specified duration. The effect will be applied alongside the fade effect.

func (Controller) Heartbeat added in v0.3.0

func (c Controller) Heartbeat() (n int, err error)

Heartbeat writes a heartbeat payload to the currently open serial port.

func (Controller) MaskedFade added in v0.3.0

func (c Controller) MaskedFade(mask *Mask, from, to float64, dur time.Duration) (n int, err error)

MaskedFade writes a multi command payload to fade all masked channels brightness from and to the specified values within the specified duration.

func (Controller) MaskedOn added in v0.3.0

func (c Controller) MaskedOn(mask *Mask) (n int, err error)

MaskedOn writes a multi command payload to set all masked channels to 100% brightness. This saves 1 byte over a MaskedSetBrightness call.

func (Controller) MaskedSetBrightness added in v0.3.0

func (c Controller) MaskedSetBrightness(mask *Mask, val float64) (n int, err error)

MaskedSetBrightness writes a multi command payload to set all masked channels brightness to the specified value.

func (Controller) MaskedSetEffect added in v0.3.0

func (c Controller) MaskedSetEffect(mask *Mask, effect Effect) (n int, err error)

MaskedSetEffect writes a multi command payload to set all masked channels active effect.

func (Controller) On

func (c Controller) On(ch Channel) (n int, err error)

On writes a command payload to set the channel to 100% brightness. This saves 1 byte over a SetBrightness call.

func (Controller) SetBrightness

func (c Controller) SetBrightness(ch Channel, val float64) (n int, err error)

SetBrightness writes a command payload to set the channel's brightness to the specified value.

func (Controller) SetEffect

func (c Controller) SetEffect(ch Channel, effect Effect) (n int, err error)

SetEffect writes a command payload to set a channel's active effect. This will reset the channel's brightness.

type Effect

type Effect byte

Effect represents a pre-defined action within the LOR hardware.

const (
	// EffectTwinkle creates random fades with a slight delay.
	EffectTwinkle Effect = commandSetTwinkle
	// EffectShimmer creates rapid flashing with fading between flashes.
	EffectShimmer Effect = commandSetShimmer
)

type Mask

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

Mask represents a variable length bit mask.

func NewMask

func NewMask(bitLength byte) (*Mask, error)

NewMask returns a new mask sized for the specified bit length.

func (*Mask) Set

func (m *Mask) Set(ch Channel, val bool)

Set sets the bit value at the specified index to the specified value.

func (*Mask) SetAll

func (m *Mask) SetAll(val bool)

SetAll sets all bit values within the mask length to the specified value.

type Unit added in v0.0.3

type Unit byte

Unit represents a unique, addressable Controller.

Jump to

Keyboard shortcuts

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