deviceapi

package
v0.0.0-...-9e2e3ce Latest Latest
Warning

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

Go to latest
Published: May 20, 2017 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Overview

The effect package defines data structures and functions to export the functionality of devices, giving functions a textual name, description and providing an interface to configure their parameters

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColorLampEffectFactory

type ColorLampEffectFactory func(c devices.ColorLamp) Effect

type Config

type Config interface{}

Config is a type used to configure the parameters of a function supported by a lamp this could be a color to be set or define the speed of an animation

func DelayConfigFactory

func DelayConfigFactory() Config

DelayConfigFactory is used to create a preconfigured DelayConfig that configures a delay of 30ms appropriate for smooth but slow animations

func EmptyConfigFactory

func EmptyConfigFactory() Config

EmptyConfigFactory creates an EmptyEffectConfig

type DelayConfig

type DelayConfig struct {
	Delay string
}

DelayConfig sets the Delay between steps of an animation

type DeviceEffectFactory

type DeviceEffectFactory func(p devices.Device) Effect

type DimLampEffectFactory

type DimLampEffectFactory func(d devices.DimLamp) Effect

type Effect

type Effect interface {
	Apply(config Config) error
}

Effect are all types that provide a configureable Apply function

type EffectFunc

type EffectFunc func(config Config) error

EffectFunc turns any function taking a config into an Effect

func (EffectFunc) Apply

func (f EffectFunc) Apply(config Config) error

Apply let's EffectFunc implement the Effect interface

type EmptyConfig

type EmptyConfig struct{}

EmptyConfig is used to configure effects that don't have any parameters

type Info

type Info struct {
	Name        string
	Description string
	Config      Config
}

Info holds metadata on an effect including its current configuration

type MatrixLampEffectFactory

type MatrixLampEffectFactory func(s devices.MatrixLamp) Effect

type Registration

type Registration struct {
	Info          Info
	EffectFactory interface{}
	ConfigFactory func() Config
}

Registration holds both metadata about a registered effect and also stores the ConfigFactory that may be used to generate default configurations for this effect. Usually all fields in the generated config can be customized

func (*Registration) Compatible

func (e *Registration) Compatible(lamp devices.Device) bool

Compatible checks whether a particular Registration is compatible with the given device

type Registry

type Registry struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Registry is the type used to handle registration of effects registered effects can then automatically be paired with compatible devices

var DefaultRegistry *Registry

DefaultRegistry is the default package History and for many applications no other Registry needs to be created

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new Registry, usually using the DefaultRegistry should be preferred

func (*Registry) CompatibleEffects

func (r *Registry) CompatibleEffects(lamp devices.Device) []Info

CompatibleEffects returns a slice of all compatible effects for the given device

func (*Registry) Config

func (r *Registry) Config(name string) Config

Config creates a default config for the effect registered under the given name or nil if no such effect exists

func (*Registry) Effect

func (r *Registry) Effect(name string, device devices.Device) Effect

Effect finds an effect in the registry by name and checks its compatibility with the given device. If the effect doesn't exist or is incompatible with the given device this function returns nil

func (*Registry) Info

func (r *Registry) Info(name string) *Info

Info returns the information on the effect registered under the given name or nil if no such effect exists

func (*Registry) Register

func (r *Registry) Register(reg *Registration) error

Register registers an effect and populates the current, though usually inactive, effect config with the default generated by the registered ConfigFactory

type StripeLampEffectFactory

type StripeLampEffectFactory func(s devices.StripeLamp) Effect

type WordClockEffectFactory

type WordClockEffectFactory func(s devices.WordClock) Effect

Jump to

Keyboard shortcuts

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