devices

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ADS1115

type ADS1115 struct {
	Device
	Mock bool
	// contains filtered or unexported fields
}

ADS1115 is an i2c ADC chip that will use the i2c device type to provide 4 single analog pins to be used by the raspberry pi to access analog sensors via the i2c bus. In a sense this device is a higher level device than the device_i2c.

func GetADS1115

func GetADS1115() *ADS1115

GetADS1115 will return the default ads1115 struct singleton. The first time GetADS1115 is called it will create a new device. Subsequent calls will return the global variable.

func NewADS1115

func NewADS1115(name string, bus string, addr int) *ADS1115

NewADS creates a new ADS1115 giving it the provided name, I2C bus (default /dev/i2c-1) and address (default 0x48).

func (*ADS1115) Close

func (a *ADS1115) Close()

Close the ads1115 and shutdown all the pins

func (*ADS1115) Init

func (a *ADS1115) Init() (err error)

Init prepares the chip for usage

func (*ADS1115) JSON

func (a *ADS1115) JSON() []byte

func (*ADS1115) Pin

func (a *ADS1115) Pin(name string, ch int, opts any) (pin *AnalogPin, err error)

Pin allocates and prepares one of the ads1115 pins (0 - 3) for use.

func (*ADS1115) String

func (a *ADS1115) String() string

type AnalogDevice

type AnalogDevice struct {
	*BaseDevice
	*AnalogPin
}

func NewAnalogDevice

func NewAnalogDevice(name string, offset int, opts any) (ad *AnalogDevice)

NewAnalogDevice creates a analog device with the given name and ads1115 pin value. The options (not yet supported) should be those used by the ads1115 library provided by

func (*AnalogDevice) Name

func (ad *AnalogDevice) Name() string

type AnalogMock

type AnalogMock struct {
	BaseDevice
}

func (*AnalogMock) Get

func (a *AnalogMock) Get() float64

func (*AnalogMock) ReadContinuous

func (a *AnalogMock) ReadContinuous() <-chan float64

type BaseDevice

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

func NewDevice

func NewDevice(name string) *BaseDevice

NewDevice creates a new device with the given name

func (*BaseDevice) AddPub

func (d *BaseDevice) AddPub(p string)

AddPub adds a publication

func (*BaseDevice) GetPub

func (d *BaseDevice) GetPub() string

func (*BaseDevice) GetSubs

func (d *BaseDevice) GetSubs() []string

func (*BaseDevice) JSON

func (d *BaseDevice) JSON() []byte

func (BaseDevice) Name

func (d BaseDevice) Name() string

func (*BaseDevice) Publish

func (d *BaseDevice) Publish(data any)

func (*BaseDevice) Shutdown

func (d *BaseDevice) Shutdown()

func (*BaseDevice) String

func (d *BaseDevice) String() string

func (*BaseDevice) Subscribe

func (d *BaseDevice) Subscribe(topic string, f func(*messanger.Msg))

func (*BaseDevice) TimerLoop

func (d *BaseDevice) TimerLoop(period time.Duration, done chan any, readpub func() error)

type I2CDevice

type I2CDevice struct {
	*BaseDevice
	Bus  string
	Addr int
}

func NewI2CDevice

func NewI2CDevice(name string, bus string, addr int) *I2CDevice

type MockAnalogPin

type MockAnalogPin struct {
	ads1x15.PinADC
}

func (*MockAnalogPin) Function

func (ma *MockAnalogPin) Function() string

func (*MockAnalogPin) Halt

func (ma *MockAnalogPin) Halt() error

func (*MockAnalogPin) Name

func (ma *MockAnalogPin) Name() string

func (*MockAnalogPin) Number

func (ma *MockAnalogPin) Number() int

func (*MockAnalogPin) Range

func (ma *MockAnalogPin) Range() (s1 analog.Sample, s2 analog.Sample)

func (*MockAnalogPin) Read

func (ma *MockAnalogPin) Read() (s analog.Sample, err error)

func (*MockAnalogPin) ReadContinuous

func (ma *MockAnalogPin) ReadContinuous() (ch <-chan analog.Sample)

func (*MockAnalogPin) String

func (ma *MockAnalogPin) String() string

type SerialDevice

type SerialDevice struct {
	PortName string
	Baud     int
	*serial.Port
	*BaseDevice
}

func NewSerialDevice

func NewSerialDevice(name, port string, baud int) *SerialDevice

func (*SerialDevice) Open

func (s *SerialDevice) Open() (err error)

func (*SerialDevice) Read

func (s *SerialDevice) Read(buf []byte) (int, error)

func (*SerialDevice) Write

func (s *SerialDevice) Write(buf []byte) (int, error)

Jump to

Keyboard shortcuts

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