nanogui: Button interaction over GPIO
Subject:
Re: [nanogui] Button interaction over GPIO
From:
tj ####@####.####
Date:
7 Nov 2006 17:23:03 +0000
Message-Id: <4550C0CD.2070208@comcast.net>
Raph,
What you need to try using is the PIPEKBD option. Go to the nano-X
config file and enable
PIPEKBD = Y and rebuild nano-X.
Look in the docs and you will find out how to use it.
Basicaly, you have a seperate process/therad that reads your GPIO
keyboard and decides what key was pressed, repeating key, etc and sends
that info through the pipe according to the nanoX specification. It is
then read from the main event loop in your app as a key event.
Again see the nano-X docs on about the specifics of creating and what to
write through the pipe.
tj
Raph HP wrote:
> Hello,
>
> I am looking for a way to have some interaction with Nano-X through
> buttons connected via general purpose I/O (GPIO) to an ARM9 board
> running Linux 2.6.15.
>
> By now, I am launching a thread that simply reads all GPIO ports all
> 30ms (the code is below). But it does not work well, it lasts a long
> time until Nano-X reacts to the pressing of a key.
>
> I guess it would be the best to use Nano-X's event handling. But in
> order to achieve that, I suppose that I need a driver, don't I?
>
> Any help would be very appreciated
>
> Thanks
>
> raph
>
>
> /* read ports */
> while (1) {
> port = 2;
> result = read(handle[port], &b[port], 1);
>
> if (b[port] == 0x07) { /* button connected to 2 pressed */
> if (red_button_state == 0) {
> red_button_state = 1;
> printf("DEBUG: red button switched on\n");
> }
> }
> else {
> if (red_button_state == 1) {
> printf("DEBUG: red button switched off\n");
> red_button_state = 0;
> }
> }
> if (result != 1) {
> perror("Can't read byte from port");
> return;
> }
> usleep(READ_CONST * 1000);
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ####@####.####
> For additional commands, e-mail: ####@####.####
>
>