Documentation
¶
Overview ¶
Package aio provides Gobot drivers for Analog Input/Output devices.
Installing:
Please refer to the main [README.md](https://github.com/hybridgroup/gobot/blob/release/README.md)
For further information refer to aio README: https://github.com/hybridgroup/gobot/blob/release/platforms/aio/README.md
Index ¶
- Constants
- func AnalogActuatorLinearScaler(fromMin, fromMax float64, toMin, toMax int) func(input float64) (value int)
- func AnalogSensorLinearScaler(fromMin, fromMax int, toMin, toMax float64) func(int) float64
- func TemperatureSensorNtcScaler(vRef uint, rOhm uint, reverse bool, ntc TemperatureSensorNtcConf) func(input int) (value float64)
- func WithActuatorScaler(scaler func(input float64) (value int)) actuatorOptionApplier
- func WithFahrenheit() thermalZoneOptionApplier
- func WithName(name string) optionApplier
- func WithSensorCyclicRead(interval time.Duration) sensorOptionApplier
- func WithSensorScaler(scaler func(input int) (value float64)) sensorOptionApplier
- type AnalogActuatorDriver
- func (d AnalogActuatorDriver) Connection() gobot.Connection
- func (d AnalogActuatorDriver) Halt() error
- func (d AnalogActuatorDriver) Name() string
- func (a *AnalogActuatorDriver) Pin() string
- func (a *AnalogActuatorDriver) RawValue() int
- func (a *AnalogActuatorDriver) RawWrite(val int) error
- func (d AnalogActuatorDriver) SetName(name string)
- func (a *AnalogActuatorDriver) SetScaler(scaler func(float64) int)
- func (d AnalogActuatorDriver) Start() error
- func (a *AnalogActuatorDriver) Value() float64
- func (a *AnalogActuatorDriver) Write(val float64) error
- func (a *AnalogActuatorDriver) WriteRaw(val int) error
- type AnalogReader
- type AnalogSensorDriver
- func (d AnalogSensorDriver) Connection() gobot.Connection
- func (d AnalogSensorDriver) Halt() error
- func (d AnalogSensorDriver) Name() string
- func (a *AnalogSensorDriver) Pin() string
- func (a *AnalogSensorDriver) RawValue() int
- func (a *AnalogSensorDriver) Read() (float64, error)
- func (a *AnalogSensorDriver) ReadRaw() (int, error)
- func (d AnalogSensorDriver) SetName(name string)
- func (a *AnalogSensorDriver) SetScaler(scaler func(int) float64)
- func (d AnalogSensorDriver) Start() error
- func (a *AnalogSensorDriver) Value() float64
- type AnalogWriter
- type GroveLightSensorDriver
- type GrovePiezoVibrationSensorDriver
- type GroveRotaryDriver
- type GroveSoundSensorDriver
- type GroveTemperatureSensorDriver
- type TemperatureSensorDriver
- func (d TemperatureSensorDriver) Connection() gobot.Connection
- func (d TemperatureSensorDriver) Halt() error
- func (d TemperatureSensorDriver) Name() string
- func (t *TemperatureSensorDriver) SetLinearScaler(fromMin, fromMax int, toMin, toMax float64)
- func (d TemperatureSensorDriver) SetName(name string)
- func (t *TemperatureSensorDriver) SetNtcScaler(vRef uint, rOhm uint, reverse bool, ntc TemperatureSensorNtcConf)
- func (d TemperatureSensorDriver) Start() error
- func (t *TemperatureSensorDriver) Temperature() float64
- type TemperatureSensorNtcConf
- type ThermalZoneDriver
Constants ¶
const ( // Error event Error = "error" // Data event Data = "data" // Value event Value = "value" // Vibration event Vibration = "vibration" )
Variables ¶
This section is empty.
Functions ¶
func AnalogActuatorLinearScaler ¶
func AnalogActuatorLinearScaler(fromMin, fromMax float64, toMin, toMax int) func(input float64) (value int)
AnalogActuatorLinearScaler creates a linear scaler function from the given values.
func AnalogSensorLinearScaler ¶
AnalogSensorLinearScaler creates a linear scaler function from the given values.
func TemperatureSensorNtcScaler ¶
func TemperatureSensorNtcScaler( vRef uint, rOhm uint, reverse bool, ntc TemperatureSensorNtcConf, ) func(input int) (value float64)
TemperatureSensorNtcScaler creates a function for typical NTC scaling the read value. The read value is related to the voltage over the thermistor in an series connection to a resistor. If the thermistor is connected to ground, the reverse flag must be set to true. This means the voltage decreases when temperature gets higher. Currently no negative values for voltage are supported.
func WithActuatorScaler ¶ added in v2.3.0
WithActuatorScaler substitute the default 1:1 return value function by a new scaling function
func WithFahrenheit ¶ added in v2.3.0
func WithFahrenheit() thermalZoneOptionApplier
WithFahrenheit substitute the default 1:1 °C scaler by a scaler for °F
func WithName ¶ added in v2.3.0
func WithName(name string) optionApplier
WithName is used to replace the default name of the driver.
func WithSensorCyclicRead ¶ added in v2.3.0
WithSensorCyclicRead add a asynchronous cyclic reading functionality to the sensor with the given read interval.
func WithSensorScaler ¶ added in v2.3.0
WithSensorScaler substitute the default 1:1 return value function by a new scaling function
Types ¶
type AnalogActuatorDriver ¶
type AnalogActuatorDriver struct {
// contains filtered or unexported fields
}
AnalogActuatorDriver represents an analog actuator
func NewAnalogActuatorDriver ¶
func NewAnalogActuatorDriver(a AnalogWriter, pin string, opts ...interface{}) *AnalogActuatorDriver
NewAnalogActuatorDriver returns a new driver for analog actuator, given by an AnalogWriter and pin. The driver supports customizable scaling from given float64 value to written int. The default scaling is 1:1. An adjustable linear scaler is provided by the driver.
Supported options:
"WithName" "WithActuatorScaler"
Adds the following API Commands:
"Write" - See AnalogActuator.Write "WriteRaw" - See AnalogActuator.WriteRaw
func (AnalogActuatorDriver) Connection ¶
func (d AnalogActuatorDriver) Connection() gobot.Connection
Connection returns the connection of the driver.
func (AnalogActuatorDriver) Halt ¶
func (d AnalogActuatorDriver) Halt() error
Halt halts the driver.
func (AnalogActuatorDriver) Name ¶
func (d AnalogActuatorDriver) Name() string
Name returns the name of the driver.
func (*AnalogActuatorDriver) Pin ¶
func (a *AnalogActuatorDriver) Pin() string
Pin returns the drivers pin
func (*AnalogActuatorDriver) RawValue ¶
func (a *AnalogActuatorDriver) RawValue() int
RawValue returns the last written raw value
func (*AnalogActuatorDriver) RawWrite ¶
func (a *AnalogActuatorDriver) RawWrite(val int) error
RawWrite write the given raw value to the actuator Deprecated: Please use aio.WriteRaw instead.
func (AnalogActuatorDriver) SetName ¶
func (d AnalogActuatorDriver) SetName(name string)
SetName sets the name of the driver. Deprecated: Please use option aio.WithName instead.
func (*AnalogActuatorDriver) SetScaler ¶
func (a *AnalogActuatorDriver) SetScaler(scaler func(float64) int)
SetScaler substitute the default 1:1 return value function by a new scaling function If the scaler is not changed after initialization, prefer to use aio.WithActuatorScaler instead.
func (AnalogActuatorDriver) Start ¶
func (d AnalogActuatorDriver) Start() error
Start initializes the driver.
func (*AnalogActuatorDriver) Value ¶
func (a *AnalogActuatorDriver) Value() float64
Value returns the last written value
func (*AnalogActuatorDriver) Write ¶
func (a *AnalogActuatorDriver) Write(val float64) error
Write writes the given value to the actuator
func (*AnalogActuatorDriver) WriteRaw ¶ added in v2.3.0
func (a *AnalogActuatorDriver) WriteRaw(val int) error
WriteRaw write the given raw value to the actuator
type AnalogReader ¶
AnalogReader interface represents an Adaptor which has AnalogRead capabilities
type AnalogSensorDriver ¶
type AnalogSensorDriver struct { gobot.Eventer // contains filtered or unexported fields }
AnalogSensorDriver represents an analog sensor
func NewAnalogSensorDriver ¶
func NewAnalogSensorDriver(a AnalogReader, pin string, opts ...interface{}) *AnalogSensorDriver
NewAnalogSensorDriver returns a new driver for analog sensors, given an AnalogReader and pin. The driver supports cyclic reading and customizable scaling from read int value to returned float64. The default scaling is 1:1. An adjustable linear scaler is provided by the driver.
Supported options:
"WithName" "WithSensorCyclicRead" "WithSensorScaler"
Adds the following API Commands:
"Read" - See AnalogDriverSensor.Read "ReadRaw" - See AnalogDriverSensor.ReadRaw
func (AnalogSensorDriver) Connection ¶
func (d AnalogSensorDriver) Connection() gobot.Connection
Connection returns the connection of the driver.
func (AnalogSensorDriver) Name ¶
func (d AnalogSensorDriver) Name() string
Name returns the name of the driver.
func (*AnalogSensorDriver) Pin ¶
func (a *AnalogSensorDriver) Pin() string
Pin returns the AnalogSensorDrivers pin
func (*AnalogSensorDriver) RawValue ¶
func (a *AnalogSensorDriver) RawValue() int
RawValue returns the last read raw value from the sensor
func (*AnalogSensorDriver) Read ¶
func (a *AnalogSensorDriver) Read() (float64, error)
Read returns the current reading from the sensor, scaled by the current scaler
func (*AnalogSensorDriver) ReadRaw ¶
func (a *AnalogSensorDriver) ReadRaw() (int, error)
ReadRaw returns the current reading from the sensor without scaling
func (AnalogSensorDriver) SetName ¶
func (d AnalogSensorDriver) SetName(name string)
SetName sets the name of the driver. Deprecated: Please use option aio.WithName instead.
func (*AnalogSensorDriver) SetScaler ¶
func (a *AnalogSensorDriver) SetScaler(scaler func(int) float64)
SetScaler substitute the default 1:1 return value function by a new scaling function If the scaler is not changed after initialization, prefer to use aio.WithSensorScaler instead.
func (AnalogSensorDriver) Start ¶
func (d AnalogSensorDriver) Start() error
Start initializes the driver.
func (*AnalogSensorDriver) Value ¶
func (a *AnalogSensorDriver) Value() float64
Value returns the last read value from the sensor
type AnalogWriter ¶
AnalogWriter interface represents an Adaptor which has AnalogWrite capabilities
type GroveLightSensorDriver ¶
type GroveLightSensorDriver struct {
*AnalogSensorDriver
}
GroveLightSensorDriver represents an analog light sensor with a Grove connector
func NewGroveLightSensorDriver ¶
func NewGroveLightSensorDriver(a AnalogReader, pin string, opts ...interface{}) *GroveLightSensorDriver
NewGroveLightSensorDriver returns a new driver for grove light sensor, given an AnalogReader and pin.
Supported options: see aio.NewAnalogSensorDriver Adds the following API Commands: see aio.NewAnalogSensorDriver
func (GroveLightSensorDriver) Connection ¶ added in v2.3.0
func (d GroveLightSensorDriver) Connection() gobot.Connection
Connection returns the connection of the driver.
func (GroveLightSensorDriver) Halt ¶ added in v2.3.0
func (d GroveLightSensorDriver) Halt() error
Halt halts the driver.
func (GroveLightSensorDriver) Name ¶ added in v2.3.0
func (d GroveLightSensorDriver) Name() string
Name returns the name of the driver.
func (GroveLightSensorDriver) SetName ¶ added in v2.3.0
func (d GroveLightSensorDriver) SetName(name string)
SetName sets the name of the driver. Deprecated: Please use option aio.WithName instead.
type GrovePiezoVibrationSensorDriver ¶
type GrovePiezoVibrationSensorDriver struct {
*AnalogSensorDriver
}
GrovePiezoVibrationSensorDriver represents an analog vibration sensor with a Grove connector
func NewGrovePiezoVibrationSensorDriver ¶
func NewGrovePiezoVibrationSensorDriver( a AnalogReader, pin string, opts ...interface{}, ) *GrovePiezoVibrationSensorDriver
NewGrovePiezoVibrationSensorDriver returns a new driver for grove piezo vibration sensor, given an AnalogReader and pin.
Supported options: see aio.NewAnalogSensorDriver Adds the following API Commands: see aio.NewAnalogSensorDriver
func (GrovePiezoVibrationSensorDriver) Connection ¶ added in v2.3.0
func (d GrovePiezoVibrationSensorDriver) Connection() gobot.Connection
Connection returns the connection of the driver.
func (GrovePiezoVibrationSensorDriver) Halt ¶ added in v2.3.0
func (d GrovePiezoVibrationSensorDriver) Halt() error
Halt halts the driver.
func (GrovePiezoVibrationSensorDriver) Name ¶ added in v2.3.0
func (d GrovePiezoVibrationSensorDriver) Name() string
Name returns the name of the driver.
func (GrovePiezoVibrationSensorDriver) SetName ¶ added in v2.3.0
func (d GrovePiezoVibrationSensorDriver) SetName(name string)
SetName sets the name of the driver. Deprecated: Please use option aio.WithName instead.
type GroveRotaryDriver ¶
type GroveRotaryDriver struct {
*AnalogSensorDriver
}
GroveRotaryDriver represents an analog rotary dial with a Grove connector
func NewGroveRotaryDriver ¶
func NewGroveRotaryDriver(a AnalogReader, pin string, opts ...interface{}) *GroveRotaryDriver
NewGroveRotaryDriver returns a new driver for grove rotary dial, given an AnalogReader and pin.
Supported options: see aio.NewAnalogSensorDriver Adds the following API Commands: see aio.NewAnalogSensorDriver
func (GroveRotaryDriver) Connection ¶ added in v2.3.0
func (d GroveRotaryDriver) Connection() gobot.Connection
Connection returns the connection of the driver.
func (GroveRotaryDriver) Halt ¶ added in v2.3.0
func (d GroveRotaryDriver) Halt() error
Halt halts the driver.
func (GroveRotaryDriver) Name ¶ added in v2.3.0
func (d GroveRotaryDriver) Name() string
Name returns the name of the driver.
func (GroveRotaryDriver) SetName ¶ added in v2.3.0
func (d GroveRotaryDriver) SetName(name string)
SetName sets the name of the driver. Deprecated: Please use option aio.WithName instead.
type GroveSoundSensorDriver ¶
type GroveSoundSensorDriver struct {
*AnalogSensorDriver
}
GroveSoundSensorDriver represents a analog sound sensor with a Grove connector
func NewGroveSoundSensorDriver ¶
func NewGroveSoundSensorDriver(a AnalogReader, pin string, opts ...interface{}) *GroveSoundSensorDriver
NewGroveSoundSensorDriver returns a new driver for grove sound sensor, given an AnalogReader and pin.
Supported options: see aio.NewAnalogSensorDriver Adds the following API Commands: see aio.NewAnalogSensorDriver
func (GroveSoundSensorDriver) Connection ¶ added in v2.3.0
func (d GroveSoundSensorDriver) Connection() gobot.Connection
Connection returns the connection of the driver.
func (GroveSoundSensorDriver) Halt ¶ added in v2.3.0
func (d GroveSoundSensorDriver) Halt() error
Halt halts the driver.
func (GroveSoundSensorDriver) Name ¶ added in v2.3.0
func (d GroveSoundSensorDriver) Name() string
Name returns the name of the driver.
func (GroveSoundSensorDriver) SetName ¶ added in v2.3.0
func (d GroveSoundSensorDriver) SetName(name string)
SetName sets the name of the driver. Deprecated: Please use option aio.WithName instead.
type GroveTemperatureSensorDriver ¶
type GroveTemperatureSensorDriver struct {
*TemperatureSensorDriver
}
GroveTemperatureSensorDriver represents a temperature sensor The temperature is reported in degree Celsius
func NewGroveTemperatureSensorDriver ¶
func NewGroveTemperatureSensorDriver(a AnalogReader, pin string, opts ...interface{}) *GroveTemperatureSensorDriver
NewGroveTemperatureSensorDriver returns a new driver for grove temperature sensor, given an AnalogReader and pin.
Supported options: see aio.NewAnalogSensorDriver Adds the following API Commands: see aio.NewAnalogSensorDriver
func (GroveTemperatureSensorDriver) Connection ¶ added in v2.3.0
func (d GroveTemperatureSensorDriver) Connection() gobot.Connection
Connection returns the connection of the driver.
func (GroveTemperatureSensorDriver) Halt ¶ added in v2.3.0
func (d GroveTemperatureSensorDriver) Halt() error
Halt halts the driver.
func (GroveTemperatureSensorDriver) Name ¶ added in v2.3.0
func (d GroveTemperatureSensorDriver) Name() string
Name returns the name of the driver.
func (GroveTemperatureSensorDriver) SetName ¶ added in v2.3.0
func (d GroveTemperatureSensorDriver) SetName(name string)
SetName sets the name of the driver. Deprecated: Please use option aio.WithName instead.
type TemperatureSensorDriver ¶
type TemperatureSensorDriver struct {
*AnalogSensorDriver
}
TemperatureSensorDriver represents an Analog Sensor
func NewTemperatureSensorDriver ¶
func NewTemperatureSensorDriver(a AnalogReader, pin string, opts ...interface{}) *TemperatureSensorDriver
NewTemperatureSensorDriver is a driver for analog temperature sensors, given an AnalogReader and pin. Linear scaling and NTC scaling is supported.
Supported options: see aio.NewAnalogSensorDriver Adds the following API Commands: see aio.NewAnalogSensorDriver
func (TemperatureSensorDriver) Connection ¶ added in v2.3.0
func (d TemperatureSensorDriver) Connection() gobot.Connection
Connection returns the connection of the driver.
func (TemperatureSensorDriver) Halt ¶ added in v2.3.0
func (d TemperatureSensorDriver) Halt() error
Halt halts the driver.
func (TemperatureSensorDriver) Name ¶ added in v2.3.0
func (d TemperatureSensorDriver) Name() string
Name returns the name of the driver.
func (*TemperatureSensorDriver) SetLinearScaler ¶
func (t *TemperatureSensorDriver) SetLinearScaler(fromMin, fromMax int, toMin, toMax float64)
SetLinearScaler sets a function for linear scaling the read value. This can be applied for some silicon based PTC sensors or e.g. PT100, and in a small temperature range also for NTC. If the scaler is not changed after initialization, prefer to use aio.WithSensorScaler instead.
func (TemperatureSensorDriver) SetName ¶ added in v2.3.0
func (d TemperatureSensorDriver) SetName(name string)
SetName sets the name of the driver. Deprecated: Please use option aio.WithName instead.
func (*TemperatureSensorDriver) SetNtcScaler ¶
func (t *TemperatureSensorDriver) SetNtcScaler(vRef uint, rOhm uint, reverse bool, ntc TemperatureSensorNtcConf)
SetNtcScaler sets a function for typical NTC scaling the read value. The read value is related to the voltage over the thermistor in an series connection to a resistor. If the thermistor is connected to ground, the reverse flag must be set to true. This means the voltage decreases when temperature gets higher. Currently no negative values for voltage are supported. If the scaler is not changed after initialization, prefer to use aio.WithSensorScaler instead.
func (TemperatureSensorDriver) Start ¶ added in v2.3.0
func (d TemperatureSensorDriver) Start() error
Start initializes the driver.
func (*TemperatureSensorDriver) Temperature ¶
func (t *TemperatureSensorDriver) Temperature() float64
Temperature returns the last read temperature from the sensor.
type TemperatureSensorNtcConf ¶
type TemperatureSensorNtcConf struct { TC0 int // °C R0 float64 // same unit as resistance of NTC (Ohm is recommended) B float64 // 2000..5000K TC1 int // used if B is not given, °C R1 float64 // used if B is not given, same unit as R0 needed // contains filtered or unexported fields }
TemperatureSensorNtcConf contains all attributes to calculate key parameters of a NTC thermistor.
type ThermalZoneDriver ¶ added in v2.3.0
type ThermalZoneDriver struct { *AnalogSensorDriver // contains filtered or unexported fields }
ThermalZoneDriver represents an driver for reading the system thermal zone temperature
func NewThermalZoneDriver ¶ added in v2.3.0
func NewThermalZoneDriver(a AnalogReader, zoneID string, opts ...interface{}) *ThermalZoneDriver
NewThermalZoneDriver is a driver for reading the system thermal zone temperature, given an AnalogReader and zone id.
Supported options: see also aio.NewAnalogSensorDriver
"WithFahrenheit()"
Adds the following API Commands: see aio.NewAnalogSensorDriver
func (ThermalZoneDriver) Connection ¶ added in v2.3.0
func (d ThermalZoneDriver) Connection() gobot.Connection
Connection returns the connection of the driver.
func (ThermalZoneDriver) Halt ¶ added in v2.3.0
func (d ThermalZoneDriver) Halt() error
Halt halts the driver.
func (ThermalZoneDriver) Name ¶ added in v2.3.0
func (d ThermalZoneDriver) Name() string
Name returns the name of the driver.
func (ThermalZoneDriver) SetName ¶ added in v2.3.0
func (d ThermalZoneDriver) SetName(name string)
SetName sets the name of the driver. Deprecated: Please use option aio.WithName instead.