devices

package
v1.0.1-0...-6f0197d Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CachedPin

func CachedPin(pin gpio.PinIO, reinforce int) gpio.PinIO

CachedPin creates a PinIO wrapper which reduces writing the same value to the wrapped object

This object is used to reduce unnecessary I2C traffic

Types

type BaseSensor

type BaseSensor struct {
	VUnit string
	// contains filtered or unexported fields
}

BaseSensor is a default implementation of the ISensor interface

func (*BaseSensor) AddListener

func (bs *BaseSensor) AddListener(listener ISensorValueListener)

func (*BaseSensor) NotifyListeners

func (bs *BaseSensor) NotifyListeners(value float64)

func (*BaseSensor) Unit

func (bs *BaseSensor) Unit() string

type CCS811Config

type CCS811Config struct {
	Address  int    `ini:"address"`
	Bus      string `ini:"i2cbus"`
	Duration int    `ini:"duration"`
}

CCS811Config holds the configuration data of a sensor

type Device

type Device interface {
	// Tick is called periodically
	Tick() error
	// Initialize is called upon startup
	Initialize() error
}

Device is the interface of a periodically operated peripheral controlled by wscgo.

type DimmerConfig

type DimmerConfig struct {
	PwmPin   string `ini:"pwmpin"`
	OnPin    string `ini:"onpin"`
	Speed    int32  `ini:"speed"`
	OnDelay  int    `ini:"ondelay"`
	Inverted bool   `ini:"inverted"`
}

DimmerConfig is the configuration structure for a dimmer device

type ICCS811

type ICCS811 interface {
	Device
	// ECO2 returns the sensor interface to the "equivalent CO2" measurement value
	ECO2() ISensor
	// VOC returns the sensor interface to the "Total Volatile Organic Compound" measuremenr value
	VOC() ISensor
}

ICCS811 denotes a CCS811 environmental sensor

func CreateCCS811

func CreateCCS811(config *CCS811Config) (ICCS811, error)

CreateCCS811 configures connection the sensor

type IDimmer

type IDimmer interface {
	Device
	On()
	Off()
	SetBrightness(value gpio.Duty)
}

IDimmer is a device representing a dimmed light

func CreateDimmer

func CreateDimmer(config *DimmerConfig) (IDimmer, error)

CreateDimmer configures a dimmer device

type IInput

type IInput interface {
	Device
	AddListener(IInputListener)
}

IInput denotes a pin configued for digital input

func CreateInput

func CreateInput(config *InputConfig) (IInput, error)

CreateInput configures an IInputDevice

type IInputListener

type IInputListener func(bool)

IInputListener function is called on changes of input

type IOutput

type IOutput interface {
	Device
	Out(l gpio.Level) error
}

IOutput poin configured as active output

func CreateOutput

func CreateOutput(config *OutputConfig) (IOutput, error)

CreateOutput configures an IOutput device

type ISensor

type ISensor interface {
	// AddListener registers a measurement callback
	AddListener(ISensorValueListener)
	// Unit returns the human-readable representation of the measurement unit
	Unit() string
}

ISensor is the interface of a single value sensor

type ISensorValueListener

type ISensorValueListener func(float64)

ISensorValueListener is the signature to the callback called on measurements

type IShutter

type IShutter interface {
	Device
	Open()
	Close()
	OpenOrStop()
	CloseOrStop()
	MoveBy(int)
	Stop()
	GetRange() int
	AddListener(ShutterStateListener)
}

IShutter is the interface of a shutter device

func CreateShutter

func CreateShutter(config *ShutterConfig) (IShutter, error)

CreateShutter configures a shutter device

type IThermostat

type IThermostat interface {
	Device

	TemperatureRange() ThermostatRange
	SetTargetTemperature(float64)
	TargetTemperature() ISensor
	Temperature() ISensor
}

type InputConfig

type InputConfig struct {
	Pin string `ini:"pin"`
}

InputConfig holds configuration for an IIinput device

type OutputConfig

type OutputConfig struct {
	Pin string `ini:"pin"`
}

OutputConfig hods the configuration for an IOutput device

type ShutterConfig

type ShutterConfig struct {
	UpPin         string `ini:"uppin"`
	DownPin       string `ini:"downpin"`
	DirSwitchWait int    `ini:"dirswitchwait"`
	Range         int    `ini:"range"`
	Inverted      bool   `ini:"inverted"`
}

ShutterConfig holds the configuration values for a shutter

type ShutterStateListener

type ShutterStateListener func(int)

ShutterStateListener is the signature for state callback

type ThermostatRange

type ThermostatRange struct {
	Min  float64
	Max  float64
	Step float64
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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