Documentation
¶
Index ¶
- type ADS1115
- type AnalogDevice
- type AnalogMock
- type BaseDevice
- func (d *BaseDevice) AddPub(p string)
- func (d *BaseDevice) GetPub() string
- func (d *BaseDevice) GetSubs() []string
- func (d *BaseDevice) JSON() []byte
- func (d BaseDevice) Name() string
- func (d *BaseDevice) Publish(data any)
- func (d *BaseDevice) Shutdown()
- func (d *BaseDevice) String() string
- func (d *BaseDevice) Subscribe(topic string, f func(*messanger.Msg))
- func (d *BaseDevice) TimerLoop(period time.Duration, done chan any, readpub func() error)
- type I2CDevice
- type MockAnalogPin
- func (ma *MockAnalogPin) Function() string
- func (ma *MockAnalogPin) Halt() error
- func (ma *MockAnalogPin) Name() string
- func (ma *MockAnalogPin) Number() int
- func (ma *MockAnalogPin) Range() (s1 analog.Sample, s2 analog.Sample)
- func (ma *MockAnalogPin) Read() (s analog.Sample, err error)
- func (ma *MockAnalogPin) ReadContinuous() (ch <-chan analog.Sample)
- func (ma *MockAnalogPin) String() string
- type SerialDevice
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 ¶
NewADS creates a new ADS1115 giving it the provided name, I2C bus (default /dev/i2c-1) and address (default 0x48).
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) 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
type I2CDevice ¶
type I2CDevice struct { *BaseDevice Bus string Addr int }
type MockAnalogPin ¶
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) 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)