Documentation ¶
Overview ¶
Package gpio provides Gobot drivers for General Purpose Input/Output devices.
Installing:
go get github.com/hybridgroup/gobot/platforms/gpio
For further information refer to gpio README: https://github.com/hybridgroup/gobot/blob/master/platforms/gpio/README.md
Index ¶
- Constants
- Variables
- type AnalogReader
- type AnalogSensorDriver
- func (a *AnalogSensorDriver) Connection() gobot.Connection
- func (a *AnalogSensorDriver) Halt() (errs []error)
- func (a *AnalogSensorDriver) Name() string
- func (a *AnalogSensorDriver) Pin() string
- func (a *AnalogSensorDriver) Read() (val int, err error)
- func (a *AnalogSensorDriver) Start() (errs []error)
- type ButtonDriver
- type DigitalReader
- type DigitalWriter
- type DirectPinDriver
- func (d *DirectPinDriver) AnalogRead() (val int, err error)
- func (d *DirectPinDriver) Connection() gobot.Connection
- func (d *DirectPinDriver) DigitalRead() (val int, err error)
- func (d *DirectPinDriver) DigitalWrite(level byte) (err error)
- func (d *DirectPinDriver) Halt() (errs []error)
- func (d *DirectPinDriver) Name() string
- func (d *DirectPinDriver) Pin() string
- func (d *DirectPinDriver) PwmWrite(level byte) (err error)
- func (d *DirectPinDriver) ServoWrite(level byte) (err error)
- func (d *DirectPinDriver) Start() (errs []error)
- type LedDriver
- func (l *LedDriver) Brightness(level byte) (err error)
- func (l *LedDriver) Connection() gobot.Connection
- func (l *LedDriver) Halt() (errs []error)
- func (l *LedDriver) Name() string
- func (l *LedDriver) Off() (err error)
- func (l *LedDriver) On() (err error)
- func (l *LedDriver) Pin() string
- func (l *LedDriver) Start() (errs []error)
- func (l *LedDriver) State() bool
- func (l *LedDriver) Toggle() (err error)
- type MakeyButtonDriver
- type MotorDriver
- func (m *MotorDriver) Backward(speed byte) (err error)
- func (m *MotorDriver) Connection() gobot.Connection
- func (m *MotorDriver) Direction(direction string) (err error)
- func (m *MotorDriver) Forward(speed byte) (err error)
- func (m *MotorDriver) Halt() (errs []error)
- func (m *MotorDriver) IsOff() bool
- func (m *MotorDriver) IsOn() bool
- func (m *MotorDriver) Max() (err error)
- func (m *MotorDriver) Min() (err error)
- func (m *MotorDriver) Name() string
- func (m *MotorDriver) Off() (err error)
- func (m *MotorDriver) On() (err error)
- func (m *MotorDriver) Speed(value byte) (err error)
- func (m *MotorDriver) Start() (errs []error)
- func (m *MotorDriver) Toggle() (err error)
- type PwmWriter
- type ServoDriver
- func (s *ServoDriver) Center() (err error)
- func (s *ServoDriver) Connection() gobot.Connection
- func (s *ServoDriver) Halt() (errs []error)
- func (s *ServoDriver) Max() (err error)
- func (s *ServoDriver) Min() (err error)
- func (s *ServoDriver) Move(angle uint8) (err error)
- func (s *ServoDriver) Name() string
- func (s *ServoDriver) Pin() string
- func (s *ServoDriver) Start() (errs []error)
- type ServoWriter
Constants ¶
const ( Release = "release" Push = "push" Error = "error" Data = "data" )
Variables ¶
var ( ErrServoWriteUnsupported = errors.New("ServoWrite is not supported by this platform") ErrPwmWriteUnsupported = errors.New("PwmWrite is not supported by this platform") ErrAnalogReadUnsupported = errors.New("AnalogRead is not supported by this platform") ErrDigitalWriteUnsupported = errors.New("DigitalWrite is not supported by this platform") ErrDigitalReadUnsupported = errors.New("DigitalRead is not supported by this platform") ErrServoOutOfRange = errors.New("servo angle must be between 0-180") )
Functions ¶
This section is empty.
Types ¶
type AnalogReader ¶
type AnalogSensorDriver ¶
type AnalogSensorDriver struct { gobot.Eventer gobot.Commander // contains filtered or unexported fields }
Represents an Analog Sensor
func NewAnalogSensorDriver ¶
func NewAnalogSensorDriver(a AnalogReader, name string, pin string, v ...time.Duration) *AnalogSensorDriver
NewAnalogSensorDriver returns a new AnalogSensorDriver given an AnalogReader, name and pin.
Adds the following API Commands:
"Read" - See AnalogSensor.Read
func (*AnalogSensorDriver) Connection ¶
func (a *AnalogSensorDriver) Connection() gobot.Connection
func (*AnalogSensorDriver) Halt ¶
func (a *AnalogSensorDriver) Halt() (errs []error)
Halt returns true on a successful halt of the driver
func (*AnalogSensorDriver) Name ¶
func (a *AnalogSensorDriver) Name() string
func (*AnalogSensorDriver) Pin ¶
func (a *AnalogSensorDriver) Pin() string
func (*AnalogSensorDriver) Read ¶
func (a *AnalogSensorDriver) Read() (val int, err error)
Read returns the current reading from the Analog Sensor
func (*AnalogSensorDriver) Start ¶
func (a *AnalogSensorDriver) Start() (errs []error)
Starts the AnalogSensorDriver and reads the Analog Sensor at the given Driver.Interval(). Returns true on successful start of the driver. Emits the Events:
"data" int - Event is emitted on change and represents the current reading from the sensor.
type ButtonDriver ¶
Represents a digital Button
func NewButtonDriver ¶
func NewButtonDriver(a DigitalReader, name string, pin string, v ...time.Duration) *ButtonDriver
NewButtonDriver return a new ButtonDriver given a DigitalReader, name and pin
func (*ButtonDriver) Connection ¶
func (b *ButtonDriver) Connection() gobot.Connection
func (*ButtonDriver) Halt ¶
func (b *ButtonDriver) Halt() (errs []error)
Halt returns true on a successful halt of the driver
func (*ButtonDriver) Name ¶
func (b *ButtonDriver) Name() string
func (*ButtonDriver) Pin ¶
func (b *ButtonDriver) Pin() string
func (*ButtonDriver) Start ¶
func (b *ButtonDriver) Start() (errs []error)
Starts the ButtonDriver and reads the state of the button at the given Driver.Interval(). Returns true on successful start of the driver.
Emits the Events:
"push" int - On button push "release" int - On button release "error" error - On button error
type DigitalReader ¶
type DigitalWriter ¶
type DirectPinDriver ¶
Represents a raw GPIO pin
func NewDirectPinDriver ¶
func NewDirectPinDriver(a gobot.Connection, name string, pin string) *DirectPinDriver
NewDirectPinDriver return a new DirectPinDriver given a DirectPin, name and pin.
Adds the following API Commands:
"DigitalRead" - See DirectPinDriver.DigitalRead "DigitalWrite" - See DirectPinDriver.DigitalWrite "AnalogRead" - See DirectPinDriver.AnalogRead "AnalogWrite" - See DirectPinDriver.AnalogWrite "PwmWrite" - See DirectPinDriver.PwmWrite "ServoWrite" - See DirectPinDriver.ServoWrite
func (*DirectPinDriver) AnalogRead ¶
func (d *DirectPinDriver) AnalogRead() (val int, err error)
AnalogRead reads the current analog reading of the pin
func (*DirectPinDriver) Connection ¶
func (d *DirectPinDriver) Connection() gobot.Connection
func (*DirectPinDriver) DigitalRead ¶
func (d *DirectPinDriver) DigitalRead() (val int, err error)
DigitalRead returns the current digital state of the pin
func (*DirectPinDriver) DigitalWrite ¶
func (d *DirectPinDriver) DigitalWrite(level byte) (err error)
DigitalWrite writes to the pin
func (*DirectPinDriver) Halt ¶
func (d *DirectPinDriver) Halt() (errs []error)
Halts the DirectPinDriver. Returns true on successful halt of the driver
func (*DirectPinDriver) Name ¶
func (d *DirectPinDriver) Name() string
func (*DirectPinDriver) Pin ¶
func (d *DirectPinDriver) Pin() string
func (*DirectPinDriver) PwmWrite ¶
func (d *DirectPinDriver) PwmWrite(level byte) (err error)
PwmWrite writes to the pin
func (*DirectPinDriver) ServoWrite ¶
func (d *DirectPinDriver) ServoWrite(level byte) (err error)
ServoWrite writes to the pin
func (*DirectPinDriver) Start ¶
func (d *DirectPinDriver) Start() (errs []error)
Starts the DirectPinDriver. Returns true on successful start of the driver
type LedDriver ¶
Represents a digital Led
func NewLedDriver ¶
func NewLedDriver(a DigitalWriter, name string, pin string) *LedDriver
NewLedDriver return a new LedDriver given a PwmDigitalWriter, name and pin.
Adds the following API Commands:
"Brightness" - See LedDriver.Brightness "Toggle" - See LedDriver.Toggle "On" - See LedDriver.On "Off" - See LedDriver.Off
func (*LedDriver) Brightness ¶
Brightness sets the led to the specified level of brightness
func (*LedDriver) Connection ¶
func (l *LedDriver) Connection() gobot.Connection
func (*LedDriver) Start ¶
Start starts the LedDriver. Returns true on successful start of the driver
type MakeyButtonDriver ¶
type MakeyButtonDriver struct { Active bool gobot.Eventer // contains filtered or unexported fields }
Represents a Makey Button
func NewMakeyButtonDriver ¶
func NewMakeyButtonDriver(a DigitalReader, name string, pin string, v ...time.Duration) *MakeyButtonDriver
NewMakeyButtonDriver returns a new MakeyButtonDriver given a DigitalRead, name and pin.
func (*MakeyButtonDriver) Connection ¶
func (b *MakeyButtonDriver) Connection() gobot.Connection
func (*MakeyButtonDriver) Halt ¶
func (m *MakeyButtonDriver) Halt() (errs []error)
Halt returns true on a successful halt of the driver
func (*MakeyButtonDriver) Name ¶
func (b *MakeyButtonDriver) Name() string
func (*MakeyButtonDriver) Pin ¶
func (b *MakeyButtonDriver) Pin() string
func (*MakeyButtonDriver) Start ¶
func (m *MakeyButtonDriver) Start() (errs []error)
Starts the MakeyButtonDriver and reads the state of the button at the given Driver.Interval(). Returns true on successful start of the driver.
Emits the Events:
"push" int - On button push "release" int - On button release
type MotorDriver ¶
type MotorDriver struct { SpeedPin string SwitchPin string DirectionPin string ForwardPin string BackwardPin string CurrentState byte CurrentSpeed byte CurrentMode string CurrentDirection string // contains filtered or unexported fields }
Represents a Motor
func NewMotorDriver ¶
func NewMotorDriver(a DigitalWriter, name string, speedPin string) *MotorDriver
NewMotorDriver return a new MotorDriver given a DigitalWriter, name and pin
func (*MotorDriver) Backward ¶
func (m *MotorDriver) Backward(speed byte) (err error)
Backward sets the backward pin to the specified speed
func (*MotorDriver) Connection ¶
func (m *MotorDriver) Connection() gobot.Connection
func (*MotorDriver) Direction ¶
func (m *MotorDriver) Direction(direction string) (err error)
Direction sets the direction pin to the specified speed
func (*MotorDriver) Forward ¶
func (m *MotorDriver) Forward(speed byte) (err error)
Forward sets the forward pin to the specified speed
func (*MotorDriver) Halt ¶
func (m *MotorDriver) Halt() (errs []error)
Halt halts the MotorDriver. Returns true on successful halt of the driver
func (*MotorDriver) IsOff ¶
func (m *MotorDriver) IsOff() bool
InOff returns true if the motor is off
func (*MotorDriver) Max ¶
func (m *MotorDriver) Max() (err error)
Max sets the motor to the maximum speed
func (*MotorDriver) Min ¶
func (m *MotorDriver) Min() (err error)
Min sets the motor to the minimum speed
func (*MotorDriver) Name ¶
func (m *MotorDriver) Name() string
func (*MotorDriver) Off ¶
func (m *MotorDriver) Off() (err error)
Off turns the motor off or sets the motor to a 0 speed
func (*MotorDriver) On ¶
func (m *MotorDriver) On() (err error)
On turns the motor on or sets the motor to a maximum speed
func (*MotorDriver) Speed ¶
func (m *MotorDriver) Speed(value byte) (err error)
Speed sets the speed of the motor
func (*MotorDriver) Start ¶
func (m *MotorDriver) Start() (errs []error)
Start starts the MotorDriver. Returns true on successful start of the driver
func (*MotorDriver) Toggle ¶
func (m *MotorDriver) Toggle() (err error)
Toggle sets the motor to the opposite of it's current state
type ServoDriver ¶
type ServoDriver struct { gobot.Commander CurrentAngle byte // contains filtered or unexported fields }
Represents a Servo
func NewServoDriver ¶
func NewServoDriver(a ServoWriter, name string, pin string) *ServoDriver
NewSerovDriver return a new ServoDriver given a Servo, name and pin.
Adds the following API Commands:
"Move" - See ServoDriver.Move "Min" - See ServoDriver.Min "Center" - See ServoDriver.Center "Max" - See ServoDriver.Max
func (*ServoDriver) Center ¶
func (s *ServoDriver) Center() (err error)
Center sets the servo to it's center position
func (*ServoDriver) Connection ¶
func (s *ServoDriver) Connection() gobot.Connection
func (*ServoDriver) Halt ¶
func (s *ServoDriver) Halt() (errs []error)
Halt halts the ServoDriver. Returns true on successful halt of the driver.
func (*ServoDriver) Max ¶
func (s *ServoDriver) Max() (err error)
Max sets the servo to its maximum position
func (*ServoDriver) Min ¶
func (s *ServoDriver) Min() (err error)
Min sets the servo to it's minimum position
func (*ServoDriver) Move ¶
func (s *ServoDriver) Move(angle uint8) (err error)
Move sets the servo to the specified angle
func (*ServoDriver) Name ¶
func (s *ServoDriver) Name() string
func (*ServoDriver) Pin ¶
func (s *ServoDriver) Pin() string
func (*ServoDriver) Start ¶
func (s *ServoDriver) Start() (errs []error)
Start starts the ServoDriver. Returns true on successful start of the driver.