Documentation ¶
Overview ¶
Package client provies a client for interacting with microcontrollers using the Firmata protocol https://github.com/firmata/protocol.
Index ¶
- Constants
- Variables
- type Client
- func (b *Client) AnalogMappingQuery() error
- func (b *Client) AnalogWrite(pin int, value int) error
- func (b *Client) CapabilitiesQuery() error
- func (b *Client) Connect(conn io.ReadWriteCloser) (err error)
- func (b *Client) Connected() bool
- func (b *Client) DigitalWrite(pin int, value int) error
- func (b *Client) Disconnect() (err error)
- func (b *Client) FirmwareQuery() error
- func (b *Client) I2cConfig(delay int) error
- func (b *Client) I2cRead(address int, numBytes int) error
- func (b *Client) I2cWrite(address int, data []byte) error
- func (b *Client) PinStateQuery(pin int) error
- func (b *Client) Pins() []Pin
- func (b *Client) ProtocolVersionQuery() error
- func (b *Client) ReportAnalog(pin int, state int) error
- func (b *Client) ReportDigital(pin int, state int) error
- func (b *Client) Reset() error
- func (b *Client) ServoConfig(pin int, max int, min int) error
- func (b *Client) SetPinMode(pin int, mode int) error
- type I2cReply
- type Pin
Constants ¶
const ( Input = 0x00 Output = 0x01 Analog = 0x02 Pwm = 0x03 Servo = 0x04 )
Pin Modes
const ( ProtocolVersion byte = 0xF9 SystemReset byte = 0xFF DigitalMessage byte = 0x90 DigitalMessageRangeStart byte = 0x90 DigitalMessageRangeEnd byte = 0x9F AnalogMessage byte = 0xE0 AnalogMessageRangeStart byte = 0xE0 AnalogMessageRangeEnd byte = 0xEF ReportAnalog byte = 0xC0 ReportDigital byte = 0xD0 PinMode byte = 0xF4 StartSysex byte = 0xF0 EndSysex byte = 0xF7 CapabilityQuery byte = 0x6B CapabilityResponse byte = 0x6C PinStateQuery byte = 0x6D PinStateResponse byte = 0x6E AnalogMappingQuery byte = 0x69 AnalogMappingResponse byte = 0x6A StringData byte = 0x71 I2CRequest byte = 0x76 I2CReply byte = 0x77 I2CConfig byte = 0x78 FirmwareQuery byte = 0x79 I2CModeWrite byte = 0x00 I2CModeRead byte = 0x01 I2CModeContinuousRead byte = 0x02 I2CModeStopReading byte = 0x03 ServoConfig byte = 0x70 )
Sysex Codes
Variables ¶
var (
ErrConnected = errors.New("client is already connected")
)
Errors
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { FirmwareName string ProtocolVersion string gobot.Eventer // contains filtered or unexported fields }
Client represents a client connection to a firmata board
func (*Client) AnalogMappingQuery ¶
AnalogMappingQuery sends the AnalogMappingQuery sysex code.
func (*Client) AnalogWrite ¶
AnalogWrite writes value to pin.
func (*Client) CapabilitiesQuery ¶
CapabilitiesQuery sends the CapabilityQuery sysex code.
func (*Client) Connect ¶
func (b *Client) Connect(conn io.ReadWriteCloser) (err error)
Connect connects to the Client given conn. It first resets the firmata board then continuously polls the firmata board for new information when it's available.
func (*Client) DigitalWrite ¶
DigitalWrite writes value to pin.
func (*Client) Disconnect ¶
Disconnect disconnects the Client
func (*Client) FirmwareQuery ¶
FirmwareQuery sends the FirmwareQuery sysex code.
func (*Client) I2cConfig ¶
I2cConfig configures the delay in which a register can be read from after it has been written to.
func (*Client) PinStateQuery ¶
PinStateQuery sends a PinStateQuery for pin.
func (*Client) ProtocolVersionQuery ¶
ProtocolVersionQuery sends the ProtocolVersion sysex code.
func (*Client) ReportAnalog ¶
ReportAnalog enables or disables analog reporting for pin, a non zero state enables reporting
func (*Client) ReportDigital ¶
ReportDigital enables or disables digital reporting for pin, a non zero state enables reporting
func (*Client) ServoConfig ¶
ServoConfig sets the min and max pulse width for servo PWM range