Reading button states from a 4DPi-24-HAT

44 views
Skip to first unread message

Javalex

unread,
Apr 26, 2017, 4:56:03 AM4/26/17
to Pi4J
Hello,

I've recently acquired this screen/hat (http://www.4dsystems.com.au/product/4DPi_24_HAT/) for some playing around on the go. As an added bonus, the hat comes with 5 buttons below the screen which I would now like to use via Pi4J.

I have found this resource (http://www.mcmelectronics.com/content/ProductData/Etc/4DPi-24-HAT_appendix_R_1_0.pdf) that describes how to access these buttons in C and python. Unfortunately to the best of my knowledge, I was unable to translate this to Java/Pi4J and get it to work.

I guess the critical point is translating the following lines, which are supposed to read the button states

in C:
#define LCD4DPI_GET_KEYS _IOR('K', 1, unsigned char *)
ioctl(fd, LCD4DPI_GET_KEYS, &keys); // where keys in "unsigned char"

in Python:
LCD4DPI_GET_KEYS = _IOR(ord('K'), 1, 4)
fcntl
.ioctl(fd, LCD4DPI_GET_KEYS, buf, 1) # where buf is an array.array('h',[0])

Any idea how I could achieve this using Pi4J?
Any help would be immensely appreciated
Cheers
Alex


Javalex

unread,
Apr 27, 2017, 4:09:31 AM4/27/17
to Pi4J
Ok, after some internal testing/fiddling, plus some (more) digging, I have found the following:

- GPIO PIN #2 throws out interrupts when any of the 5 buttons are pressed/released (great start, but obviously not enough to tell me which one has been pressed specifically)

There is some example to make these 5 buttons work, yes.
 
(This refers to the code in C / Python I quoted in the original post) 
 
They are not linked to the Raspberry Pi, but instead talk directly to the Xilinx processor on the HAT itself, which then passes them to the Pi over SPI etc.

Which now indicates I have to go via SPI (I initially thought I had to go via I2C).
I am sure the answer is quite simple, but I have still little knowledge yet of how/where to start.
Any further pointer is again much appreciated.
Cheers
Alex
 
Reply all
Reply to author
Forward
0 new messages