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/master/platforms/aio/README.md
Index ¶
- Constants
- Variables
- func AnalogActuatorLinearScaler(fromMin, fromMax float64, toMin, toMax int) func(input float64) (value int)
- func AnalogSensorLinearScaler(fromMin, fromMax int, toMin, toMax float64) func(input int) (value float64)
- func TemperatureSensorNtcScaler(vRef uint, rOhm uint, reverse bool, ntc TemperatureSensorNtcConf) func(input int) (value float64)
- type AnalogActuatorDriver
- func (a *AnalogActuatorDriver) Connection() gobot.Connection
- func (a *AnalogActuatorDriver) Halt() (err error)
- func (a *AnalogActuatorDriver) Name() string
- func (a *AnalogActuatorDriver) Pin() string
- func (a *AnalogActuatorDriver) RawValue() (val int)
- func (a *AnalogActuatorDriver) RawWrite(val int) (err error)
- func (a *AnalogActuatorDriver) SetName(n string)
- func (a *AnalogActuatorDriver) SetScaler(scaler func(float64) int)
- func (a *AnalogActuatorDriver) Start() (err error)
- func (a *AnalogActuatorDriver) Value() (val float64)
- func (a *AnalogActuatorDriver) Write(val float64) (err error)
- type AnalogReader
- type AnalogSensorDriver
- func (a *AnalogSensorDriver) Connection() gobot.Connection
- func (a *AnalogSensorDriver) Halt() (err error)
- func (a *AnalogSensorDriver) Name() string
- func (a *AnalogSensorDriver) Pin() string
- func (a *AnalogSensorDriver) RawValue() int
- func (a *AnalogSensorDriver) Read() (val float64, err error)
- func (a *AnalogSensorDriver) ReadRaw() (val int, err error)
- func (a *AnalogSensorDriver) SetName(n string)
- func (a *AnalogSensorDriver) SetScaler(scaler func(int) float64)
- func (a *AnalogSensorDriver) Start() (err error)
- func (a *AnalogSensorDriver) Value() float64
- type AnalogWriter
- type GroveLightSensorDriver
- type GrovePiezoVibrationSensorDriver
- type GroveRotaryDriver
- type GroveSoundSensorDriver
- type GroveTemperatureSensorDriver
- type TemperatureSensorDriver
- type TemperatureSensorNtcConf
Constants ¶
const ( // Error event Error = "error" // Data event Data = "data" // Value event Value = "value" // Vibration event Vibration = "vibration" )
Variables ¶
var ErrAnalogReadUnsupported = errors.New("AnalogRead is not supported by this platform")
ErrAnalogReadUnsupported is error resulting when a driver attempts to use hardware capabilities which a connection does not support
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 ¶
func AnalogSensorLinearScaler(fromMin, fromMax int, toMin, toMax float64) func(input int) (value float64)
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.
Types ¶
type AnalogActuatorDriver ¶
type AnalogActuatorDriver struct { gobot.Eventer gobot.Commander // contains filtered or unexported fields }
AnalogActuatorDriver represents an analog actuator
func NewAnalogActuatorDriver ¶
func NewAnalogActuatorDriver(a AnalogWriter, pin string) *AnalogActuatorDriver
NewAnalogActuatorDriver returns a new AnalogActuatorDriver 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.
Adds the following API Commands:
"Write" - See AnalogActuator.Write "RawWrite" - See AnalogActuator.RawWrite
func (*AnalogActuatorDriver) Connection ¶
func (a *AnalogActuatorDriver) Connection() gobot.Connection
Connection returns the drivers Connection
func (*AnalogActuatorDriver) Halt ¶
func (a *AnalogActuatorDriver) Halt() (err error)
Halt is for halt
func (*AnalogActuatorDriver) Name ¶
func (a *AnalogActuatorDriver) Name() string
Name returns the drivers name
func (*AnalogActuatorDriver) Pin ¶
func (a *AnalogActuatorDriver) Pin() string
Pin returns the drivers pin
func (*AnalogActuatorDriver) RawValue ¶
func (a *AnalogActuatorDriver) RawValue() (val int)
RawValue returns the last written raw value
func (*AnalogActuatorDriver) RawWrite ¶
func (a *AnalogActuatorDriver) RawWrite(val int) (err error)
RawWrite write the given raw value to the actuator
func (*AnalogActuatorDriver) SetName ¶
func (a *AnalogActuatorDriver) SetName(n string)
SetName sets the drivers name
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
func (*AnalogActuatorDriver) Start ¶
func (a *AnalogActuatorDriver) Start() (err error)
Start starts driver
func (*AnalogActuatorDriver) Value ¶
func (a *AnalogActuatorDriver) Value() (val float64)
Value returns the last written value
func (*AnalogActuatorDriver) Write ¶
func (a *AnalogActuatorDriver) Write(val float64) (err error)
Write writes the given value to the actuator
type AnalogReader ¶
AnalogReader interface represents an Adaptor which has AnalogRead capabilities
type AnalogSensorDriver ¶
type AnalogSensorDriver struct { gobot.Eventer gobot.Commander // contains filtered or unexported fields }
AnalogSensorDriver represents an Analog Sensor
func NewAnalogSensorDriver ¶
func NewAnalogSensorDriver(a AnalogReader, pin string, v ...time.Duration) *AnalogSensorDriver
NewAnalogSensorDriver returns a new AnalogSensorDriver with a polling interval of 10 Milliseconds given an AnalogReader and pin. The driver supports customizable scaling from read int value to returned float64. The default scaling is 1:1. An adjustable linear scaler is provided by the driver.
Optionally accepts:
time.Duration: Interval at which the AnalogSensor is polled for new information
Adds the following API Commands:
"Read" - See AnalogDriverSensor.Read "ReadRaw" - See AnalogDriverSensor.ReadRaw
func (*AnalogSensorDriver) Connection ¶
func (a *AnalogSensorDriver) Connection() gobot.Connection
Connection returns the AnalogSensorDrivers Connection
func (*AnalogSensorDriver) Halt ¶
func (a *AnalogSensorDriver) Halt() (err error)
Halt stops polling the analog sensor for new information
func (*AnalogSensorDriver) Name ¶
func (a *AnalogSensorDriver) Name() string
Name returns the AnalogSensorDrivers name
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() (val float64, err error)
Read returns the current reading from the sensor
func (*AnalogSensorDriver) ReadRaw ¶
func (a *AnalogSensorDriver) ReadRaw() (val int, err error)
ReadRaw returns the current reading from the sensor without scaling
func (*AnalogSensorDriver) SetName ¶
func (a *AnalogSensorDriver) SetName(n string)
SetName sets the AnalogSensorDrivers name
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
func (*AnalogSensorDriver) Start ¶
func (a *AnalogSensorDriver) Start() (err error)
Start starts the AnalogSensorDriver and reads the sensor at the given interval. Emits the Events:
Data int - Event is emitted on change and represents the current raw reading from the sensor. Value float64 - Event is emitted on change and represents the current reading from the sensor. Error error - Event is emitted on error reading from the sensor.
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, v ...time.Duration) *GroveLightSensorDriver
NewGroveLightSensorDriver returns a new GroveLightSensorDriver with a polling interval of 10 Milliseconds given an AnalogReader and pin.
Optionally accepts:
time.Duration: Interval at which the AnalogSensor is polled for new information
Adds the following API Commands:
"Read" - See AnalogSensor.Read
type GrovePiezoVibrationSensorDriver ¶
type GrovePiezoVibrationSensorDriver struct {
*AnalogSensorDriver
}
GrovePiezoVibrationSensorDriver represents an analog vibration sensor with a Grove connector
func NewGrovePiezoVibrationSensorDriver ¶
func NewGrovePiezoVibrationSensorDriver(a AnalogReader, pin string, v ...time.Duration) *GrovePiezoVibrationSensorDriver
NewGrovePiezoVibrationSensorDriver returns a new GrovePiezoVibrationSensorDriver with a polling interval of 10 Milliseconds given an AnalogReader and pin.
Optionally accepts:
time.Duration: Interval at which the AnalogSensor is polled for new information
Adds the following API Commands:
"Read" - See AnalogSensor.Read
type GroveRotaryDriver ¶
type GroveRotaryDriver struct {
*AnalogSensorDriver
}
GroveRotaryDriver represents an analog rotary dial with a Grove connector
func NewGroveRotaryDriver ¶
func NewGroveRotaryDriver(a AnalogReader, pin string, v ...time.Duration) *GroveRotaryDriver
NewGroveRotaryDriver returns a new GroveRotaryDriver with a polling interval of 10 Milliseconds given an AnalogReader and pin.
Optionally accepts:
time.Duration: Interval at which the AnalogSensor is polled for new information
Adds the following API Commands:
"Read" - See AnalogSensor.Read
type GroveSoundSensorDriver ¶
type GroveSoundSensorDriver struct {
*AnalogSensorDriver
}
GroveSoundSensorDriver represents a analog sound sensor with a Grove connector
func NewGroveSoundSensorDriver ¶
func NewGroveSoundSensorDriver(a AnalogReader, pin string, v ...time.Duration) *GroveSoundSensorDriver
NewGroveSoundSensorDriver returns a new GroveSoundSensorDriver with a polling interval of 10 Milliseconds given an AnalogReader and pin.
Optionally accepts:
time.Duration: Interval at which the AnalogSensor is polled for new information
Adds the following API Commands:
"Read" - See AnalogSensor.Read
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, v ...time.Duration) *GroveTemperatureSensorDriver
NewGroveTemperatureSensorDriver returns a new GroveTemperatureSensorDriver with a polling interval of 10 Milliseconds given an AnalogReader and pin.
Optionally accepts:
time.Duration: Interval at which the sensor is polled for new information (given 0 switch the polling off)
Adds the following API Commands:
"Read" - See AnalogDriverSensor.Read "ReadValue" - See AnalogDriverSensor.ReadValue
type TemperatureSensorDriver ¶
type TemperatureSensorDriver struct {
*AnalogSensorDriver
}
TemperatureSensorDriver represents an Analog Sensor
func NewTemperatureSensorDriver ¶
func NewTemperatureSensorDriver(a AnalogReader, pin string, v ...time.Duration) *TemperatureSensorDriver
NewTemperatureSensorDriver is a gobot driver for analog temperature sensors with a polling interval 10 Milliseconds given an AnalogReader and pin. For further details please refer to AnalogSensorDriver. Linear scaling and NTC scaling is supported.
Optionally accepts:
time.Duration: Interval at which the sensor is polled for new information (given 0 switch the polling off)
Adds the following API Commands:
"Read" - See AnalogDriverSensor.Read "ReadValue" - See AnalogDriverSensor.ReadValue
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.
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.
func (*TemperatureSensorDriver) Temperature ¶
func (t *TemperatureSensorDriver) Temperature() (val 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.