Documentation ¶
Overview ¶
Package firmata provides the Gobot adaptor for microcontrollers that support the Firmata protocol.
Installing:
go get -d -u gobot.io/x/gobot/v2/... && go get gobot.io/x/gobot/v2/platforms/firmata
Example:
package main import ( "time" "gobot.io/x/gobot/v2" "gobot.io/x/gobot/v2/drivers/gpio" "gobot.io/x/gobot/v2/platforms/firmata" ) func main() { firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0") led := gpio.NewLedDriver(firmataAdaptor, "13") work := func() { gobot.Every(1*time.Second, func() { led.Toggle() }) } robot := gobot.NewRobot("bot", []gobot.Connection{firmataAdaptor}, []gobot.Device{led}, work, ) robot.Start() }
For further information refer to firmata readme: https://github.com/hybridgroup/gobot/blob/master/platforms/firmata/README.md
Index ¶
- Constants
- func NewFirmataI2cConnection(adaptor *Adaptor, address int) (connection *firmataI2cConnection)
- type Adaptor
- func (f *Adaptor) AnalogRead(pin string) (val int, err error)
- func (f *Adaptor) Connect() (err error)
- func (f *Adaptor) DefaultI2cBus() int
- func (f *Adaptor) DigitalRead(pin string) (val int, err error)
- func (f *Adaptor) DigitalWrite(pin string, level byte) (err error)
- func (f *Adaptor) Disconnect() (err error)
- func (f *Adaptor) Finalize() (err error)
- func (f *Adaptor) GetI2cConnection(address int, bus int) (connection i2c.Connection, err error)
- func (f *Adaptor) Name() string
- func (f *Adaptor) Port() string
- func (f *Adaptor) PwmWrite(pin string, level byte) (err error)
- func (f *Adaptor) ServoConfig(pin string, min, max int) error
- func (f *Adaptor) ServoWrite(pin string, angle byte) (err error)
- func (f *Adaptor) SetName(n string)
- func (f *Adaptor) WriteSysex(data []byte) error
- type BLEAdaptor
- type FirmataAdaptor
- type TCPAdaptor
Constants ¶
const ( // ReceiveID is the BLE characteristic ID for receiving serial data ReceiveID = "6e400003b5a3f393e0a9e50e24dcca9e" // TransmitID is the BLE characteristic ID for transmitting serial data TransmitID = "6e400002b5a3f393e0a9e50e24dcca9e" )
Variables ¶
This section is empty.
Functions ¶
func NewFirmataI2cConnection ¶ added in v1.2.0
NewFirmataI2cConnection creates an I2C connection to an I2C device at the specified address
Types ¶
type Adaptor ¶ added in v1.0.0
type Adaptor struct { Board firmataBoard PortOpener func(port string) (io.ReadWriteCloser, error) gobot.Eventer // contains filtered or unexported fields }
Adaptor is the Gobot Adaptor for Firmata based boards
func NewAdaptor ¶ added in v1.0.0
func NewAdaptor(args ...interface{}) *Adaptor
NewAdaptor returns a new Firmata Adaptor which optionally accepts:
string: port the Adaptor uses to connect to a serial port with a baude rate of 57600 io.ReadWriteCloser: connection the Adaptor uses to communication with the hardware
If an io.ReadWriteCloser is not supplied, the Adaptor will open a connection to a serial port with a baude rate of 57600. If an io.ReadWriteCloser is supplied, then the Adaptor will use the provided io.ReadWriteCloser and use the string port as a label to be displayed in the log and api.
func (*Adaptor) AnalogRead ¶ added in v1.0.0
AnalogRead retrieves value from analog pin. Returns -1 if the response from the board has timed out
func (*Adaptor) DefaultI2cBus ¶
DefaultI2cBus returns the default i2c bus for this platform
func (*Adaptor) DigitalRead ¶ added in v1.0.0
DigitalRead retrieves digital value from specified pin. Returns -1 if the response from the board has timed out
func (*Adaptor) DigitalWrite ¶ added in v1.0.0
DigitalWrite writes a value to the pin. Acceptable values are 1 or 0.
func (*Adaptor) Disconnect ¶ added in v1.0.0
Disconnect closes the io connection to the Board
func (*Adaptor) GetI2cConnection ¶
GetI2cConnection returns an i2c connection to a device on a specified bus. Only supports bus number 0
func (*Adaptor) ServoConfig ¶ added in v1.0.0
ServoConfig sets the pulse width in microseconds for a pin attached to a servo
func (*Adaptor) ServoWrite ¶ added in v1.0.0
ServoWrite writes the 0-180 degree angle to the specified pin.
func (*Adaptor) WriteSysex ¶ added in v1.6.0
type BLEAdaptor ¶ added in v1.2.0
type BLEAdaptor struct {
*Adaptor
}
BLEAdaptor represents a Bluetooth LE based connection to a microcontroller running FirmataBLE
func NewBLEAdaptor ¶ added in v1.2.0
func NewBLEAdaptor(args ...interface{}) *BLEAdaptor
NewBLEAdaptor opens and uses a BLE connection to a microcontroller running FirmataBLE
type FirmataAdaptor ¶
type TCPAdaptor ¶ added in v1.1.0
type TCPAdaptor struct {
*Adaptor
}
TCPAdaptor represents a TCP based connection to a microcontroller running WiFiFirmata
func NewTCPAdaptor ¶ added in v1.1.0
func NewTCPAdaptor(args ...interface{}) *TCPAdaptor
NewTCPAdaptor opens and uses a TCP connection to a microcontroller running WiFiFirmata
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package client provies a client for interacting with microcontrollers using the Firmata protocol https://github.com/firmata/protocol.
|
Package client provies a client for interacting with microcontrollers using the Firmata protocol https://github.com/firmata/protocol. |