Documentation ¶
Index ¶
- func WithDigitalPinInitializer(pc digitalPinInitializer) func(DigitalPinsOptioner)
- func WithGpioDebounce(pin string, period time.Duration) func(DigitalPinsOptioner)
- func WithGpioEventOnBothEdges(pin string, ...) func(DigitalPinsOptioner)
- func WithGpioEventOnFallingEdge(pin string, ...) func(DigitalPinsOptioner)
- func WithGpioEventOnRisingEdge(pin string, ...) func(DigitalPinsOptioner)
- func WithGpioPollForEdgeDetection(pin string, pollInterval time.Duration, pollQuitChan chan struct{}) func(DigitalPinsOptioner)
- func WithGpiodAccess() func(DigitalPinsOptioner)
- func WithGpiosActiveLow(pin string, otherPins ...string) func(DigitalPinsOptioner)
- func WithGpiosOpenDrain(pin string, otherPins ...string) func(DigitalPinsOptioner)
- func WithGpiosOpenSource(pin string, otherPins ...string) func(DigitalPinsOptioner)
- func WithGpiosPullDown(pin string, otherPins ...string) func(DigitalPinsOptioner)
- func WithGpiosPullUp(pin string, otherPins ...string) func(DigitalPinsOptioner)
- func WithPWMDefaultPeriod(periodNanoSec uint32) pwmPinsPeriodDefaultOption
- func WithPWMDefaultPeriodForPin(pin string, periodNanoSec uint32) pwmPinsDefaultPeriodForPinOption
- func WithPWMMinimumDutyRate(dutyRate float64) pwmPinsDutyRateMinimumOption
- func WithPWMMinimumPeriod(periodNanoSec uint32) pwmPinsPeriodMinimumOption
- func WithPWMNoDutyCycleAdjustment() pwmPinsAdjustDutyOnSetPeriodOption
- func WithPWMPinInitializer(pc pwmPinInitializer) pwmPinsInitializeOption
- func WithPWMPolarityInvertedIdentifier(identifier string) pwmPinsPolarityInvertedIdentifierOption
- func WithPWMServoAngleRangeForPin(pin string, min, max float64) pwmPinsServoAngleScaleForPinOption
- func WithPWMServoDutyCycleRangeForPin(pin string, min, max time.Duration) pwmPinsServoDutyScaleForPinOption
- func WithPWMUsePiBlaster() pwmPinsUsePiBlasterPinOption
- func WithSpiGpioAccess(sclkPin, nssPin, mosiPin, misoPin string) func(DigitalPinsOptioner)
- type AnalogPinsAdaptor
- type DigitalPinsAdaptor
- func (a *DigitalPinsAdaptor) Connect() error
- func (a *DigitalPinsAdaptor) DigitalPin(id string) (gobot.DigitalPinner, error)
- func (a *DigitalPinsAdaptor) DigitalRead(id string) (int, error)
- func (a *DigitalPinsAdaptor) DigitalWrite(id string, val byte) error
- func (a *DigitalPinsAdaptor) Finalize() error
- type DigitalPinsOptioner
- type I2cBusAdaptor
- type PWMPinsAdaptor
- func (a *PWMPinsAdaptor) Connect() error
- func (a *PWMPinsAdaptor) Finalize() error
- func (a *PWMPinsAdaptor) PWMPin(id string) (gobot.PWMPinner, error)
- func (a *PWMPinsAdaptor) PwmWrite(id string, val byte) error
- func (a *PWMPinsAdaptor) ServoWrite(id string, angle byte) error
- func (a *PWMPinsAdaptor) SetPeriod(id string, period uint32) error
- type PwmPinsOptionApplier
- type SpiBusAdaptor
- func (a *SpiBusAdaptor) Connect() error
- func (a *SpiBusAdaptor) Finalize() error
- func (a *SpiBusAdaptor) GetSpiConnection(busNum, chipNum, mode, bits int, maxSpeed int64) (spi.Connection, error)
- func (a *SpiBusAdaptor) SpiDefaultBitCount() int
- func (a *SpiBusAdaptor) SpiDefaultBusNumber() int
- func (a *SpiBusAdaptor) SpiDefaultChipNumber() int
- func (a *SpiBusAdaptor) SpiDefaultMaxSpeed() int64
- func (a *SpiBusAdaptor) SpiDefaultMode() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithDigitalPinInitializer ¶
func WithDigitalPinInitializer(pc digitalPinInitializer) func(DigitalPinsOptioner)
WithDigitalPinInitializer can be used to substitute the default initializer.
func WithGpioDebounce ¶
func WithGpioDebounce(pin string, period time.Duration) func(DigitalPinsOptioner)
WithGpioDebounce prepares the given input pin to be debounced on next initialize. This is working for inputs since Kernel 5.10, but will be ignored for outputs or with sysfs ABI.
func WithGpioEventOnBothEdges ¶
func WithGpioEventOnBothEdges(pin string, handler func(lineOffset int, timestamp time.Duration, detectedEdge string, seqno uint32, lseqno uint32), ) func(DigitalPinsOptioner)
WithGpioEventOnBothEdges prepares the given input pin to be generate an event on rising and falling edges. This is working for inputs since Kernel 5.10, but will be ignored for outputs or with sysfs ABI.
func WithGpioEventOnFallingEdge ¶
func WithGpioEventOnFallingEdge(pin string, handler func(lineOffset int, timestamp time.Duration, detectedEdge string, seqno uint32, lseqno uint32), ) func(DigitalPinsOptioner)
WithGpioEventOnFallingEdge prepares the given input pin to be generate an event on falling edge. This is working for inputs since Kernel 5.10, but will be ignored for outputs or with sysfs ABI.
func WithGpioEventOnRisingEdge ¶
func WithGpioEventOnRisingEdge(pin string, handler func(lineOffset int, timestamp time.Duration, detectedEdge string, seqno uint32, lseqno uint32), ) func(DigitalPinsOptioner)
WithGpioEventOnRisingEdge prepares the given input pin to be generate an event on rising edge. This is working for inputs since Kernel 5.10, but will be ignored for outputs or with sysfs ABI.
func WithGpioPollForEdgeDetection ¶ added in v2.2.0
func WithGpioPollForEdgeDetection( pin string, pollInterval time.Duration, pollQuitChan chan struct{}, ) func(DigitalPinsOptioner)
WithGpioPollForEdgeDetection prepares the given input pin to use a discrete input pin polling function together with edge detection.
func WithGpiodAccess ¶
func WithGpiodAccess() func(DigitalPinsOptioner)
WithGpiodAccess can be used to change the default sysfs implementation to the character device Kernel ABI. The access is provided by the gpiod package.
func WithGpiosActiveLow ¶
func WithGpiosActiveLow(pin string, otherPins ...string) func(DigitalPinsOptioner)
WithGpiosActiveLow prepares the given pins for inverse reaction on next initialize. This is working for inputs and outputs.
func WithGpiosOpenDrain ¶
func WithGpiosOpenDrain(pin string, otherPins ...string) func(DigitalPinsOptioner)
WithGpiosOpenDrain prepares the given output pins to be driven with open drain/collector on next initialize. This will be ignored for inputs or with sysfs ABI.
func WithGpiosOpenSource ¶
func WithGpiosOpenSource(pin string, otherPins ...string) func(DigitalPinsOptioner)
WithGpiosOpenSource prepares the given output pins to be driven with open source/emitter on next initialize. This will be ignored for inputs or with sysfs ABI.
func WithGpiosPullDown ¶
func WithGpiosPullDown(pin string, otherPins ...string) func(DigitalPinsOptioner)
WithGpiosPullDown prepares the given pins to be pulled down (high impedance to GND) on next initialize. This is working for inputs and outputs since Kernel 5.5, but will be ignored with sysfs ABI.
func WithGpiosPullUp ¶
func WithGpiosPullUp(pin string, otherPins ...string) func(DigitalPinsOptioner)
WithGpiosPullUp prepares the given pins to be pulled up (high impedance to VDD) on next initialize. This is working for inputs and outputs since Kernel 5.5, but will be ignored with sysfs ABI.
func WithPWMDefaultPeriod ¶ added in v2.3.0
func WithPWMDefaultPeriod(periodNanoSec uint32) pwmPinsPeriodDefaultOption
WithPWMDefaultPeriod substitute the default period of 10 ms (100 Hz) for all created pins.
func WithPWMDefaultPeriodForPin ¶ added in v2.3.0
WithPWMDefaultPeriodForPin substitute the default period of 10 ms (100 Hz) for the given pin. This option also overrides a default period given by the WithPWMDefaultPeriod() option. This is often needed for servo applications, where the default period is 50Hz (20.000.000 ns).
func WithPWMMinimumDutyRate ¶ added in v2.3.0
func WithPWMMinimumDutyRate(dutyRate float64) pwmPinsDutyRateMinimumOption
WithPWMMinimumDutyRate substitute the default minimum duty rate of 1/period. The given limit only come into effect, if the rate is > 0, because a rate of 0.0 is always allowed.
func WithPWMMinimumPeriod ¶ added in v2.3.0
func WithPWMMinimumPeriod(periodNanoSec uint32) pwmPinsPeriodMinimumOption
WithPWMMinimumPeriod substitute the default minimum period limit of 0 nanoseconds.
func WithPWMNoDutyCycleAdjustment ¶ added in v2.3.0
func WithPWMNoDutyCycleAdjustment() pwmPinsAdjustDutyOnSetPeriodOption
WithPWMNoDutyCycleAdjustment switch off the automatic adjustment of duty cycle on setting the period.
func WithPWMPinInitializer ¶
func WithPWMPinInitializer(pc pwmPinInitializer) pwmPinsInitializeOption
WithPWMPinInitializer substitute the default initializer.
func WithPWMPolarityInvertedIdentifier ¶ added in v2.3.0
func WithPWMPolarityInvertedIdentifier(identifier string) pwmPinsPolarityInvertedIdentifierOption
WithPWMPolarityInvertedIdentifier use the given identifier, which will replace the default "inversed".
func WithPWMServoAngleRangeForPin ¶ added in v2.3.0
WithPWMServoAngleRangeForPin set new values for range of angle for servo calls, which replaces the default 0.0-180.0° range.
func WithPWMServoDutyCycleRangeForPin ¶ added in v2.3.0
func WithPWMServoDutyCycleRangeForPin(pin string, min, max time.Duration) pwmPinsServoDutyScaleForPinOption
WithPWMServoDutyCycleRangeForPin set new values for range of duty cycle for servo calls, which replaces the default 0.5-2.5 ms range. The given duration values will be internally converted to nanoseconds.
func WithPWMUsePiBlaster ¶ added in v2.3.0
func WithPWMUsePiBlaster() pwmPinsUsePiBlasterPinOption
WithPWMUsePiBlaster substitute the default sysfs-implementation for PWM-pins by the implementation for pi-blaster.
func WithSpiGpioAccess ¶
func WithSpiGpioAccess(sclkPin, nssPin, mosiPin, misoPin string) func(DigitalPinsOptioner)
WithSpiGpioAccess can be used to switch the default SPI implementation to GPIO usage.
Types ¶
type AnalogPinsAdaptor ¶ added in v2.3.0
type AnalogPinsAdaptor struct {
// contains filtered or unexported fields
}
AnalogPinsAdaptor is a adaptor for analog pins, normally used for composition in platforms. It is also usable for general sysfs access.
func NewAnalogPinsAdaptor ¶ added in v2.3.0
func NewAnalogPinsAdaptor(sys *system.Accesser, t analogPinTranslator) *AnalogPinsAdaptor
NewAnalogPinsAdaptor provides the access to analog pins of the board. Usually sysfs system drivers are used. The translator is used to adapt the pin header naming, which is given by user, to the internal file name nomenclature. This varies by each platform.
func (*AnalogPinsAdaptor) AnalogRead ¶ added in v2.3.0
func (a *AnalogPinsAdaptor) AnalogRead(id string) (int, error)
AnalogRead returns an analog value from specified pin or identifier, defined by the translation function.
func (*AnalogPinsAdaptor) AnalogWrite ¶ added in v2.3.0
func (a *AnalogPinsAdaptor) AnalogWrite(id string, val int) error
AnalogWrite writes an analog value to the specified pin or identifier, defined by the translation function.
func (*AnalogPinsAdaptor) Connect ¶ added in v2.3.0
func (a *AnalogPinsAdaptor) Connect() error
Connect prepare new connection to analog pins.
func (*AnalogPinsAdaptor) Finalize ¶ added in v2.3.0
func (a *AnalogPinsAdaptor) Finalize() error
Finalize closes connection to analog pins
type DigitalPinsAdaptor ¶
type DigitalPinsAdaptor struct {
// contains filtered or unexported fields
}
DigitalPinsAdaptor is a adaptor for digital pins, normally used for composition in platforms.
func NewDigitalPinsAdaptor ¶
func NewDigitalPinsAdaptor( sys *system.Accesser, t digitalPinTranslator, options ...func(DigitalPinsOptioner), ) *DigitalPinsAdaptor
NewDigitalPinsAdaptor provides the access to digital pins of the board. It supports sysfs and gpiod system drivers. This is decided by the given accesser. The translator is used to adapt the pin header naming, which is given by user, to the internal file name or chip/line nomenclature. This varies by each platform. If for some reasons the default initializer is not suitable, it can be given by the option "WithDigitalPinInitializer()". This is especially needed, if some values needs to be adjusted after the pin was created but before the pin is exported.
func (*DigitalPinsAdaptor) Connect ¶
func (a *DigitalPinsAdaptor) Connect() error
Connect prepare new connection to digital pins.
func (*DigitalPinsAdaptor) DigitalPin ¶
func (a *DigitalPinsAdaptor) DigitalPin(id string) (gobot.DigitalPinner, error)
DigitalPin returns a digital pin. If the pin is initially acquired, it is an input. Pin direction and other options can be changed afterwards by pin.ApplyOptions() at any time.
func (*DigitalPinsAdaptor) DigitalRead ¶
func (a *DigitalPinsAdaptor) DigitalRead(id string) (int, error)
DigitalRead reads digital value from pin
func (*DigitalPinsAdaptor) DigitalWrite ¶
func (a *DigitalPinsAdaptor) DigitalWrite(id string, val byte) error
DigitalWrite writes digital value to specified pin
func (*DigitalPinsAdaptor) Finalize ¶
func (a *DigitalPinsAdaptor) Finalize() error
Finalize closes connection to digital pins
type DigitalPinsOptioner ¶ added in v2.3.0
type DigitalPinsOptioner interface {
// contains filtered or unexported methods
}
DigitalPinsOptioner is the interface for digital adaptors options. This provides the possibility for change the platform behavior by the user when creating the platform, e.g. by "NewAdaptor()". TODO: change to applier-architecture, see options of pwmpinsadaptor.go
type I2cBusAdaptor ¶
type I2cBusAdaptor struct {
// contains filtered or unexported fields
}
I2cBusAdaptor is a adaptor for i2c bus, normally used for composition in platforms.
func NewI2cBusAdaptor ¶
func NewI2cBusAdaptor(sys *system.Accesser, v i2cBusNumberValidator, defaultBusNr int) *I2cBusAdaptor
NewI2cBusAdaptor provides the access to i2c buses of the board. The validator is used to check the bus number, which is given by user, to the abilities of the board.
func (*I2cBusAdaptor) Connect ¶
func (a *I2cBusAdaptor) Connect() error
Connect prepares the connection to i2c buses.
func (*I2cBusAdaptor) DefaultI2cBus ¶
func (a *I2cBusAdaptor) DefaultI2cBus() int
DefaultI2cBus returns the default i2c bus number for this platform.
func (*I2cBusAdaptor) Finalize ¶
func (a *I2cBusAdaptor) Finalize() error
Finalize closes all i2c buses.
func (*I2cBusAdaptor) GetI2cConnection ¶
func (a *I2cBusAdaptor) GetI2cConnection(address int, busNum int) (i2c.Connection, error)
GetI2cConnection returns a connection to a device on a specified i2c bus
type PWMPinsAdaptor ¶
type PWMPinsAdaptor struct {
// contains filtered or unexported fields
}
PWMPinsAdaptor is a adaptor for PWM pins, normally used for composition in platforms.
func NewPWMPinsAdaptor ¶
func NewPWMPinsAdaptor(sys *system.Accesser, t pwmPinTranslator, opts ...PwmPinsOptionApplier) *PWMPinsAdaptor
NewPWMPinsAdaptor provides the access to PWM pins of the board. It uses sysfs system drivers. The translator is used to adapt the pin header naming, which is given by user, to the internal file name nomenclature. This varies by each platform. If for some reasons the default initializer is not suitable, it can be given by the option "WithPWMPinInitializer()".
Further options:
"WithPWMDefaultPeriod" "WithPWMPolarityInvertedIdentifier" "WithPWMNoDutyCycleAdjustment" "WithPWMDefaultPeriodForPin" "WithPWMServoDutyCycleRangeForPin" "WithPWMServoAngleRangeForPin"
func (*PWMPinsAdaptor) Connect ¶
func (a *PWMPinsAdaptor) Connect() error
Connect prepare new connection to PWM pins.
func (*PWMPinsAdaptor) Finalize ¶
func (a *PWMPinsAdaptor) Finalize() error
Finalize closes connection to PWM pins.
func (*PWMPinsAdaptor) PWMPin ¶
func (a *PWMPinsAdaptor) PWMPin(id string) (gobot.PWMPinner, error)
PWMPin initializes the pin for PWM and returns matched pwmPin for specified pin number. It implements the PWMPinnerProvider interface.
func (*PWMPinsAdaptor) PwmWrite ¶
func (a *PWMPinsAdaptor) PwmWrite(id string, val byte) error
PwmWrite writes a PWM signal to the specified pin. The given value is between 0 and 255.
func (*PWMPinsAdaptor) ServoWrite ¶
func (a *PWMPinsAdaptor) ServoWrite(id string, angle byte) error
ServoWrite writes a servo signal to the specified pin. The given angle is between 0 and 180°.
type PwmPinsOptionApplier ¶ added in v2.3.0
type PwmPinsOptionApplier interface {
// contains filtered or unexported methods
}
pwmPinOptionApplier needs to be implemented by each configurable option type
type SpiBusAdaptor ¶
type SpiBusAdaptor struct {
// contains filtered or unexported fields
}
SpiBusAdaptor is a adaptor for SPI bus, normally used for composition in platforms.
func NewSpiBusAdaptor ¶
func NewSpiBusAdaptor(sys *system.Accesser, v spiBusNumberValidator, busNum, chipNum, mode, bits int, maxSpeed int64, ) *SpiBusAdaptor
NewSpiBusAdaptor provides the access to SPI buses of the board. The validator is used to check the bus number (given by user) to the abilities of the board.
func (*SpiBusAdaptor) Connect ¶
func (a *SpiBusAdaptor) Connect() error
Connect prepares the connection to SPI buses.
func (*SpiBusAdaptor) Finalize ¶
func (a *SpiBusAdaptor) Finalize() error
Finalize closes all SPI connections.
func (*SpiBusAdaptor) GetSpiConnection ¶
func (a *SpiBusAdaptor) GetSpiConnection(busNum, chipNum, mode, bits int, maxSpeed int64) (spi.Connection, error)
GetSpiConnection returns an spi connection to a device on a specified bus. Valid bus numbers range between 0 and 65536, valid chip numbers are 0 ... 255.
func (*SpiBusAdaptor) SpiDefaultBitCount ¶
func (a *SpiBusAdaptor) SpiDefaultBitCount() int
SpiDefaultBitCount returns the default number of bits used for this platform.
func (*SpiBusAdaptor) SpiDefaultBusNumber ¶
func (a *SpiBusAdaptor) SpiDefaultBusNumber() int
SpiDefaultBusNumber returns the default bus number for this platform.
func (*SpiBusAdaptor) SpiDefaultChipNumber ¶
func (a *SpiBusAdaptor) SpiDefaultChipNumber() int
SpiDefaultChipNumber returns the default chip number for this platform.
func (*SpiBusAdaptor) SpiDefaultMaxSpeed ¶
func (a *SpiBusAdaptor) SpiDefaultMaxSpeed() int64
SpiDefaultMaxSpeed returns the default maximal speed for this platform.
func (*SpiBusAdaptor) SpiDefaultMode ¶
func (a *SpiBusAdaptor) SpiDefaultMode() int
SpiDefaultMode returns the default SPI mode for this platform.