2013-10-22 16:45:31 -07:00
|
|
|
package gobot
|
2013-10-23 22:00:03 -07:00
|
|
|
|
2022-11-20 19:22:26 +01:00
|
|
|
// DigitalPinner is the interface for system gpio interactions
|
|
|
|
type DigitalPinner interface {
|
|
|
|
// Export exports the pin for use by the operating system
|
|
|
|
Export() error
|
|
|
|
// Unexport unexports the pin and releases the pin from the operating system
|
|
|
|
Unexport() error
|
|
|
|
// Direction sets the direction for the pin
|
|
|
|
Direction(string) error
|
|
|
|
// Read reads the current value of the pin
|
|
|
|
Read() (int, error)
|
|
|
|
// Write writes to the pin
|
|
|
|
Write(int) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// DigitalPinnerProvider is the interface that an Adaptor should implement to allow
|
|
|
|
// clients to obtain access to any DigitalPin's available on that board.
|
|
|
|
type DigitalPinnerProvider interface {
|
|
|
|
DigitalPin(string, string) (DigitalPinner, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// PWMPinner is the interface for system PWM interactions
|
|
|
|
type PWMPinner interface {
|
|
|
|
// Export exports the pin for use by the operating system
|
|
|
|
Export() error
|
|
|
|
// Unexport unexports the pin and releases the pin from the operating system
|
|
|
|
Unexport() error
|
|
|
|
// Enable enables/disables the PWM pin
|
|
|
|
// TODO: rename to "SetEnable(bool)" according to golang style and allow "Enable()" to be the getter function
|
|
|
|
Enable(bool) (err error)
|
|
|
|
// Polarity returns the polarity either normal or inverted
|
|
|
|
Polarity() (polarity string, err error)
|
|
|
|
// SetPolarity writes value to pwm polarity path
|
|
|
|
SetPolarity(value string) (err error)
|
|
|
|
// InvertPolarity sets the polarity to inverted if called with true
|
|
|
|
InvertPolarity(invert bool) (err error)
|
|
|
|
// Period returns the current PWM period for pin
|
|
|
|
Period() (period uint32, err error)
|
|
|
|
// SetPeriod sets the current PWM period for pin
|
|
|
|
SetPeriod(period uint32) (err error)
|
|
|
|
// DutyCycle returns the duty cycle for the pin
|
|
|
|
DutyCycle() (duty uint32, err error)
|
|
|
|
// SetDutyCycle writes the duty cycle to the pin
|
|
|
|
SetDutyCycle(duty uint32) (err error)
|
|
|
|
}
|
|
|
|
|
|
|
|
// PWMPinnerProvider is the interface that an Adaptor should implement to allow
|
|
|
|
// clients to obtain access to any PWMPin's available on that board.
|
|
|
|
type PWMPinnerProvider interface {
|
|
|
|
PWMPin(string) (PWMPinner, error)
|
|
|
|
}
|
|
|
|
|
2014-12-31 05:15:52 -08:00
|
|
|
// Adaptor is the interface that describes an adaptor in gobot
|
2014-11-20 18:00:32 -08:00
|
|
|
type Adaptor interface {
|
2014-12-31 05:15:52 -08:00
|
|
|
// Name returns the label for the Adaptor
|
2014-07-03 19:52:31 -07:00
|
|
|
Name() string
|
2016-09-25 11:46:55 +02:00
|
|
|
// SetName sets the label for the Adaptor
|
|
|
|
SetName(n string)
|
2014-12-31 05:15:52 -08:00
|
|
|
// Connect initiates the Adaptor
|
2016-11-07 14:55:21 +01:00
|
|
|
Connect() error
|
2014-12-31 05:15:52 -08:00
|
|
|
// Finalize terminates the Adaptor
|
2016-11-07 14:55:21 +01:00
|
|
|
Finalize() error
|
2014-11-21 19:35:01 -08:00
|
|
|
}
|
|
|
|
|
2014-12-31 05:15:52 -08:00
|
|
|
// Porter is the interface that describes an adaptor's port
|
2014-11-21 19:35:01 -08:00
|
|
|
type Porter interface {
|
2014-11-20 18:00:32 -08:00
|
|
|
Port() string
|
2014-06-13 10:46:58 -07:00
|
|
|
}
|