Documentation
¶
Index ¶
- Constants
- type Client
- func (c *Client) AnalogWrite(pin uint, pinData byte) error
- func (c *Client) Close() error
- func (c *Client) DigitalWrite(pin uint8, val bool) error
- func (c *Client) EnableAnalogInput(pin uint, val bool) error
- func (c *Client) EnableDigitalInput(pin uint, val bool) error
- func (c *Client) SPIConfig(csPin byte, spiMode byte) (err error)
- func (c *Client) SPIReadWrite(csPin byte, data []byte) (dataOut []byte, err error)
- func (c *Client) SerialConfig(port SerialPort, baud int, txPin byte, rxPin byte) (err error)
- func (c *Client) SerialData() <-chan string
- func (c *Client) SetAnalogSamplingInterval(ms byte) error
- func (c *Client) SetPinMode(pin uint8, mode PinMode) error
- func (c *Client) Values() <-chan FirmataValue
- type FirmataCommand
- type FirmataValue
- type PinMode
- type SPISubCommand
- type SerialPort
- type SerialSubCommand
- type SysExCommand
Constants ¶
const ( ProtocolMajorVersion = 2 ProtocolMinorVersion = 3 // max number of data bytes in non-Sysex messages MaxDataBytes = 32 DigitalMessage FirmataCommand = 0x90 // send data for a digital pin AnalogMessage FirmataCommand = 0xE0 // send data for an analog pin (or PWM) EnableAnalogInput FirmataCommand = 0xC0 // enable analog input by pin # EnableDigitalInput FirmataCommand = 0xD0 // enable digital input by port pair SetPinMode FirmataCommand = 0xF4 // set a pin to INPUT/OUTPUT/PWM/etc ReportVersion FirmataCommand = 0xF9 // report protocol version SystemReset FirmataCommand = 0xFF // reset from MIDI StartSysEx FirmataCommand = 0xF0 // start a MIDI Sysex message EndSysEx FirmataCommand = 0xF7 // end a MIDI Sysex message // extended command set using sysex (0-127/0x00-0x7F) /* 0x00-0x0F reserved for user-defined commands */ ServoConfig SysExCommand = 0x70 // set max angle, minPulse, maxPulse, freq StringData SysExCommand = 0x71 // a string message with 14-bits per char ShiftData SysExCommand = 0x75 // a bitstream to/from a shift register I2CRequest SysExCommand = 0x76 // send an I2C read/write request I2CReply SysExCommand = 0x77 // a reply to an I2C read request I2CConfig SysExCommand = 0x78 // config I2C settings such as delay times and power pins ExtendedAnalog SysExCommand = 0x6F // analog write (PWM, Servo, etc) to any pin PinStateQuery SysExCommand = 0x6D // ask for a pin's current mode and value PinStateResponse SysExCommand = 0x6E // reply with pin's current mode and value CapabilityQuery SysExCommand = 0x6B // ask for supported modes and resolution of all pins CapabilityResponse SysExCommand = 0x6C // reply with supported modes and resolution AnalogMappingQuery SysExCommand = 0x69 // ask for mapping of analog to pin numbers AnalogMappingResponse SysExCommand = 0x6A // reply with mapping info ReportFirmware SysExCommand = 0x79 // report name and version of the firmware SamplingInterval SysExCommand = 0x7A // set the poll rate of the main loop SysExNonRealtime SysExCommand = 0x7E // MIDI Reserved for non-realtime messages SysExRealtime SysExCommand = 0x7F // MIDI Reserved for realtime messages Serial SysExCommand = 0x60 SysExSPI SysExCommand = 0x80 SerialConfig SerialSubCommand = 0x10 SerialComm SerialSubCommand = 0x20 SerialFlush SerialSubCommand = 0x30 SerialClose SerialSubCommand = 0x40 SPIConfig SPISubCommand = 0x10 SPIComm SPISubCommand = 0x20 SPI_MODE0 = 0x00 SPI_MODE1 = 0x04 SPI_MODE2 = 0x08 SPI_MODE3 = 0x0C SoftSerial SerialPort = 0x00 HardSerial1 SerialPort = 0x01 HardSerial2 SerialPort = 0x02 HardSerial3 SerialPort = 0x03 // pin modes Input PinMode = 0x00 Output PinMode = 0x01 Analog PinMode = 0x02 PWM PinMode = 0x03 Servo PinMode = 0x04 Shift PinMode = 0x05 I2C PinMode = 0x06 SPI PinMode = 0x07 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Arduino Firmata client for golang
func NewClient ¶
NewClient creates a new Client and connects to the Arduino board over specified serial port. It blocks till a connection is succesfully established and pin mappings are retrieved.
func (*Client) DigitalWrite ¶
Set the value of a digital pin
func (*Client) EnableAnalogInput ¶
Specified if a analog Pin should be watched for input. Values will be streamed back over a channel which can be retrieved by the Values() call.
func (*Client) EnableDigitalInput ¶
Specified if a digital Pin should be watched for input. Values will be streamed back over a channel which can be retrieved by the GetValues() call
func (*Client) SPIReadWrite ¶
Read and write data to SPI device
func (*Client) SerialConfig ¶
Configure a builtin or soft serial port. This command must be called before sending serial data. Set txPin and rxPin to 0x00 for builtin serial ports.
func (*Client) SerialData ¶
func (*Client) SetAnalogSamplingInterval ¶
func (*Client) SetPinMode ¶
SetPinMode sets the pin mode.
func (*Client) Values ¶
func (c *Client) Values() <-chan FirmataValue
type FirmataCommand ¶
type FirmataCommand byte
func (FirmataCommand) String ¶
func (c FirmataCommand) String() string
type FirmataValue ¶
type FirmataValue struct {
// contains filtered or unexported fields
}
func (FirmataValue) AnalogValue ¶
func (v FirmataValue) AnalogValue() (pin int, val int, err error)
func (FirmataValue) DigitalValue ¶
func (v FirmataValue) DigitalValue() (port byte, val map[byte]interface{}, err error)
func (FirmataValue) IsAnalog ¶
func (v FirmataValue) IsAnalog() bool
func (FirmataValue) String ¶
func (v FirmataValue) String() string
type SPISubCommand ¶
type SPISubCommand byte
type SerialPort ¶
type SerialPort byte
type SerialSubCommand ¶
type SerialSubCommand byte
type SysExCommand ¶
type SysExCommand byte
func (SysExCommand) String ¶
func (c SysExCommand) String() string