Data Sheet
4D SYSTEMS 4DPi-32-II Primary Display – Raspberry Pi Compatible
© 2018 4D SYSTEMS Page 14 of 18 www.4dsystems.com.au
4DPi
-32
-II Primary Display
– Raspberry
Pi
10. Appendix 1 – Code Examples – Push Buttons
Example for communicating to Push Buttons, for C:
// test program to read state of buttons on 4D Systems 4DPi displays
#include <stdio.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#define LCD4DPI_GET_KEYS _IOR('K', 1, unsigned char *)
void print_keys(int fd)
{
unsigned char keys;
if (ioctl(fd, LCD4DPI_GET_KEYS, &keys) == -1)
{
perror("_apps ioctl get");
}
else
{
printf("Keys : %2x\n", keys);
}
}
int main(int argc, char *argv[])
{
char *file_name = "/dev/fb1";
int fd;
fd = open(file_name, O_RDWR);
if (fd == -1)
{
perror("_apps open");
return 2;
}
print_keys(fd);
printf("Ioctl Number: (dec)%d (hex)%x\n", LCD4DPI_GET_KEYS,
LCD4DPI_GET_KEYS);
close (fd);
return 0;
}