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 ¶
- type AnalogReader
- type AnalogSensorDriver
- type AnalogWriter
- type ButtonDriver
- type DigitalReader
- type DigitalWriter
- type DirectPin
- type DirectPinDriver
- func (d *DirectPinDriver) AnalogRead() int
- func (d *DirectPinDriver) AnalogWrite(level byte)
- func (d *DirectPinDriver) DigitalRead() int
- func (d *DirectPinDriver) DigitalWrite(level byte)
- func (d *DirectPinDriver) Halt() bool
- func (d *DirectPinDriver) PwmWrite(level byte)
- func (d *DirectPinDriver) ServoWrite(level byte)
- func (d *DirectPinDriver) Start() bool
- type LedDriver
- type MakeyButtonDriver
- type MotorDriver
- func (m *MotorDriver) Backward(speed byte)
- func (m *MotorDriver) Direction(direction string)
- func (m *MotorDriver) Forward(speed byte)
- func (m *MotorDriver) Halt() bool
- func (m *MotorDriver) IsOff() bool
- func (m *MotorDriver) IsOn() bool
- func (m *MotorDriver) Max()
- func (m *MotorDriver) Min()
- func (m *MotorDriver) Off()
- func (m *MotorDriver) On()
- func (m *MotorDriver) Speed(value byte)
- func (m *MotorDriver) Start() bool
- func (m *MotorDriver) Toggle()
- type Pwm
- type PwmDigitalWriter
- type Servo
- type ServoDriver
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnalogReader ¶
type AnalogSensorDriver ¶
Represents an Analog Sensor
func NewAnalogSensorDriver ¶
func NewAnalogSensorDriver(a AnalogReader, name string, pin string) *AnalogSensorDriver
NewAnalogSensorDriver returns a new AnalogSensorDriver given an AnalogReader, name and pin.
Adds the following API Commands:
"Read" - See AnalogSensor.Read
func (*AnalogSensorDriver) Halt ¶
func (a *AnalogSensorDriver) Halt() bool
Halt returns true on a successful halt of the driver
func (*AnalogSensorDriver) Read ¶
func (a *AnalogSensorDriver) Read() int
Read returns the current reading from the Analog Sensor
func (*AnalogSensorDriver) Start ¶
func (a *AnalogSensorDriver) Start() bool
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 AnalogWriter ¶
type ButtonDriver ¶
Represents a digital Button
func NewButtonDriver ¶
func NewButtonDriver(a DigitalReader, name string, pin string) *ButtonDriver
NewButtonDriver return a new ButtonDriver given a DigitalReader, name and pin
func (*ButtonDriver) Halt ¶
func (b *ButtonDriver) Halt() bool
Halt returns true on a successful halt of the driver
func (*ButtonDriver) Start ¶
func (b *ButtonDriver) Start() bool
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
type DigitalReader ¶
type DigitalWriter ¶
type DirectPin ¶
type DirectPin interface { DigitalWriter DigitalReader Pwm Servo AnalogWriter AnalogReader }
type DirectPinDriver ¶
Represents a raw GPIO pin
func NewDirectPinDriver ¶
func NewDirectPinDriver(a DirectPin, 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() int
AnalogRead reads the current analog reading of the pin
func (*DirectPinDriver) AnalogWrite ¶
func (d *DirectPinDriver) AnalogWrite(level byte)
AnalogWrite writes to the pin
func (*DirectPinDriver) DigitalRead ¶
func (d *DirectPinDriver) DigitalRead() int
DigitalRead returns the current digital state of the pin
func (*DirectPinDriver) DigitalWrite ¶
func (d *DirectPinDriver) DigitalWrite(level byte)
DigitalWrite writes to the pin
func (*DirectPinDriver) Halt ¶
func (d *DirectPinDriver) Halt() bool
Halts the DirectPinDriver. Returns true on successful halt of the driver
func (*DirectPinDriver) PwmWrite ¶
func (d *DirectPinDriver) PwmWrite(level byte)
PwmWrite writes to the pin
func (*DirectPinDriver) ServoWrite ¶
func (d *DirectPinDriver) ServoWrite(level byte)
ServoWrite writes to the pin
func (*DirectPinDriver) Start ¶
func (d *DirectPinDriver) Start() bool
Starts the DirectPinDriver. Returns true on successful start of the driver
type LedDriver ¶
Represents a digital Led
func NewLedDriver ¶
func NewLedDriver(a PwmDigitalWriter, 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) Start ¶
Start starts the LedDriver. Returns true on successful start of the driver
type MakeyButtonDriver ¶
type MakeyButtonDriver struct { gobot.Driver Active bool // contains filtered or unexported fields }
Represents a Makey Button
func NewMakeyButtonDriver ¶
func NewMakeyButtonDriver(a DigitalReader, name string, pin string) *MakeyButtonDriver
NewMakeyButtonDriver returns a new MakeyButtonDriver given a DigitalRead, name and pin.
func (*MakeyButtonDriver) Halt ¶
func (m *MakeyButtonDriver) Halt() bool
Halt returns true on a successful halt of the driver
func (*MakeyButtonDriver) Start ¶
func (m *MakeyButtonDriver) Start() bool
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 { gobot.Driver SpeedPin string SwitchPin string DirectionPin string ForwardPin string BackwardPin string CurrentState byte CurrentSpeed byte CurrentMode string CurrentDirection string }
Represents a Motor
func NewMotorDriver ¶
func NewMotorDriver(a PwmDigitalWriter, name string, pin string) *MotorDriver
NewMotorDriver return a new MotorDriver given a PwmDigitalWriter, name and pin
func (*MotorDriver) Backward ¶
func (m *MotorDriver) Backward(speed byte)
Backward sets the backward pin to the specified speed
func (*MotorDriver) Direction ¶
func (m *MotorDriver) Direction(direction string)
Direction sets the direction pin to the specified speed
func (*MotorDriver) Forward ¶
func (m *MotorDriver) Forward(speed byte)
Forward sets the forward pin to the specified speed
func (*MotorDriver) Halt ¶
func (m *MotorDriver) Halt() bool
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) Off ¶
func (m *MotorDriver) Off()
Off turns the motor off or sets the motor to a 0 speed
func (*MotorDriver) On ¶
func (m *MotorDriver) On()
On turns the motor on or sets the motor to a maximum speed
func (*MotorDriver) Speed ¶
func (m *MotorDriver) Speed(value byte)
Speed sets the speed of the motor
func (*MotorDriver) Start ¶
func (m *MotorDriver) Start() bool
Start starts the MotorDriver. Returns true on successful start of the driver
func (*MotorDriver) Toggle ¶
func (m *MotorDriver) Toggle()
Toggle sets the motor to the opposite of it's current state
type PwmDigitalWriter ¶
type PwmDigitalWriter interface { DigitalWriter Pwm }
type ServoDriver ¶
Represents a Servo
func NewServoDriver ¶
func NewServoDriver(a Servo, 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()
Center sets the servo to it's center position
func (*ServoDriver) Halt ¶
func (s *ServoDriver) Halt() bool
Halt halts the ServoDriver. Returns true on successful halt of the driver.
func (*ServoDriver) InitServo ¶
func (s *ServoDriver) InitServo()
InitServo initializes the ServoDriver on platforms which require an explicit initialization.
func (*ServoDriver) Move ¶
func (s *ServoDriver) Move(angle uint8)
Move sets the servo to the specified angle
func (*ServoDriver) Start ¶
func (s *ServoDriver) Start() bool
Start starts the ServoDriver. Returns true on successful start of the driver.