gobot: gobot.io/x/gobot/drivers/gpio Index | Files

package gpio

import "gobot.io/x/gobot/drivers/gpio"

Package gpio provides Gobot drivers for General Purpose Input/Output devices.

Installing:

go get -d -u gobot.io/x/gobot

For further information refer to gpio README: https://github.com/hybridgroup/gobot/blob/master/platforms/gpio/README.md

Index

Package Files

aip1640_driver.go button_driver.go buzzer_driver.go direct_pin_driver.go doc.go gpio.go grove_drivers.go led_driver.go makey_button_driver.go max7219_driver.go motor_driver.go pir_motion_driver.go relay_driver.go rgb_led_driver.go servo_driver.go stepper_driver.go tm1638_driver.go

Constants

const (
    AIP1640DataCmd  = 0x40
    AIP1640DispCtrl = 0x88
    AIP1640AddrCmd  = 0xC0

    AIP1640FixedAddr = 0x04
)
const (
    Whole   = 4
    Half    = 2
    Quarter = 1
    Eighth  = 0.500
)
const (
    Rest = 0
    C0   = 16.35
    Db0  = 17.32
    D0   = 18.35
    Eb0  = 19.45
    E0   = 20.60
    F0   = 21.83
    Gb0  = 23.12
    G0   = 24.50
    Ab0  = 25.96
    A0   = 27.50
    Bb0  = 29.14
    B0   = 30.87
    C1   = 32.70
    Db1  = 34.65
    D1   = 36.71
    Eb1  = 38.89
    E1   = 41.20
    F1   = 43.65
    Gb1  = 46.25
    G1   = 49.00
    Ab1  = 51.91
    A1   = 55.00
    Bb1  = 58.27
    B1   = 61.74
    C2   = 65.41
    Db2  = 69.30
    D2   = 73.42
    Eb2  = 77.78
    E2   = 82.41
    F2   = 87.31
    Gb2  = 92.50
    G2   = 98.00
    Ab2  = 103.83
    A2   = 110.00
    Bb2  = 116.54
    B2   = 123.47
    C3   = 130.81
    Db3  = 138.59
    D3   = 146.83
    Eb3  = 155.56
    E3   = 164.81
    F3   = 174.61
    Gb3  = 185.00
    G3   = 196.00
    Ab3  = 207.65
    A3   = 220.00
    Bb3  = 233.08
    B3   = 246.94
    C4   = 261.63
    Db4  = 277.18
    D4   = 293.66
    Eb4  = 311.13
    E4   = 329.63
    F4   = 349.23
    Gb4  = 369.99
    G4   = 392.00
    Ab4  = 415.30
    A4   = 440.00
    Bb4  = 466.16
    B4   = 493.88
    C5   = 523.25
    Db5  = 554.37
    D5   = 587.33
    Eb5  = 622.25
    E5   = 659.25
    F5   = 698.46
    Gb5  = 739.99
    G5   = 783.99
    Ab5  = 830.61
    A5   = 880.00
    Bb5  = 932.33
    B5   = 987.77
    C6   = 1046.50
    Db6  = 1108.73
    D6   = 1174.66
    Eb6  = 1244.51
    E6   = 1318.51
    F6   = 1396.91
    Gb6  = 1479.98
    G6   = 1567.98
    Ab6  = 1661.22
    A6   = 1760.00
    Bb6  = 1864.66
    B6   = 1975.53
    C7   = 2093.00
    Db7  = 2217.46
    D7   = 2349.32
    Eb7  = 2489.02
    E7   = 2637.02
    F7   = 2793.83
    Gb7  = 2959.96
    G7   = 3135.96
    Ab7  = 3322.44
    A7   = 3520.00
    Bb7  = 3729.31
    B7   = 3951.07
    C8   = 4186.01
    Db8  = 4434.92
    D8   = 4698.63
    Eb8  = 4978.03
    E8   = 5274.04
    F8   = 5587.65
    Gb8  = 5919.91
    G8   = 6271.93
    Ab8  = 6644.88
    A8   = 7040.00
    Bb8  = 7458.62
    B8   = 7902.13
)
const (
    // Error event
    Error = "error"
    // ButtonRelease event
    ButtonRelease = "release"
    // ButtonPush event
    ButtonPush = "push"
    // Data event
    Data = "data"
    // Vibration event
    Vibration = "vibration"
    // MotionDetected event
    MotionDetected = "motion-detected"
    // MotionStopped event
    MotionStopped = "motion-stopped"
)
const (
    MAX7219Digit0 = 0x01
    MAX7219Digit1 = 0x02
    MAX7219Digit2 = 0x03
    MAX7219Digit3 = 0x04
    MAX7219Digit4 = 0x05
    MAX7219Digit5 = 0x06
    MAX7219Digit6 = 0x07
    MAX7219Digit7 = 0x08

    MAX7219DecodeMode  = 0x09
    MAX7219Intensity   = 0x0a
    MAX7219ScanLimit   = 0x0b
    MAX7219Shutdown    = 0x0c
    MAX7219DisplayTest = 0x0f
)
const (
    TM1638None = iota
    TM1638Red
    TM1638Green
)
const (
    TM1638DataCmd  = 0x40
    TM1638DispCtrl = 0x80
    TM1638AddrCmd  = 0xC0

    TM1638WriteDisp = 0x00
    TM1638ReadKeys  = 0x02
    TM1638FixedAddr = 0x04
)

Variables

var (
    // ErrServoWriteUnsupported is the error resulting when a driver attempts to use
    // hardware capabilities which a connection does not support
    ErrServoWriteUnsupported = errors.New("ServoWrite is not supported by this platform")
    // ErrPwmWriteUnsupported is the error resulting when a driver attempts to use
    // hardware capabilities which a connection does not support
    ErrPwmWriteUnsupported = errors.New("PwmWrite is not supported by this platform")
    // ErrAnalogReadUnsupported is error resulting when a driver attempts to use
    // hardware capabilities which a connection does not support
    ErrAnalogReadUnsupported = errors.New("AnalogRead is not supported by this platform")
    // ErrDigitalWriteUnsupported is the error resulting when a driver attempts to use
    // hardware capabilities which a connection does not support
    ErrDigitalWriteUnsupported = errors.New("DigitalWrite is not supported by this platform")
    // ErrDigitalReadUnsupported is the error resulting when a driver attempts to use
    // hardware capabilities which a connection does not support
    ErrDigitalReadUnsupported = errors.New("DigitalRead is not supported by this platform")
    // ErrServoOutOfRange is the error resulting when a driver attempts to use
    // hardware capabilities which a connection does not support
    ErrServoOutOfRange = errors.New("servo angle must be between 0-180")
)
var StepperModes = struct {
    SinglePhaseStepping [][4]byte
    DualPhaseStepping   [][4]byte
    HalfStepping        [][4]byte
}{

    SinglePhaseStepping: [][4]byte{
        {1, 0, 0, 0},
        {0, 1, 0, 0},
        {0, 0, 1, 0},
        {0, 0, 0, 1},
    },

    DualPhaseStepping: [][4]byte{
        {1, 0, 0, 1},
        {1, 1, 0, 0},
        {0, 1, 1, 0},
        {0, 0, 1, 1},
    },

    HalfStepping: [][4]byte{
        {1, 0, 0, 1},
        {1, 0, 0, 0},
        {1, 1, 0, 0},
        {0, 1, 0, 0},
        {0, 1, 1, 0},
        {0, 0, 1, 0},
        {0, 0, 1, 1},
        {0, 0, 0, 1},
    },
}

StepperModes to decide on Phase and Stepping

func NewTM1638Fonts Uses

func NewTM1638Fonts() map[string]byte

NewTM1638Fonts returns a map with fonts and their corresponding byte for proper representation on the 7-segment LCD

type AIP1640Driver Uses

type AIP1640Driver struct {
    gobot.Commander
    // contains filtered or unexported fields
}

AIP1640Driver is the gobot driver for the AIP1640 LED driver used in the WEMOS D1 mini Matrix LED Shield. It has some similarities with the TM16xx LED drivers

Datasheet CN: https://datasheet.lcsc.com/szlcsc/AiP1640_C82650.pdf

Library ported from: https://github.com/wemos/WEMOS_Matrix_LED_Shield_Arduino_Library

func NewAIP1640Driver Uses

func NewAIP1640Driver(a gobot.Connection, clockPin string, dataPin string) *AIP1640Driver

NewAIP1640Driver return a new AIP1640Driver given a gobot.Connection and the clock, data and strobe pins

func (*AIP1640Driver) Clear Uses

func (a *AIP1640Driver) Clear()

Clear empties the buffer (turns off all the LEDs)

func (*AIP1640Driver) Connection Uses

func (a *AIP1640Driver) Connection() gobot.Connection

Connection returns the AIP1640Driver Connection

func (*AIP1640Driver) Display Uses

func (a *AIP1640Driver) Display()

Display sends the buffer to the display (ie. turns on/off the corresponding LEDs)

func (*AIP1640Driver) DrawMatrix Uses

func (a *AIP1640Driver) DrawMatrix(data [8]byte)

DrawMatrix sets the whole buffer

func (*AIP1640Driver) DrawPixel Uses

func (a *AIP1640Driver) DrawPixel(x, y byte, enabled bool)

DrawPixel turns on or off a specific in the buffer

func (*AIP1640Driver) DrawRow Uses

func (a *AIP1640Driver) DrawRow(row, data byte)

DrawRow sets any given row of LEDs in the buffer

func (*AIP1640Driver) Halt Uses

func (a *AIP1640Driver) Halt() (err error)

Halt implements the Driver interface

func (*AIP1640Driver) Name Uses

func (a *AIP1640Driver) Name() string

Name returns the AIP1640Drivers name

func (*AIP1640Driver) SetIntensity Uses

func (a *AIP1640Driver) SetIntensity(level byte)

SetIntensity changes the intensity (from 1 to 7) of the display

func (*AIP1640Driver) SetName Uses

func (a *AIP1640Driver) SetName(n string)

SetName sets the AIP1640Drivers name

func (*AIP1640Driver) Start Uses

func (a *AIP1640Driver) Start() (err error)

Start initializes the tm1638, it uses a SPI-like communication protocol

type ButtonDriver Uses

type ButtonDriver struct {
    Active       bool
    DefaultState int

    gobot.Eventer
    // contains filtered or unexported fields
}

ButtonDriver Represents a digital Button

func NewButtonDriver Uses

func NewButtonDriver(a DigitalReader, pin string, v ...time.Duration) *ButtonDriver

NewButtonDriver returns a new ButtonDriver with a polling interval of 10 Milliseconds given a DigitalReader and pin.

Optionally accepts:

time.Duration: Interval at which the ButtonDriver is polled for new information

func (*ButtonDriver) Connection Uses

func (b *ButtonDriver) Connection() gobot.Connection

Connection returns the ButtonDrivers Connection

func (*ButtonDriver) Halt Uses

func (b *ButtonDriver) Halt() (err error)

Halt stops polling the button for new information

func (*ButtonDriver) Name Uses

func (b *ButtonDriver) Name() string

Name returns the ButtonDrivers name

func (*ButtonDriver) Pin Uses

func (b *ButtonDriver) Pin() string

Pin returns the ButtonDrivers pin

func (*ButtonDriver) SetName Uses

func (b *ButtonDriver) SetName(n string)

SetName sets the ButtonDrivers name

func (*ButtonDriver) Start Uses

func (b *ButtonDriver) Start() (err error)

Start starts the ButtonDriver and polls the state of the button at the given interval.

Emits the Events:

Push int - On button push
Release int - On button release
Error error - On button error

type BuzzerDriver Uses

type BuzzerDriver struct {
    BPM float64
    // contains filtered or unexported fields
}

BuzzerDriver represents a digital buzzer

func NewBuzzerDriver Uses

func NewBuzzerDriver(a DigitalWriter, pin string) *BuzzerDriver

NewBuzzerDriver return a new BuzzerDriver given a DigitalWriter and pin.

func (*BuzzerDriver) Connection Uses

func (l *BuzzerDriver) Connection() gobot.Connection

Connection returns the BuzzerDrivers Connection

func (*BuzzerDriver) Halt Uses

func (l *BuzzerDriver) Halt() (err error)

Halt implements the Driver interface

func (*BuzzerDriver) Name Uses

func (l *BuzzerDriver) Name() string

Name returns the BuzzerDrivers name

func (*BuzzerDriver) Off Uses

func (l *BuzzerDriver) Off() (err error)

Off sets the buzzer to a low state.

func (*BuzzerDriver) On Uses

func (l *BuzzerDriver) On() (err error)

On sets the buzzer to a high state.

func (*BuzzerDriver) Pin Uses

func (l *BuzzerDriver) Pin() string

Pin returns the BuzzerDrivers name

func (*BuzzerDriver) SetName Uses

func (l *BuzzerDriver) SetName(n string)

SetName sets the BuzzerDrivers name

func (*BuzzerDriver) Start Uses

func (l *BuzzerDriver) Start() (err error)

Start implements the Driver interface

func (*BuzzerDriver) State Uses

func (l *BuzzerDriver) State() bool

State return true if the buzzer is On and false if the led is Off

func (*BuzzerDriver) Toggle Uses

func (l *BuzzerDriver) Toggle() (err error)

Toggle sets the buzzer to the opposite of it's current state

func (*BuzzerDriver) Tone Uses

func (l *BuzzerDriver) Tone(hz, duration float64) (err error)

type DigitalReader Uses

type DigitalReader interface {
    DigitalRead(string) (val int, err error)
}

DigitalReader interface represents an Adaptor which has DigitalRead capabilities

type DigitalWriter Uses

type DigitalWriter interface {
    DigitalWrite(string, byte) (err error)
}

DigitalWriter interface represents an Adaptor which has DigitalWrite capabilities

type DirectPinDriver Uses

type DirectPinDriver struct {
    gobot.Commander
    // contains filtered or unexported fields
}

DirectPinDriver represents a GPIO pin

func NewDirectPinDriver Uses

func NewDirectPinDriver(a gobot.Connection, pin string) *DirectPinDriver

NewDirectPinDriver return a new DirectPinDriver given a Connection and pin.

Adds the following API Commands:

"DigitalRead" - See DirectPinDriver.DigitalRead
"DigitalWrite" - See DirectPinDriver.DigitalWrite
"AnalogWrite" - See DirectPinDriver.AnalogWrite
"PwmWrite" - See DirectPinDriver.PwmWrite
"ServoWrite" - See DirectPinDriver.ServoWrite

func (*DirectPinDriver) Connection Uses

func (d *DirectPinDriver) Connection() gobot.Connection

Connection returns the DirectPinDrivers Connection

func (*DirectPinDriver) DigitalRead Uses

func (d *DirectPinDriver) DigitalRead() (val int, err error)

DigitalRead returns the current digital state of the pin

func (*DirectPinDriver) DigitalWrite Uses

func (d *DirectPinDriver) DigitalWrite(level byte) (err error)

DigitalWrite writes to the pin. Acceptable values are 1 or 0

func (*DirectPinDriver) Halt Uses

func (d *DirectPinDriver) Halt() (err error)

Halt implements the Driver interface

func (*DirectPinDriver) Name Uses

func (d *DirectPinDriver) Name() string

Name returns the DirectPinDrivers name

func (*DirectPinDriver) Off Uses

func (d *DirectPinDriver) Off() (err error)

Turn Off pin

func (*DirectPinDriver) On Uses

func (d *DirectPinDriver) On() (err error)

Turn On pin

func (*DirectPinDriver) Pin Uses

func (d *DirectPinDriver) Pin() string

Pin returns the DirectPinDrivers pin

func (*DirectPinDriver) PwmWrite Uses

func (d *DirectPinDriver) PwmWrite(level byte) (err error)

PwmWrite writes the 0-254 value to the specified pin

func (*DirectPinDriver) ServoWrite Uses

func (d *DirectPinDriver) ServoWrite(level byte) (err error)

ServoWrite writes value to the specified pin

func (*DirectPinDriver) SetName Uses

func (d *DirectPinDriver) SetName(n string)

SetName sets the DirectPinDrivers name

func (*DirectPinDriver) Start Uses

func (d *DirectPinDriver) Start() (err error)

Start implements the Driver interface

type GroveButtonDriver Uses

type GroveButtonDriver struct {
    *ButtonDriver
}

GroveButtonDriver represents a button sensor with a Grove connector

func NewGroveButtonDriver Uses

func NewGroveButtonDriver(a DigitalReader, pin string, v ...time.Duration) *GroveButtonDriver

NewGroveButtonDriver returns a new GroveButtonDriver with a polling interval of 10 Milliseconds given a DigitalReader and pin.

Optionally accepts:

time.Duration: Interval at which the ButtonDriver is polled for new information

type GroveBuzzerDriver Uses

type GroveBuzzerDriver struct {
    *BuzzerDriver
}

GroveBuzzerDriver represents a buzzer with a Grove connector

func NewGroveBuzzerDriver Uses

func NewGroveBuzzerDriver(a DigitalWriter, pin string) *GroveBuzzerDriver

NewGroveBuzzerDriver return a new GroveBuzzerDriver given a DigitalWriter and pin.

type GroveLedDriver Uses

type GroveLedDriver struct {
    *LedDriver
}

GroveLedDriver represents an LED with a Grove connector

func NewGroveLedDriver Uses

func NewGroveLedDriver(a DigitalWriter, pin string) *GroveLedDriver

NewGroveLedDriver return a new GroveLedDriver given a DigitalWriter and pin.

Adds the following API Commands:

"Brightness" - See LedDriver.Brightness
"Toggle" - See LedDriver.Toggle
"On" - See LedDriver.On
"Off" - See LedDriver.Off

type GroveMagneticSwitchDriver Uses

type GroveMagneticSwitchDriver struct {
    *ButtonDriver
}

GroveMagneticSwitchDriver represent a magnetic switch sensor with a Grove connector

func NewGroveMagneticSwitchDriver Uses

func NewGroveMagneticSwitchDriver(a DigitalReader, pin string, v ...time.Duration) *GroveMagneticSwitchDriver

NewGroveMagneticSwitchDriver returns a new GroveMagneticSwitchDriver with a polling interval of 10 Milliseconds given a DigitalReader, name and pin.

Optionally accepts:

time.Duration: Interval at which the ButtonDriver is polled for new information

type GroveRelayDriver Uses

type GroveRelayDriver struct {
    *RelayDriver
}

GroveRelayDriver represents a Relay with a Grove connector

func NewGroveRelayDriver Uses

func NewGroveRelayDriver(a DigitalWriter, pin string) *GroveRelayDriver

NewGroveRelayDriver return a new GroveRelayDriver given a DigitalWriter and pin.

Adds the following API Commands:

"Toggle" - See RelayDriver.Toggle
"On" - See RelayDriver.On
"Off" - See RelayDriver.Off

type GroveTouchDriver Uses

type GroveTouchDriver struct {
    *ButtonDriver
}

GroveTouchDriver represents a touch button sensor with a Grove connector

func NewGroveTouchDriver Uses

func NewGroveTouchDriver(a DigitalReader, pin string, v ...time.Duration) *GroveTouchDriver

NewGroveTouchDriver returns a new GroveTouchDriver with a polling interval of 10 Milliseconds given a DigitalReader and pin.

Optionally accepts:

time.Duration: Interval at which the ButtonDriver is polled for new information

type LedDriver Uses

type LedDriver struct {
    gobot.Commander
    // contains filtered or unexported fields
}

LedDriver represents a digital Led

func NewLedDriver Uses

func NewLedDriver(a DigitalWriter, pin string) *LedDriver

NewLedDriver return a new LedDriver given a DigitalWriter 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 Uses

func (l *LedDriver) Brightness(level byte) (err error)

Brightness sets the led to the specified level of brightness

func (*LedDriver) Connection Uses

func (l *LedDriver) Connection() gobot.Connection

Connection returns the LedDrivers Connection

func (*LedDriver) Halt Uses

func (l *LedDriver) Halt() (err error)

Halt implements the Driver interface

func (*LedDriver) Name Uses

func (l *LedDriver) Name() string

Name returns the LedDrivers name

func (*LedDriver) Off Uses

func (l *LedDriver) Off() (err error)

Off sets the led to a low state.

func (*LedDriver) On Uses

func (l *LedDriver) On() (err error)

On sets the led to a high state.

func (*LedDriver) Pin Uses

func (l *LedDriver) Pin() string

Pin returns the LedDrivers name

func (*LedDriver) SetName Uses

func (l *LedDriver) SetName(n string)

SetName sets the LedDrivers name

func (*LedDriver) Start Uses

func (l *LedDriver) Start() (err error)

Start implements the Driver interface

func (*LedDriver) State Uses

func (l *LedDriver) State() bool

State return true if the led is On and false if the led is Off

func (*LedDriver) Toggle Uses

func (l *LedDriver) Toggle() (err error)

Toggle sets the led to the opposite of it's current state

type MAX7219Driver Uses

type MAX7219Driver struct {
    gobot.Commander
    // contains filtered or unexported fields
}

MAX7219Driver is the gobot driver for the MAX7219 LED driver

Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX7219-MAX7221.pdf

func NewMAX7219Driver Uses

func NewMAX7219Driver(a gobot.Connection, clockPin string, dataPin string, csPin string, count uint) *MAX7219Driver

NewMAX7219Driver return a new MAX7219Driver given a gobot.Connection, pins and how many chips are chained

func (*MAX7219Driver) All Uses

func (a *MAX7219Driver) All(address byte, data byte)

All sends the same data to all the modules

func (*MAX7219Driver) ClearAll Uses

func (a *MAX7219Driver) ClearAll()

ClearAll turns off all LEDs of all modules

func (*MAX7219Driver) ClearOne Uses

func (a *MAX7219Driver) ClearOne(which uint)

ClearAll turns off all LEDs of the given module

func (*MAX7219Driver) Connection Uses

func (a *MAX7219Driver) Connection() gobot.Connection

Connection returns the MAX7219Driver Connection

func (*MAX7219Driver) Halt Uses

func (a *MAX7219Driver) Halt() (err error)

Halt implements the Driver interface

func (*MAX7219Driver) Name Uses

func (a *MAX7219Driver) Name() string

Name returns the MAX7219Drivers name

func (*MAX7219Driver) One Uses

func (a *MAX7219Driver) One(which uint, address byte, data byte)

One sends data to a specific module

func (*MAX7219Driver) SetIntensity Uses

func (a *MAX7219Driver) SetIntensity(level byte)

SetIntensity changes the intensity (from 1 to 7) of the display

func (*MAX7219Driver) SetName Uses

func (a *MAX7219Driver) SetName(n string)

SetName sets the MAX7219Drivers name

func (*MAX7219Driver) Start Uses

func (a *MAX7219Driver) Start() (err error)

Start initializes the max7219, it uses a SPI-like communication protocol

type MakeyButtonDriver Uses

type MakeyButtonDriver struct {
    Active bool

    gobot.Eventer
    // contains filtered or unexported fields
}

MakeyButtonDriver Represents a Makey Button

func NewMakeyButtonDriver Uses

func NewMakeyButtonDriver(a DigitalReader, pin string, v ...time.Duration) *MakeyButtonDriver

NewMakeyButtonDriver returns a new MakeyButtonDriver with a polling interval of 10 Milliseconds given a DigitalReader and pin.

Optionally accepts:

time.Duration: Interval at which the ButtonDriver is polled for new information

func (*MakeyButtonDriver) Connection Uses

func (b *MakeyButtonDriver) Connection() gobot.Connection

Connection returns the MakeyButtonDrivers Connection

func (*MakeyButtonDriver) Halt Uses

func (b *MakeyButtonDriver) Halt() (err error)

Halt stops polling the makey button for new information

func (*MakeyButtonDriver) Name Uses

func (b *MakeyButtonDriver) Name() string

Name returns the MakeyButtonDrivers name

func (*MakeyButtonDriver) Pin Uses

func (b *MakeyButtonDriver) Pin() string

Pin returns the MakeyButtonDrivers pin

func (*MakeyButtonDriver) SetName Uses

func (b *MakeyButtonDriver) SetName(n string)

SetName sets the MakeyButtonDrivers name

func (*MakeyButtonDriver) Start Uses

func (b *MakeyButtonDriver) Start() (err error)

Start starts the MakeyButtonDriver and polls the state of the button at the given interval.

Emits the Events:

Push int - On button push
Release int - On button release
Error error - On button error

type MotorDriver Uses

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
}

MotorDriver Represents a Motor

func NewMotorDriver Uses

func NewMotorDriver(a DigitalWriter, speedPin string) *MotorDriver

NewMotorDriver return a new MotorDriver given a DigitalWriter and pin

func (*MotorDriver) Backward Uses

func (m *MotorDriver) Backward(speed byte) (err error)

Backward sets the backward pin to the specified speed

func (*MotorDriver) Connection Uses

func (m *MotorDriver) Connection() gobot.Connection

Connection returns the MotorDrivers Connection

func (*MotorDriver) Direction Uses

func (m *MotorDriver) Direction(direction string) (err error)

Direction sets the direction pin to the specified speed

func (*MotorDriver) Forward Uses

func (m *MotorDriver) Forward(speed byte) (err error)

Forward sets the forward pin to the specified speed

func (*MotorDriver) Halt Uses

func (m *MotorDriver) Halt() (err error)

Halt implements the Driver interface

func (*MotorDriver) IsOff Uses

func (m *MotorDriver) IsOff() bool

IsOff returns true if the motor is off

func (*MotorDriver) IsOn Uses

func (m *MotorDriver) IsOn() bool

IsOn returns true if the motor is on

func (*MotorDriver) Max Uses

func (m *MotorDriver) Max() (err error)

Max sets the motor to the maximum speed

func (*MotorDriver) Min Uses

func (m *MotorDriver) Min() (err error)

Min sets the motor to the minimum speed

func (*MotorDriver) Name Uses

func (m *MotorDriver) Name() string

Name returns the MotorDrivers name

func (*MotorDriver) Off Uses

func (m *MotorDriver) Off() (err error)

Off turns the motor off or sets the motor to a 0 speed

func (*MotorDriver) On Uses

func (m *MotorDriver) On() (err error)

On turns the motor on or sets the motor to a maximum speed

func (*MotorDriver) SetName Uses

func (m *MotorDriver) SetName(n string)

SetName sets the MotorDrivers name

func (*MotorDriver) Speed Uses

func (m *MotorDriver) Speed(value byte) (err error)

Speed sets the speed of the motor

func (*MotorDriver) Start Uses

func (m *MotorDriver) Start() (err error)

Start implements the Driver interface

func (*MotorDriver) Toggle Uses

func (m *MotorDriver) Toggle() (err error)

Toggle sets the motor to the opposite of it's current state

type PIRMotionDriver Uses

type PIRMotionDriver struct {
    Active bool

    gobot.Eventer
    // contains filtered or unexported fields
}

PIRMotionDriver represents a digital Proximity Infra Red (PIR) motion detecter

func NewPIRMotionDriver Uses

func NewPIRMotionDriver(a DigitalReader, pin string, v ...time.Duration) *PIRMotionDriver

NewPIRMotionDriver returns a new PIRMotionDriver with a polling interval of 10 Milliseconds given a DigitalReader and pin.

Optionally accepts:

time.Duration: Interval at which the PIRMotionDriver is polled for new information

func (*PIRMotionDriver) Connection Uses

func (p *PIRMotionDriver) Connection() gobot.Connection

Connection returns the PIRMotionDriver Connection

func (*PIRMotionDriver) Halt Uses

func (p *PIRMotionDriver) Halt() (err error)

Halt stops polling the button for new information

func (*PIRMotionDriver) Name Uses

func (p *PIRMotionDriver) Name() string

Name returns the PIRMotionDriver name

func (*PIRMotionDriver) Pin Uses

func (p *PIRMotionDriver) Pin() string

Pin returns the PIRMotionDriver pin

func (*PIRMotionDriver) SetName Uses

func (p *PIRMotionDriver) SetName(n string)

SetName sets the PIRMotionDriver name

func (*PIRMotionDriver) Start Uses

func (p *PIRMotionDriver) Start() (err error)

Start starts the PIRMotionDriver and polls the state of the sensor at the given interval.

Emits the Events:

MotionDetected - On motion detected
MotionStopped int - On motion stopped
Error error - On button error

The PIRMotionDriver will send the MotionDetected event over and over, just as long as motion is still being detected. It will only send the MotionStopped event once, however, until motion starts being detected again

type PwmWriter Uses

type PwmWriter interface {
    PwmWrite(string, byte) (err error)
}

PwmWriter interface represents an Adaptor which has Pwm capabilities

type RelayDriver Uses

type RelayDriver struct {
    gobot.Commander
    // contains filtered or unexported fields
}

RelayDriver represents a digital relay

func NewRelayDriver Uses

func NewRelayDriver(a DigitalWriter, pin string) *RelayDriver

NewRelayDriver return a new RelayDriver given a DigitalWriter and pin.

Adds the following API Commands:

"Toggle" - See RelayDriver.Toggle
"On" - See RelayDriver.On
"Off" - See RelayDriver.Off

func (*RelayDriver) Connection Uses

func (l *RelayDriver) Connection() gobot.Connection

Connection returns the RelayDrivers Connection

func (*RelayDriver) Halt Uses

func (l *RelayDriver) Halt() (err error)

Halt implements the Driver interface

func (*RelayDriver) Name Uses

func (l *RelayDriver) Name() string

Name returns the RelayDrivers name

func (*RelayDriver) Off Uses

func (l *RelayDriver) Off() (err error)

Off sets the relay to a low state.

func (*RelayDriver) On Uses

func (l *RelayDriver) On() (err error)

On sets the relay to a high state.

func (*RelayDriver) Pin Uses

func (l *RelayDriver) Pin() string

Pin returns the RelayDrivers name

func (*RelayDriver) SetName Uses

func (l *RelayDriver) SetName(n string)

SetName sets the RelayDrivers name

func (*RelayDriver) Start Uses

func (l *RelayDriver) Start() (err error)

Start implements the Driver interface

func (*RelayDriver) State Uses

func (l *RelayDriver) State() bool

State return true if the relay is On and false if the relay is Off

func (*RelayDriver) Toggle Uses

func (l *RelayDriver) Toggle() (err error)

Toggle sets the relay to the opposite of it's current state

type RgbLedDriver Uses

type RgbLedDriver struct {
    gobot.Commander
    // contains filtered or unexported fields
}

RgbLedDriver represents a digital RGB Led

func NewRgbLedDriver Uses

func NewRgbLedDriver(a DigitalWriter, redPin string, greenPin string, bluePin string) *RgbLedDriver

NewRgbLedDriver return a new RgbLedDriver given a DigitalWriter and 3 pins: redPin, greenPin, and bluePin

Adds the following API Commands:

"SetRGB" - See RgbLedDriver.SetRGB
"Toggle" - See RgbLedDriver.Toggle
"On" - See RgbLedDriver.On
"Off" - See RgbLedDriver.Off

func (*RgbLedDriver) BluePin Uses

func (l *RgbLedDriver) BluePin() string

BluePin returns the RgbLedDrivers bluePin

func (*RgbLedDriver) Connection Uses

func (l *RgbLedDriver) Connection() gobot.Connection

Connection returns the RgbLedDriver Connection

func (*RgbLedDriver) GreenPin Uses

func (l *RgbLedDriver) GreenPin() string

GreenPin returns the RgbLedDrivers redPin

func (*RgbLedDriver) Halt Uses

func (l *RgbLedDriver) Halt() (err error)

Halt implements the Driver interface

func (*RgbLedDriver) Name Uses

func (l *RgbLedDriver) Name() string

Name returns the RGBLEDDrivers name

func (*RgbLedDriver) Off Uses

func (l *RgbLedDriver) Off() (err error)

Off sets the led to black.

func (*RgbLedDriver) On Uses

func (l *RgbLedDriver) On() (err error)

On sets the led's pins to their various states

func (*RgbLedDriver) Pin Uses

func (l *RgbLedDriver) Pin() string

Pin returns the RgbLedDrivers pins

func (*RgbLedDriver) RedPin Uses

func (l *RgbLedDriver) RedPin() string

RedPin returns the RgbLedDrivers redPin

func (*RgbLedDriver) SetLevel Uses

func (l *RgbLedDriver) SetLevel(pin string, level byte) (err error)

SetLevel sets the led to the specified color level

func (*RgbLedDriver) SetName Uses

func (l *RgbLedDriver) SetName(n string)

SetName sets the RGBLEDDrivers name

func (*RgbLedDriver) SetRGB Uses

func (l *RgbLedDriver) SetRGB(r, g, b byte) error

SetRGB sets the Red Green Blue value of the LED.

func (*RgbLedDriver) Start Uses

func (l *RgbLedDriver) Start() (err error)

Start implements the Driver interface

func (*RgbLedDriver) State Uses

func (l *RgbLedDriver) State() bool

State return true if the led is On and false if the led is Off

func (*RgbLedDriver) Toggle Uses

func (l *RgbLedDriver) Toggle() (err error)

Toggle sets the led to the opposite of it's current state

type ServoDriver Uses

type ServoDriver struct {
    gobot.Commander
    CurrentAngle byte
    // contains filtered or unexported fields
}

ServoDriver Represents a Servo

func NewServoDriver Uses

func NewServoDriver(a ServoWriter, pin string) *ServoDriver

NewServoDriver returns a new ServoDriver given a ServoWriter 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 Uses

func (s *ServoDriver) Center() (err error)

Center sets the servo to it's center position

func (*ServoDriver) Connection Uses

func (s *ServoDriver) Connection() gobot.Connection

Connection returns the ServoDrivers connection

func (*ServoDriver) Halt Uses

func (s *ServoDriver) Halt() (err error)

Halt implements the Driver interface

func (*ServoDriver) Max Uses

func (s *ServoDriver) Max() (err error)

Max sets the servo to its maximum position

func (*ServoDriver) Min Uses

func (s *ServoDriver) Min() (err error)

Min sets the servo to it's minimum position

func (*ServoDriver) Move Uses

func (s *ServoDriver) Move(angle uint8) (err error)

Move sets the servo to the specified angle. Acceptable angles are 0-180

func (*ServoDriver) Name Uses

func (s *ServoDriver) Name() string

Name returns the ServoDrivers name

func (*ServoDriver) Pin Uses

func (s *ServoDriver) Pin() string

Pin returns the ServoDrivers pin

func (*ServoDriver) SetName Uses

func (s *ServoDriver) SetName(n string)

SetName sets the ServoDrivers name

func (*ServoDriver) Start Uses

func (s *ServoDriver) Start() (err error)

Start implements the Driver interface

type ServoWriter Uses

type ServoWriter interface {
    ServoWrite(string, byte) (err error)
}

ServoWriter interface represents an Adaptor which has Servo capabilities

type StepperDriver Uses

type StepperDriver struct {
    gobot.Commander
    // contains filtered or unexported fields
}

StepperDriver object

func NewStepperDriver Uses

func NewStepperDriver(a DigitalWriter, pins [4]string, phase phase, stepsPerRev uint) *StepperDriver

NewStepperDriver returns a new StepperDriver given a DigitalWriter Pins - To which the stepper is connected Phase - Defined by StepperModes {SinglePhaseStepping, DualPhaseStepping, HalfStepping} Steps - No of steps per revolution of Stepper motor

func (*StepperDriver) Connection Uses

func (s *StepperDriver) Connection() gobot.Connection

Connection returns StepperDriver's connection

func (*StepperDriver) GetCurrentStep Uses

func (s *StepperDriver) GetCurrentStep() int

GetCurrentStep gives the current step of motor

func (*StepperDriver) GetMaxSpeed Uses

func (s *StepperDriver) GetMaxSpeed() uint

GetMaxSpeed gives the max RPM of motor

func (*StepperDriver) Halt Uses

func (s *StepperDriver) Halt() (err error)

Halt implements the Driver interface and halts the motion of the Stepper

func (*StepperDriver) IsMoving Uses

func (s *StepperDriver) IsMoving() bool

IsMoving returns a bool stating whether motor is currently in motion

func (*StepperDriver) Move Uses

func (s *StepperDriver) Move(stepsToMove int) error

Move moves the motor for given number of steps

func (*StepperDriver) Name Uses

func (s *StepperDriver) Name() string

Name of StepperDriver

func (*StepperDriver) Run Uses

func (s *StepperDriver) Run() (err error)

Run continuously runs the stepper

func (*StepperDriver) SetDirection Uses

func (s *StepperDriver) SetDirection(direction string) error

SetDirection sets the direction in which motor should be moving, Default is forward

func (*StepperDriver) SetName Uses

func (s *StepperDriver) SetName(n string)

SetName sets name for StepperDriver

func (*StepperDriver) SetSpeed Uses

func (s *StepperDriver) SetSpeed(rpm uint) error

SetSpeed sets the rpm

func (*StepperDriver) Start Uses

func (s *StepperDriver) Start() (err error)

Start implements the Driver interface and keeps running the stepper till halt is called

type TM1638Driver Uses

type TM1638Driver struct {
    gobot.Commander
    // contains filtered or unexported fields
}

func NewTM1638Driver Uses

func NewTM1638Driver(a gobot.Connection, clockPin string, dataPin string, strobePin string) *TM1638Driver

NewTM1638Driver return a new TM1638Driver given a gobot.Connection and the clock, data and strobe pins

func (*TM1638Driver) AddFonts Uses

func (t *TM1638Driver) AddFonts(fonts map[string]byte)

AddFonts adds new custom fonts or modify the representation of existing ones

func (*TM1638Driver) ClearFonts Uses

func (t *TM1638Driver) ClearFonts()

ClearFonts removes all the fonts from the driver

func (*TM1638Driver) Connection Uses

func (t *TM1638Driver) Connection() gobot.Connection

Connection returns the TM1638Driver Connection

func (*TM1638Driver) Halt Uses

func (t *TM1638Driver) Halt() (err error)

Halt implements the Driver interface

func (*TM1638Driver) Name Uses

func (t *TM1638Driver) Name() string

Name returns the TM1638Drivers name

func (*TM1638Driver) SendChar Uses

func (t *TM1638Driver) SendChar(pos byte, data byte, dot bool)

SendChar sends one byte to the specific position in the display

func (*TM1638Driver) SetDisplay Uses

func (t *TM1638Driver) SetDisplay(data []byte)

SetDisplay cuts and sends a byte array to the display (without dots)

func (*TM1638Driver) SetDisplayText Uses

func (t *TM1638Driver) SetDisplayText(text string)

SetDisplayText cuts and sends a string to the display (without dots)

func (*TM1638Driver) SetLED Uses

func (t *TM1638Driver) SetLED(color byte, pos byte)

SetLED changes the color (TM1638None, TM1638Red, TM1638Green) of the specific LED

func (*TM1638Driver) SetName Uses

func (t *TM1638Driver) SetName(n string)

SetName sets the TM1638Drivers name

func (*TM1638Driver) Start Uses

func (t *TM1638Driver) Start() (err error)

Start initializes the tm1638, it uses a SPI-like communication protocol

Package gpio imports 7 packages (graph) and is imported by 9 packages. Updated 2018-06-01. Refresh now. Tools for package owners.