public class FirmataMessageFactory extends Object
Modifier and Type | Field and Description |
---|---|
static byte[] |
ANALOG_MAPPING_REQUEST
The analog mapping query provides the information about which pins (as
used with Firmata's pin mode message) correspond to the analog channels.
|
static byte[] |
REQUEST_CAPABILITY
This message requests capability repot of a Firmata device.
|
static byte[] |
REQUEST_FIRMWARE
This message requests firmware version of a Firmata device.
|
Constructor and Description |
---|
FirmataMessageFactory() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
analogReport(boolean enable)
Builds message to enable or disable reporting from Firmata device on
change of analog input.
|
static byte[] |
digitalReport(boolean enable)
Builds message to enable or disable reporting from Firmata device on
change of digital input.
|
static byte[] |
i2cConfigRequest(int delayInMicroseconds)
Creates SysEx message that configures I2C setup.
|
static byte[] |
i2cReadRequest(byte slaveAddress,
int register,
int bytesToRead,
boolean continuous)
Builds a message that asks a Firmata device to read data from an I2C
device.
|
static byte[] |
i2cStopContinuousRequest(byte slaveAddress)
Builds a message that terminates receiving continuous updates from
specified I2C device.
|
static byte[] |
i2cWriteRequest(byte slaveAddress,
byte... bytesToWrite)
Builds a message that asks a Firmata device to send specified data to
specified I2C device.
|
static byte[] |
pinStateRequest(byte pinId)
Builds a message that requests a state of specified pin.
|
static byte[] |
servoConfig(byte pinId,
int minPulse,
int maxPulse)
Builds servo configuration message.
|
static byte[] |
setAnalogPinValue(byte pinId,
long value)
Creates Firmata message to set value of an output pin in PWM mode.
|
static byte[] |
setDigitalPinValue(byte portId,
byte value)
Creates Firmata message to set digital values of port's pins.
|
static byte[] |
setMode(byte pinId,
Pin.Mode mode)
Creates the message that assigns particular mode to specified pin.
|
static byte[] |
setSamplingInterval(int value)
Creates a message to set sampling interval.
|
static byte[] |
stringMessage(String message)
Encodes the string as a SysEx message.
|
public static final byte[] REQUEST_FIRMWARE
public static final byte[] REQUEST_CAPABILITY
public static final byte[] ANALOG_MAPPING_REQUEST
public static byte[] i2cConfigRequest(int delayInMicroseconds)
delayInMicroseconds
- delay between the moment a register is written
to and the moment when the data can be read from that register (optional,
when I2C device requires a delay)public static byte[] i2cWriteRequest(byte slaveAddress, byte... bytesToWrite)
slaveAddress
- address of the I2C device you want to talk tobytesToWrite
- data to send to the slaveAddersspublic static byte[] i2cReadRequest(byte slaveAddress, int register, int bytesToRead, boolean continuous)
slaveAddress
- address of the I2C device you want to talk toregister
- The device register to read from.bytesToRead
- the number of bytes that the device will returncontinuous
- repeatedly send updates until asked to stoppublic static byte[] i2cStopContinuousRequest(byte slaveAddress)
slaveAddress
- address of the I2C device you want to shut uppublic static byte[] pinStateRequest(byte pinId)
pinId
- index of the pinpublic static byte[] analogReport(boolean enable)
enable
- message enables analog reporting if true and disable if
falsepublic static byte[] digitalReport(boolean enable)
enable
- message enables digital reporting if true and disable if
falsepublic static byte[] setMode(byte pinId, Pin.Mode mode)
pinId
- index of the pinmode
- modepublic static byte[] setDigitalPinValue(byte portId, byte value)
portId
- index of a portvalue
- values of port's pinspublic static byte[] setAnalogPinValue(byte pinId, long value)
pinId
- index of the pinvalue
- value to be setpublic static byte[] setSamplingInterval(int value)
value
- sampling interval in millisecondspublic static byte[] servoConfig(byte pinId, int minPulse, int maxPulse)
setMode(byte, org.firmata4j.Pin.Mode)
to attach/detach Servo
support to a pin. Then the normal setAnalogPinValue(byte, long)
is used to send data.pinId
- minPulse
- maxPulse
- public static byte[] stringMessage(String message)
message
- string messageCopyright © 2017. All rights reserved.