Package com.diozero.firmata
Class FirmataAdapter
java.lang.Object
com.diozero.firmata.FirmataAdapter
- All Implemented Interfaces:
FirmataProtocol,java.io.Closeable,java.lang.AutoCloseable,java.lang.Runnable
- Direct Known Subclasses:
SocketFirmataAdapter
public class FirmataAdapter extends java.lang.Object implements FirmataProtocol, java.lang.Runnable, java.io.Closeable
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFirmataAdapter.FirmwareDetailsstatic classFirmataAdapter.I2CResponseNested classes/interfaces inherited from interface com.diozero.firmata.FirmataProtocol
FirmataProtocol.PinCapability, FirmataProtocol.PinMode -
Field Summary
Fields inherited from interface com.diozero.firmata.FirmataProtocol
ANALOG_IO_END, ANALOG_IO_START, ANALOG_MAPPING_QUERY, ANALOG_MAPPING_RESPONSE, CAPABILITY_QUERY, CAPABILITY_RESPONSE, DIGITAL_IO_END, DIGITAL_IO_START, END_SYSEX, EXTENDED_ANALOG, EXTENDED_ID, I2C_REPLY, I2C_REQUEST, PIN_STATE_QUERY, PIN_STATE_RESPONSE, PROTOCOL_VERSION, REPORT_ANALOG_PIN, REPORT_DIGITAL_PORT, REPORT_FIRMWARE, SAMPLING_INTERVAL, SET_DIGITAL_PIN_VALUE, SET_PIN_MODE, START_SYSEX, STRING_DATA, SYSEX_NON_REALTIME, SYSEX_REALTIME, SYSTEM_RESET -
Constructor Summary
Constructors Constructor Description FirmataAdapter(FirmataEventListener eventListener) -
Method Summary
Modifier and Type Method Description voidclose()protected voidconnect(java.io.InputStream input, java.io.OutputStream output)voidenableDigitalReporting(int gpio, boolean enabled)java.util.List<java.util.List<FirmataProtocol.PinCapability>>getBoardCapabilities()booleangetDigitalValue(int gpio)FirmataAdapter.FirmwareDetailsgetFirmware()intgetMax(int gpio, FirmataProtocol.PinMode mode)FirmataProtocol.PinModegetPinMode(int gpio)com.diozero.firmata.FirmataAdapter.PinStategetPinState(int gpio)com.diozero.firmata.FirmataAdapter.ProtocolVersiongetProtocolVersion()intgetValue(int gpio)FirmataAdapter.I2CResponsei2cRead(int slaveAddress, boolean autoRestart, boolean addressSize10Bit, int length)FirmataAdapter.I2CResponsei2cReadData(int slaveAddress, boolean autoRestart, boolean addressSize10Bit, int register, int length)voidi2cWrite(int slaveAddress, boolean autoRestart, boolean addressSize10Bit, byte[] data)voidi2cWriteData(int slaveAddress, boolean autoRestart, boolean addressSize10Bit, int register, byte[] data)voidinitialiseBoard()voidrun()voidsetDigitalValue(int gpio, boolean value)voidsetDigitalValues(int port, byte values)voidsetPinMode(int gpio, FirmataProtocol.PinMode pinMode)voidsetSamplingInterval(int intervalMs)voidsetValue(int gpio, int value)
-
Constructor Details
-
Method Details
-
connect
protected void connect(java.io.InputStream input, java.io.OutputStream output) throws java.io.IOException- Throws:
java.io.IOException
-
getMax
-
initialiseBoard
public void initialiseBoard() throws java.io.IOException- Throws:
java.io.IOException
-
getProtocolVersion
public com.diozero.firmata.FirmataAdapter.ProtocolVersion getProtocolVersion() throws java.io.IOException- Throws:
java.io.IOException
-
getFirmware
-
getBoardCapabilities
-
getPinState
public com.diozero.firmata.FirmataAdapter.PinState getPinState(int gpio) throws java.io.IOException- Throws:
java.io.IOException
-
setSamplingInterval
public void setSamplingInterval(int intervalMs) throws java.io.IOException- Throws:
java.io.IOException
-
enableDigitalReporting
public void enableDigitalReporting(int gpio, boolean enabled) throws java.io.IOException- Throws:
java.io.IOException
-
getPinMode
-
setPinMode
- Throws:
java.io.IOException
-
setDigitalValues
public void setDigitalValues(int port, byte values) throws java.io.IOException- Throws:
java.io.IOException
-
getDigitalValue
public boolean getDigitalValue(int gpio) -
setDigitalValue
public void setDigitalValue(int gpio, boolean value) throws java.io.IOException- Throws:
java.io.IOException
-
getValue
public int getValue(int gpio) -
setValue
public void setValue(int gpio, int value) throws java.io.IOException- Throws:
java.io.IOException
-
i2cRead
public FirmataAdapter.I2CResponse i2cRead(int slaveAddress, boolean autoRestart, boolean addressSize10Bit, int length) throws java.io.IOException- Throws:
java.io.IOException
-
i2cWrite
public void i2cWrite(int slaveAddress, boolean autoRestart, boolean addressSize10Bit, byte[] data) throws java.io.IOException- Throws:
java.io.IOException
-
i2cReadData
public FirmataAdapter.I2CResponse i2cReadData(int slaveAddress, boolean autoRestart, boolean addressSize10Bit, int register, int length) throws java.io.IOException- Throws:
java.io.IOException
-
i2cWriteData
public void i2cWriteData(int slaveAddress, boolean autoRestart, boolean addressSize10Bit, int register, byte[] data) throws java.io.IOException- Throws:
java.io.IOException
-
close
public void close()- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable
-
run
public void run()- Specified by:
runin interfacejava.lang.Runnable
-