Library which helps to communicate with CHIP GPIO using Java language.
Clone project and install in local repository.
git clone https://github.com/DenisLAD/JavaGPIOLib.git
cd GPIOChipLib
mvn install
Add maven dependency into your project.
<dependencies>
...
<dependency>
<groupId>free.lucifer</groupId>
<artifactId>chiplib</artifactId>
<version>0.1.2</version>
</dependency>
...
</dependencies>
Just read data.
Chip.I.open(); // Prepare low level access
Chip.Pin pin1 = Chip.Pin.XIO_P7;
Chip.I.pinMode(pin1, Chip.Pin.PinMode.INPUT); // Setup pin mode
while (true) {
System.out.println(Chip.I.digiatalRead(pin1));
}
Read DHT11 sensor
Chip.I.open(); // Prepare low level access
DHT11 dht = new DHT11(Chip.Pin.CSID0); // Use CSID0 pin
Chip.I.addTask(dht); // Add task to interval update
while(dht.getStatus() != DHT11.Status.OK) { // Repeat while status in not OK
LockSupport.parkNanos(TimeUnit.SECONDS.toNanos(1)); // Wait 1 second
}
System.out.println("Temperature: " + dht.getTemperature());
System.out.println("Humidity: " + dht.getHumidity());
...
If you want to use all of CHIP pins, you should run your project thru sudo or add your user to super user group. ...
Library uses JNA to access to native IO libraries. Also library uses direct access to memory instead of file system access (which may improve the speed).
- SPI
- DHT11 (temperature sensor)
- I2C
- SSD1306 (LCD)
- nRF24L01+ (network)
- A4988 (stepper driver)
- Soft PWM at high speed