Documentation ¶
Index ¶
- Constants
- type ADC
- type ADCOption
- type ADCOptionFunc
- type ADS1115
- func (d *ADS1115) Active() bool
- func (d *ADS1115) Close() error
- func (d *ADS1115) Init() (err error)
- func (d *ADS1115) Max(n int, t *time.Duration) float64
- func (d *ADS1115) Min(n int, t *time.Duration) float64
- func (d *ADS1115) RMS(n int, t *time.Duration) float64
- func (d *ADS1115) Read() float64
- func (d *ADS1115) Verify() bool
- type Bluetooth
- type BluetoothOption
- type BluetoothOptionFunc
- type GPIO
- type I2C
- func (i *I2C) Active() bool
- func (i *I2C) Close() error
- func (i *I2C) Init() (err error)
- func (i *I2C) Read() (byte, error)
- func (i *I2C) ReadBytes(n int) ([]byte, error)
- func (i *I2C) ReadReg(reg byte) (byte, error)
- func (i *I2C) ReadRegBytes(reg byte, n int) ([]byte, error)
- func (i *I2C) ReadRegS16BE(reg byte) (int16, error)
- func (i *I2C) ReadRegS16LE(reg byte) (int16, error)
- func (i *I2C) ReadRegU16BE(reg byte) (uint16, error)
- func (i *I2C) ReadRegU16LE(reg byte) (uint16, error)
- func (i *I2C) Tx(w, r []byte) error
- func (i *I2C) Verify() bool
- func (i *I2C) WriteBytes(data ...byte) error
- func (i *I2C) WriteRegBytes(reg byte, data ...byte) error
- func (i *I2C) WriteRegU16BE(reg byte, value uint16) error
- func (i *I2C) WriteRegU16LE(reg byte, value uint16) error
- type I2COption
- type I2COptionFunc
- type SPI
Constants ¶
const ( // Conversion constants ADS1115_SAMPLES_PER_READ = 32767.0 ADS1115_VOLTS_PER_SAMPLE = 5 ADS1115_DEVICE_ID_REGISTER = 0x0E ADS1115_DEVICE_ID = 0x80 )
ADS1115 ADC chip constants.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ADC ¶
type ADC interface { // Init performs ADC driver initialisation. Init() error // Read returns single analog sensor reading value. Read() float64 // RMS aggregates `n` readings from analog sensor and calculates Root Mean Square function. RMS(n int, t *time.Duration) float64 // Max returns max value from `n` analog sensor readings. Max(n int, t *time.Duration) float64 // Min returns min value from `n` analog sensor readings. Min(n int, t *time.Duration) float64 // Verify identifies ADC device and checks it according to implemented driver. Verify() bool // Active determines whether the ADC device is active. Active() bool // Close closes connection to ADC device. Close() error }
ADC defines analog to digital peripheral interface.
type ADCOption ¶
type ADCOption interface {
Apply(adc *ADS1115)
}
An ADCOption configures a ADC driver.
func WithConversion ¶
WithConversion can be used to setup ADC readings conversion. Default is a function that returns input value as is.
func WithI2CMutex ¶
WithI2CMutex can be used to specify mutex for I2C bus driver. Default is a new sync.Mutex instance.
type ADCOptionFunc ¶
type ADCOptionFunc func(d *ADS1115)
ADCOptionFunc is a function that configures a ADC driver.
func (ADCOptionFunc) Apply ¶
func (f ADCOptionFunc) Apply(adc *ADS1115)
Apply calls ADCOptionFunc on the driver instance.
type ADS1115 ¶
type ADS1115 struct { *ads.ADS *I2C Addr uint16 Bus string // contains filtered or unexported fields }
ADS1115 implements ADC driver for ADS1115 device.
type Bluetooth ¶
Bluetooth defines BLE peripheral interface.
func NewBluetooth ¶
func NewBluetooth(options ...BluetoothOption) *Bluetooth
NewBluetooth creates new Bluetooth driver instance.
func (*Bluetooth) ApplyOptions ¶
func (b *Bluetooth) ApplyOptions(options ...BluetoothOption) *Bluetooth
ApplyOptions applies Bluetooth configuration parameters by given `options`.
func (*Bluetooth) Init ¶
func (b *Bluetooth) Init(options ...BluetoothOption) error
Init performs initialisation of the Bluetooth driver.
type BluetoothOption ¶
type BluetoothOption interface {
Apply(d *Bluetooth)
}
An BluetoothOption configures a Bluetooth driver.
func WithAdvertisementDuration ¶
func WithAdvertisementDuration(du time.Duration) BluetoothOption
WithAdvertisementDuration can be used to specify timeout for Bluetooth advertisement. Default is the one specified in the configuration: viper.GetString("bluetooth.advertise_duration").
func WithAdvertisementServices ¶
func WithAdvertisementServices(uuids ...ble.UUID) BluetoothOption
WithAdvertisementServices can be used to specify service to expose during Bluetooth advertisement. Default is no service being exposed.
func WithDeviceName ¶
func WithDeviceName(name string) BluetoothOption
WithDeviceName can be used to specify Bluetooth device identifier name. Default is the one specified in the configuration: viper.GetString("bluetooth.device_name").
func WithScanDuration ¶
func WithScanDuration(du time.Duration) BluetoothOption
WithScanDuration can be used to specify timeout for Bluetooth scanning. Default is the one specified in the configuration: viper.GetString("bluetooth.scan_duration").
type BluetoothOptionFunc ¶
type BluetoothOptionFunc func(d *Bluetooth)
BluetoothOptionFunc is a function that configures a Bluetooth driver.
func (BluetoothOptionFunc) Apply ¶
func (f BluetoothOptionFunc) Apply(d *Bluetooth)
Apply calls BluetoothOptionFunc on the driver instance.
type GPIO ¶
GPIO provides wrapper for GPIO peripheral.
type I2C ¶
I2C provides wrapper for I2C peripheral.
func (*I2C) ReadRegBytes ¶
ReadRegBytes reads `n` bytes from a specified `reg` register.
func (*I2C) ReadRegS16BE ¶
ReadRegS16BE reads signed big endian word (16 bits) from a specified `reg` register.
func (*I2C) ReadRegS16LE ¶
ReadRegS16LE reads signed little endian word (16 bits) from a specified `reg` register.
func (*I2C) ReadRegU16BE ¶
ReadRegU16BE reads unsigned big endian word (16 bits) from a specified `reg` register.
func (*I2C) ReadRegU16LE ¶
ReadRegU16LE reads unsigned little endian word (16 bits) from a specified `reg` register.
func (*I2C) Verify ¶
Verify verifies I2C bus connectivity. It will perform Init if driver is not Active.
func (*I2C) WriteBytes ¶
WriteBytes writes `data` bytes to an active register.
func (*I2C) WriteRegBytes ¶
WriteRegBytes writes `data` bytes to a specified `reg` register.
func (*I2C) WriteRegU16BE ¶
WriteRegU16BE writes unsigned big endian word (16 bits) value to I2C-device starting from address specified in reg.
type I2COptionFunc ¶
type I2COptionFunc func(d *I2C)
I2COptionFunc is a function that configures a I2C driver.
func (I2COptionFunc) Apply ¶
func (f I2COptionFunc) Apply(i2c *I2C)
Apply calls I2COptionFunc on the driver instance.
type SPI ¶
SPI provides wrapper for SPI peripheral.
func (*SPI) SendCommand ¶
SendCommand sends `cmd` command on SPI device.
func (*SPI) SendCommandArgs ¶
SendCommandArgs sends `cmd` command with `data` as arguments on SPI device.