Java-Lib for GPIOs [in development]

Post Reply
chromo
Posts: 7
Joined: Sun Feb 08, 2015 11:44 pm
languages_spoken: english, deutsch
ODROIDs: odroid c1
Has thanked: 0
Been thanked: 0
Contact:

Java-Lib for GPIOs [in development]

Post by chromo »

EDIT
I made a git-repo: https://github.com/Chromolus/jOdro

Hello,
I got 4 days ago my Odroid C1. I'm very happy with the device, BUT I was very disappointed that there is no Java-Lib for the GPIOs.
So I decided that I build my own one :) .
I post this because I want to know what you think about it. I also want to say that this lib is in development and can only control and listen gpios (No I2C...) and there is no warranty, that the lib doesn't damage something or works perfekt.

How to use the lib:
you construct a pin like this:

Code: Select all

led = new GPIOPin(OdroPin.GPIO_03, PinMode.OUT, PinState.HIGH);
OdroPin.GPIO_03: defines which pin you want to select. See more info in the Doc-Tooltip
PinMode.OUT: defines the direction of the pin. In this case Output. See more info in the Doc-Tooltip
PinState.HIGH: defines the default state of the Pin. Set this only when you use Out, there is a constructor only for pin and mode. See more info in the Doc-Tooltip

manipulate the state of the pin like this:

Code: Select all

led.low() //to set the pin to low-state

Code: Select all

led.high() //to set the pin to high-state

Code: Select all

led.toggle() //to invert the state of the pin
listen for changes like this:
implement GPIOListener
and call this method:

Code: Select all

led.addGPIOListener(l);
and implement this method:

Code: Select all

@Override
    public void valueChanged(GPIOPin pin) {
        System.out.println("Changed Value of "+pin.getPin().name()+" to: "+pin.getState().toString());
    }
at the end of the program you have to call:

Code: Select all

code.shutdown() //unexports the pin and sets it to defaults


This is all what my lib can do at the moment.
To use it you need no wiringPi or something like that it uses commands to set the pins.
Bevor you can use it you have to execute on your Odroid C1:

Code: Select all

sudo chmod 222 /sys/class/gpio/export /sys/class/gpio/unexport
Thanks for reading my post and sorry for my bad english :)
When you have some problems or have some ideas what to add/to change, please post it.
If you want to help developing me, you are welcome, there is much work to do (ADC, I2C...).
I hope you like my project, I added the lib and the netbeans-project in a zip.

Thanks,
chromo
Attachments
jGPIO.zip
(53.57 KiB) Downloaded 127 times
Last edited by chromo on Fri Feb 20, 2015 8:23 pm, edited 1 time in total.

lhuet
Posts: 1
Joined: Fri Feb 20, 2015 7:21 am
languages_spoken: english
ODROIDs: C1
Has thanked: 0
Been thanked: 0
Contact:

Re: Java-Lib for GPIOs [in development]

Post by lhuet »

Hello chromo,

Have you tried the Bulldog library : http://libbulldog.org/bulldog/ ?
This library seems to be complete and is platform independant.
I use this one for I2C on BBB with success.

Laurent

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 1 guest