gobot: gobot.io/x/gobot/platforms/firmata Index | Files | Directories

package firmata

import "gobot.io/x/gobot/platforms/firmata"

Package firmata provides the Gobot adaptor for microcontrollers that support the Firmata protocol.

Installing:

go get -d -u gobot.io/x/gobot/... && go get gobot.io/x/gobot/platforms/firmata

Example:

package main

import (
	"time"

	"gobot.io/x/gobot"
	"gobot.io/x/gobot/drivers/gpio"
	"gobot.io/x/gobot/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

Package Files

ble_firmata_adaptor.go doc.go firmata_adaptor.go firmata_i2c.go tcp_firmata_adaptor.go

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"
)

func NewFirmataI2cConnection Uses

func NewFirmataI2cConnection(adaptor *Adaptor, address int) (connection *firmataI2cConnection)

NewFirmataI2cConnection creates an I2C connection to an I2C device at the specified address

type Adaptor Uses

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 Uses

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 Uses

func (f *Adaptor) AnalogRead(pin string) (val int, err error)

AnalogRead retrieves value from analog pin. Returns -1 if the response from the board has timed out

func (*Adaptor) Connect Uses

func (f *Adaptor) Connect() (err error)

Connect starts a connection to the board.

func (*Adaptor) DigitalRead Uses

func (f *Adaptor) DigitalRead(pin string) (val int, err error)

DigitalRead retrieves digital value from specified pin. Returns -1 if the response from the board has timed out

func (*Adaptor) DigitalWrite Uses

func (f *Adaptor) DigitalWrite(pin string, level byte) (err error)

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

func (*Adaptor) Disconnect Uses

func (f *Adaptor) Disconnect() (err error)

Disconnect closes the io connection to the Board

func (*Adaptor) Finalize Uses

func (f *Adaptor) Finalize() (err error)

Finalize terminates the firmata connection

func (*Adaptor) GetConnection Uses

func (f *Adaptor) GetConnection(address int, bus int) (connection i2c.Connection, err error)

GetConnection returns an i2c connection to a device on a specified bus. Only supports bus number 0

func (*Adaptor) GetDefaultBus Uses

func (f *Adaptor) GetDefaultBus() int

GetDefaultBus returns the default i2c bus for this platform

func (*Adaptor) Name Uses

func (f *Adaptor) Name() string

Name returns the Firmata Adaptors name

func (*Adaptor) Port Uses

func (f *Adaptor) Port() string

Port returns the Firmata Adaptors port

func (*Adaptor) PwmWrite Uses

func (f *Adaptor) PwmWrite(pin string, level byte) (err error)

PwmWrite writes the 0-254 value to the specified pin

func (*Adaptor) ServoConfig Uses

func (f *Adaptor) ServoConfig(pin string, min, max int) error

ServoConfig sets the pulse width in microseconds for a pin attached to a servo

func (*Adaptor) ServoWrite Uses

func (f *Adaptor) ServoWrite(pin string, angle byte) (err error)

ServoWrite writes the 0-180 degree angle to the specified pin.

func (*Adaptor) SetName Uses

func (f *Adaptor) SetName(n string)

SetName sets the Firmata Adaptors name

func (*Adaptor) WriteSysex Uses

func (f *Adaptor) WriteSysex(data []byte) error

type BLEAdaptor Uses

type BLEAdaptor struct {
    *Adaptor
}

BLEAdaptor represents a Bluetooth LE based connection to a microcontroller running FirmataBLE

func NewBLEAdaptor Uses

func NewBLEAdaptor(args ...interface{}) *BLEAdaptor

NewBLEAdaptor opens and uses a BLE connection to a microcontroller running FirmataBLE

type FirmataAdaptor Uses

type FirmataAdaptor interface {
    Connect() (err error)
    Finalize() (err error)
    Name() string
    SetName(n string)
    WriteSysex(data []byte) error
    gobot.Eventer
}

type TCPAdaptor Uses

type TCPAdaptor struct {
    *Adaptor
}

TCPAdaptor represents a TCP based connection to a microcontroller running WiFiFirmata

func NewTCPAdaptor Uses

func NewTCPAdaptor(args ...interface{}) *TCPAdaptor

NewTCPAdaptor opens and uses a TCP connection to a microcontroller running WiFiFirmata

Directories

PathSynopsis
clientPackage client provies a client for interacting with microcontrollers using the Firmata protocol https://github.com/firmata/protocol.

Package firmata imports 10 packages (graph) and is imported by 6 packages. Updated 2019-05-04. Refresh now. Tools for package owners.