mattlewis
Posts: 107
Joined: Sat Jan 12, 2013 3:05 pm
Location: UK
Contact: Website

Update on diozero - Java Device I/O library

Fri Feb 12, 2016 12:33 pm

Almost ready for a 1.0 release, see https://github.com/mattjlewis/diozero for details.
I was getting some odd behaviour with wiringPi, Pi4j and JDK Device I/O so I knocked together a pigpio JNI wrapper library (there was one already but was only partially implemented). This is currently my preferred provider for Raspberry Pi.
Again I understand the overlap in functionality between this and Pi4j, in particular the new device capabilities in v1.1-SNAPSHOT. However as previously stated I wanted to ensure maximum portability across devices as well as present a clean object-orientated API similar to that offered by the Python GPIO Zero.

Usage example:
1. Controlling an LED with a button

Code: Select all

try (Button b = new Button(buttonPin, GpioPullUpDown.PULL_UP); LED led = new LED(ledPin)) {
	b.whenPressed(led::on);
	b.whenReleased(led::off);
	Logger.info("Waiting for 10s - *** Press the button connected to pin {} ***", Integer.valueOf(buttonPin));
	SleepUtil.sleepSeconds(10);
}
2. Doing the same via a MCP23017 GPIO expansion board:

Code: Select all

try (MCP23017 mcp23017 = new MCP23017(intAPin, intBPin)) {
	try (Button button = new Button(mcp23017, inputPin, GpioPullUpDown.PULL_UP);
			LED led = new LED(mcp23017, outputPin, false, true)) {
		button.whenPressed(led::on);
		button.whenReleased(led::off);
		Logger.debug("Waiting for 10s - *** Press the button connected to MCP23017 pin {} ***", Integer.valueOf(inputPin));
		SleepUtil.sleepSeconds(10);
}
As always feedback is very welcome.

Matt
http://www.diozero.com/

mattlewis
Posts: 107
Joined: Sat Jan 12, 2013 3:05 pm
Location: UK
Contact: Website

Re: Update on diozero - Java Device I/O library

Sat Feb 20, 2016 10:42 pm

Uploaded another snapshot build to the Maven repository - newest addition is support for all MCP30/32/34 ADCs as well as WS281x / NeoPixel LEDs (via a JNI wrapper around the rpi_ws281x library).
Slowly working on the documentation at http://rtd.diozero.com.

Matt
http://www.diozero.com/

mattlewis
Posts: 107
Joined: Sat Jan 12, 2013 3:05 pm
Location: UK
Contact: Website

Re: Update on diozero - Java Device I/O library

Wed Jun 07, 2017 7:42 pm

If anyone is interest this library continues to be actively developed; it now works on all flavours of Pi, Beaglebone Black, Asus Tinker Board, CHIP and CHIP Pro, Odroid C2 as well as Arduino's connected via USB using the Firmata protocol. All device control is handled by dynamically loaded providers, including pigpio (both local and socket), Pi4j, wiringPi and one for the BBB based on BBBiolib. There is also a built in fallback implementation using sysfs / SMbus that can be easily ported to any Linux based SBC.

I have a work in progress provider that uses a Java native memory mapped ByteBuffer for high speed GPIO control that works on Pi as well as Odroid C2.

I'm gradually adding in support for more devices, recent ones include SSD1306 display, MCP EEPROMs and the MFRC522 rfid reader.

Give it a try and let me know how you get on. Feedback always welcome!

http://www.diozero.com

Matt
http://www.diozero.com/

mattderoddock
Posts: 2
Joined: Tue Oct 24, 2017 4:36 pm

Re: Update on diozero - Java Device I/O library

Tue Oct 24, 2017 4:59 pm

Hi Matt,

Could you help me, I've been created new Project on NetBeans 8.2 and I have imported jar files, such as diozero-core11xxx.jar , tinylog.jar on my Project. I also build the project and successfully but when I try to Run the it give me an error :
23:52:06.791 [main] ERROR rc522read.ReadUid.main - Usage: rc522read.ReadUid <spi-controller> <chip-select> <rst-gpio>
/root/.cache/netbeans/8.2/executor-snippets/run.xml:53: Java returned: 1
BUILD FAILED (total time: 1 second) . what should I do. Thank You.

Can you help Matt..

Thank You,
DeRoddock

mattlewis
Posts: 107
Joined: Sat Jan 12, 2013 3:05 pm
Location: UK
Contact: Website

Re: Update on diozero - Java Device I/O library

Tue Oct 24, 2017 7:32 pm

Can you confirm what version of diozero you are using please. I'd recommend the latest 0.11-SNAPSHOT version.
From your post it looks like you are using an old version of the MFRC classes. They are now in the diozero-sampleapps project in the package com.diozero.sampleapps.mfrc522. You should first try to run com.diozero.sampleapps.mfrc522.ReadUid.

Also are you using Maven to build / package / run you application or are you managing dependencies manually? I'd recommend Maven.
As an FYI, I've recently added documentation for developing diozero applications: http://rtd.diozero.com/en/latest/Application/

Let me know how you get on.

Regards,
Matt
http://www.diozero.com/

mattderoddock
Posts: 2
Joined: Tue Oct 24, 2017 4:36 pm

Re: Update on diozero - Java Device I/O library

Sun Oct 29, 2017 2:48 pm

Hi Matt,


Yes Matt, I'm using your latest 0.11-SNAPSHOT version and also 1.2 tiny log , diozero-core . I added manually jar files on my netbeans java project, I didn't try yet of your step by step documentations by using maven. I'm not familiar with eclipse , but I will try your suggestion.

Thank You Matt.

Return to “Java”

Who is online

Users browsing this forum: No registered users and 1 guest