Documentation ¶
Index ¶
- func WithDigitalPinInitializer(pc digitalPinInitializer) func(Optioner)
- func WithGpioDebounce(pin string, period time.Duration) func(Optioner)
- func WithGpioEventOnBothEdges(pin string, ...) func(Optioner)
- func WithGpioEventOnFallingEdge(pin string, ...) func(Optioner)
- func WithGpioEventOnRisingEdge(pin string, ...) func(Optioner)
- func WithGpiodAccess() func(Optioner)
- func WithGpiosActiveLow(pin string, otherPins ...string) func(Optioner)
- func WithGpiosOpenDrain(pin string, otherPins ...string) func(Optioner)
- func WithGpiosOpenSource(pin string, otherPins ...string) func(Optioner)
- func WithGpiosPullDown(pin string, otherPins ...string) func(Optioner)
- func WithGpiosPullUp(pin string, otherPins ...string) func(Optioner)
- func WithPWMPinDefaultPeriod(periodNanoSec uint32) func(pwmPinsOption)
- func WithPWMPinInitializer(pc pwmPinInitializer) func(pwmPinsOption)
- func WithPolarityInvertedIdentifier(identifier string) func(pwmPinsOption)
- func WithSpiGpioAccess(sclkPin, nssPin, mosiPin, misoPin string) func(Optioner)
- 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() (err error)
- type I2cBusAdaptor
- type Optioner
- type PWMPinsAdaptor
- func (a *PWMPinsAdaptor) Connect() error
- func (a *PWMPinsAdaptor) Finalize() (err error)
- func (a *PWMPinsAdaptor) PWMPin(id string) (gobot.PWMPinner, error)
- func (a *PWMPinsAdaptor) PwmWrite(id string, val byte) (err error)
- func (a *PWMPinsAdaptor) ServoWrite(id string, angle byte) (err error)
- func (a *PWMPinsAdaptor) SetPeriod(id string, period uint32) error
- 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(Optioner)
WithDigitalPinInitializer can be used to substitute the default initializer.
func WithGpioDebounce ¶
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(Optioner)
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(Optioner)
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(Optioner)
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 WithGpiodAccess ¶
func WithGpiodAccess() func(Optioner)
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 ¶
WithGpiosActiveLow prepares the given pins for inverse reaction on next initialize. This is working for inputs and outputs.
func WithGpiosOpenDrain ¶
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 ¶
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 ¶
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 ¶
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 WithPWMPinDefaultPeriod ¶
func WithPWMPinDefaultPeriod(periodNanoSec uint32) func(pwmPinsOption)
WithPWMPinDefaultPeriod substitute the default period of 10 ms (100 Hz) for all created pins.
func WithPWMPinInitializer ¶
func WithPWMPinInitializer(pc pwmPinInitializer) func(pwmPinsOption)
WithPWMPinInitializer substitute the default initializer.
func WithPolarityInvertedIdentifier ¶
func WithPolarityInvertedIdentifier(identifier string) func(pwmPinsOption)
WithPolarityInvertedIdentifier use the given identifier, which will replace the default "inverted".
func WithSpiGpioAccess ¶
WithSpiGpioAccess can be used to switch the default SPI implementation to GPIO usage.
Types ¶
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(Optioner)) *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() (err error)
Finalize closes connection to digital pins
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 Optioner ¶
type Optioner interface {
// contains filtered or unexported methods
}
Optioner is the interface for adaptors options. This provides the possibility for change the platform behavior by the user when creating the platform, e.g. by "NewAdaptor()".
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, options ...func(pwmPinsOption)) *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()".
func (*PWMPinsAdaptor) Connect ¶
func (a *PWMPinsAdaptor) Connect() error
Connect prepare new connection to PWM pins.
func (*PWMPinsAdaptor) Finalize ¶
func (a *PWMPinsAdaptor) Finalize() (err 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) (err error)
PwmWrite writes a PWM signal to the specified pin.
func (*PWMPinsAdaptor) ServoWrite ¶
func (a *PWMPinsAdaptor) ServoWrite(id string, angle byte) (err error)
ServoWrite writes a servo signal to the specified pin.
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.