Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A20 => Topic started by: Claus on December 30, 2014, 11:04:36 PM

Title: GPIO inputs and Android
Post by: Claus on December 30, 2014, 11:04:36 PM
Hello everybody,
I do some app coding and now I am a little bit surprised...
when a GPIO is configured as in (direction > in)
and external voltage puts value from 0 to 1,
than it is not recognised by java class FileObserver.

The timestamp of file "value" is not touched during its content change.

A20 Tools is using os tool cat.

Does somebody know a way to recognise value changes with a java class?
or/and
How can I enable timestamp of modification for file "value"?

regards
Claus
Title: Re: GPIO inputs and Android
Post by: MBR on January 02, 2015, 04:34:07 AM
I don't know how Java class FileObserver works internally, but there can be two reasons:
Title: Re: GPIO inputs and Android
Post by: dave-at-axon on January 03, 2015, 08:14:12 AM
GPIO under Android is quite easy and uses the same C calls as you would with Linux but you need to use the JNI and the Android NDK to build and use them as Java can't directly talk to the drivers.

There is some code on the Internet that I wrote a while back and I have since done some work on it and have now got a library that can do both I2C and GPIO on any Android system.

I'll update my blog soon with the source and build instructions for this but in the mean time, if you send me a PM with your email address I will send you the Java class and JNI code to build the library that you need to work with GPIO. You'll need to download the NDK from the Android development website to use it.