i2c

package module
v0.0.0-...-4938491 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

README

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

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

func (*Dispatcher) OnError

func (d *Dispatcher) OnError(id ID, err error)

OnError dispatches a new error event.

func (*Dispatcher) OnHumidity

func (d *Dispatcher) OnHumidity(id ID, h RH)

OnHumidity dispatches a new humidity event.

func (*Dispatcher) OnTemperature

func (d *Dispatcher) OnTemperature(id ID, t T)

OnTemperature dispatches a new temperature event.

func (*Dispatcher) Register

func (d *Dispatcher) Register(observer interface{}) (hnd int)

func (*Dispatcher) Time

func (d *Dispatcher) Time() time.Time

func (*Dispatcher) Unregister

func (d *Dispatcher) Unregister(hnd int)

type ErrorObserver

type ErrorObserver interface {
	OnError(id ID, err error)
}

type HumidityObserver

type HumidityObserver interface {
	OnHumidity(id ID, h RH)
}

type ID

type ID int32

ID is just some sensor identifier.

type Observer

type Observer interface {
	TemperatureObserver
	HumidityObserver
	ErrorObserver
}

type Polling

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

func NewPolling

func NewPolling(interval time.Duration) *Polling

NewPolling tries to identify the correct i2c bus and the connected devices and immediately starts polling. It does never fail, and instead just returns an instance which has no sensors.

func (*Polling) Close

func (p *Polling) Close() error

func (*Polling) Dispatcher

func (p *Polling) Dispatcher() *Dispatcher

type PrintObserver

type PrintObserver struct {
}

func (PrintObserver) OnError

func (p PrintObserver) OnError(id ID, err error)

func (PrintObserver) OnHumidity

func (p PrintObserver) OnHumidity(id ID, h RH)

func (PrintObserver) OnTemperature

func (p PrintObserver) OnTemperature(id ID, t T)

type RH

type RH int32

RH is the relative humidity in milli-RH (1% = 1000RH)

func (RH) Humidity

func (v RH) Humidity() float64

Humidity returns the value in relative percent.

func (RH) String

func (v RH) String() string

type Sensor

type Sensor interface {
	Poll(*Dispatcher)
}

type T

type T int32

T is the temperature in milli-Celsius (1°C = 1000T)

func (T) Celsius

func (t T) Celsius() float64

Celsius returns just the degree value.

func (T) String

func (t T) String() string

type TemperatureObserver

type TemperatureObserver interface {
	OnTemperature(id ID, t T)
}

Directories

Path Synopsis
cmd
Package crc8 provides a simple CRC8 implementation according to the Sensirion documentation.
Package crc8 provides a simple CRC8 implementation according to the Sensirion documentation.
sensor
shtc3
Package shtc3 provides the i2c protocol implementation for the Sensirion shtc-3 temperature and humidity sensor.
Package shtc3 provides the i2c protocol implementation for the Sensirion shtc-3 temperature and humidity sensor.

Jump to

Keyboard shortcuts

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