Documentation ¶
Index ¶
- Constants
- type FirmataClient
- func (c *FirmataClient) AnalogWrite(pin uint, pinData byte) (err error)
- func (c *FirmataClient) Close()
- func (c *FirmataClient) Delay(duration time.Duration)
- func (c *FirmataClient) DigitalWrite(pin uint8, val bool) error
- func (c *FirmataClient) EnableAnalogInput(pin uint, val bool) (err error)
- func (c *FirmataClient) EnableDigitalInput(pin uint, val bool) (err error)
- func (c *FirmataClient) GetSerialData() <-chan string
- func (c *FirmataClient) GetValues() <-chan FirmataValue
- func (c *FirmataClient) SPIConfig(csPin byte, spiMode byte) (err error)
- func (c *FirmataClient) SPIReadWrite(csPin byte, data []byte) (dataOut []byte, err error)
- func (c *FirmataClient) SerialConfig(port SerialPort, baud int, txPin byte, rxPin byte) (err error)
- func (c *FirmataClient) SetAnalogSamplingInterval(ms byte) (err error)
- func (c *FirmataClient) SetPinMode(pin uint8, mode PinMode) error
- 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 FirmataClient ¶
type FirmataClient struct { Log *log.Logger Verbose bool // contains filtered or unexported fields }
Arduino Firmata client for golang
func NewClient ¶
func NewClient(dev string, baud int) (client *FirmataClient, err error)
Creates a new FirmataClient object and connects to the Arduino board over specified serial port. This function blocks till a connection is succesfullt established and pin mappings are retrieved.
func (*FirmataClient) AnalogWrite ¶
func (c *FirmataClient) AnalogWrite(pin uint, pinData byte) (err error)
Set the value of a analog pin
func (*FirmataClient) Close ¶
func (c *FirmataClient) Close()
Close the serial connection to properly clean up after ourselves Usage: defer client.Close()
func (*FirmataClient) Delay ¶
func (c *FirmataClient) Delay(duration time.Duration)
Close the serial connection to properly clean up after ourselves Usage: defer client.Close()
func (*FirmataClient) DigitalWrite ¶
func (c *FirmataClient) DigitalWrite(pin uint8, val bool) error
Set the value of a digital pin
func (*FirmataClient) EnableAnalogInput ¶
func (c *FirmataClient) EnableAnalogInput(pin uint, val bool) (err error)
Specified if a analog Pin should be watched for input. Values will be streamed back over a channel which can be retrieved by the GetValues() call
func (*FirmataClient) EnableDigitalInput ¶
func (c *FirmataClient) EnableDigitalInput(pin uint, val bool) (err error)
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 (*FirmataClient) GetSerialData ¶
func (c *FirmataClient) GetSerialData() <-chan string
Get channel for incoming serial data
func (*FirmataClient) GetValues ¶
func (c *FirmataClient) GetValues() <-chan FirmataValue
Get the channel to retrieve analog and digital pin values
func (*FirmataClient) SPIConfig ¶
func (c *FirmataClient) SPIConfig(csPin byte, spiMode byte) (err error)
Enable SPI communication for selected chip-select pin
func (*FirmataClient) SPIReadWrite ¶
func (c *FirmataClient) SPIReadWrite(csPin byte, data []byte) (dataOut []byte, err error)
Read and write data to SPI device
func (*FirmataClient) SerialConfig ¶
func (c *FirmataClient) SerialConfig(port SerialPort, baud int, txPin byte, rxPin byte) (err error)
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 (*FirmataClient) SetAnalogSamplingInterval ¶
func (c *FirmataClient) SetAnalogSamplingInterval(ms byte) (err error)
Sets the polling interval in milliseconds for analog pin samples
func (*FirmataClient) SetPinMode ¶
func (c *FirmataClient) SetPinMode(pin uint8, mode PinMode) error
Sets the Pin mode (input, output, etc.) for the Arduino pin
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) GetAnalogValue ¶
func (v FirmataValue) GetAnalogValue() (pin int, val int, err error)
func (FirmataValue) GetDigitalValue ¶
func (v FirmataValue) GetDigitalValue() (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