lor

package
v0.0.3 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

This section is empty.

Types

type Channel

type Channel byte

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

type Controller

type Controller struct {
	Unit Unit
	// contains filtered or unexported fields
}

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

func ControllerWithPort added in v0.0.3

func ControllerWithPort(unit Unit, port *serial.Port) *Controller

ControllerWithPort returns a *Controller using a given, pre-existing *serial.Port. This enables multiple Controller instances using a shared *serial.Port.

func (Controller) BulkFade

func (c Controller) BulkFade(m *Mask, from, to float64, dur time.Duration) error

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

func (Controller) BulkOn

func (c Controller) BulkOn(m *Mask) error

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

func (Controller) BulkSetBrightness

func (c Controller) BulkSetBrightness(m *Mask, val float64) error

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

func (Controller) BulkSetBrightnessAbs added in v0.0.2

func (c Controller) BulkSetBrightnessAbs(m *Mask, val byte) error

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

func (Controller) BulkSetEffect

func (c Controller) BulkSetEffect(m *Mask, effect Effect) error

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

func (Controller) Fade

func (c Controller) Fade(ch Channel, from, to float64, dur time.Duration) 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) 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) On

func (c Controller) On(ch Channel) error

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

func (*Controller) OpenPort

func (c *Controller) OpenPort(conf *serial.Config) error

OpenPort opens a serial port with the given serial.Config object. Once opened, OpenPort will send an initial heartbeat (using #SendHeartbeat) to test the connection.

func (Controller) SetBrightness

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

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

func (Controller) SetBrightnessAbs added in v0.0.2

func (c Controller) SetBrightnessAbs(ch Channel, val byte) error

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

func (Controller) SetEffect

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

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

func (Controller) WriteHeartbeat

func (c Controller) WriteHeartbeat() error

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

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