public class JNADevDevice extends Device
This implementation requires the i2c-dev kernel module to be loaded, and the JNA library to be available on the classpath, including its native libjnidispatch.so library which can also be specified using the java.library.path system property or LD_LIBRARY_PATH environment variable. The implementation works with the current Sun/Oracle JVM on Linux, but may not work on other systems.
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buf |
protected FileOutputStream |
out |
ADDR_GND, ADDR_SCL, ADDR_SDA, ADDR_VCC, CONFIG_AUDIO_INPUT, CONFIG_DISPLAY_MATRIX_1, CONFIG_DISPLAY_MATRIX_1_AND_2, CONFIG_DISPLAY_MATRIX_2, CONFIG_MATRIX_5X11, CONFIG_MATRIX_6X10, CONFIG_MATRIX_7X9, CONFIG_MATRIX_8X8, CONFIG_SOFTWARE_SHUTDOWN, errors, height, REG_BRIGHTNESS_CONFIG, REG_BRIGHTNESS_PWM, REG_CONFIG, REG_MATRIX1_DATA_START, REG_MATRIX2_DATA_START, REG_RESET, REG_UPDATE, shutdownHook, throwErrorCount, warnErrorCount, width| Constructor and Description |
|---|
JNADevDevice() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
closeImpl()
Closes the I2C bus and device.
|
protected int |
getNativeFileDescriptor(FileDescriptor fd)
Returns the native file descriptor associated with the Java file descriptor.
|
protected void |
ioctl(int fd,
int request,
int data)
Invokes the native ioctl function.
|
protected Device |
openImpl(int busNumber,
int address)
Opens the connection to the I2C bus and
to the device at the given address.
|
protected void |
writeImpl(byte register,
byte[] data,
int offset,
int length)
Writes a series of bytes of data starting at the given register.
|
protected void |
writeImpl(byte register,
int data)
Writes a single byte of data to the given register.
|
close, closeOnShutdown, configure, displayTestPatterns, getHeight, getWidth, handleError, init, main, newInstance, newInstance, open, open, reset, setBrightness, setDisplay, setDisplay, setDisplay, setDisplay, update, update, write, writeprotected FileOutputStream out
protected byte[] buf
protected int getNativeFileDescriptor(FileDescriptor fd) throws IOException
fd - the Java file descriptorIOException - if an error occursprotected void ioctl(int fd,
int request,
int data)
throws IOException
fd - the file descriptorrequest - the ioctl request type constantdata - the data for the requestIOException - if an error occursprotected Device openImpl(int busNumber, int address) throws IOException
DeviceopenImpl in class DevicebusNumber - the I2C bus number to useaddress - the I2C device addressIOException - if an error occursprotected void closeImpl()
throws IOException
Device
This method may be called multiple times, or
without a successful call to Device.open(int) before it.
closeImpl in class DeviceIOException - if an error occursprotected void writeImpl(byte register,
int data)
throws IOException
DevicewriteImpl in class Deviceregister - the register to write todata - the data to write (only the lower 8 bits are written)IOException - if an error occursprotected void writeImpl(byte register,
byte[] data,
int offset,
int length)
throws IOException
DevicewriteImpl in class Deviceregister - the register to write todata - an array containing the data to writeoffset - the offset within the array of the first byte to writelength - the number of bytes to writeIOException - if an error occursCopyright © 2017 freeutils.net. All rights reserved.