[<<] [<] Page 1 of 1 [>] [>>] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
Button interaction over GPIO
From: Raph HP ####@####.#### Date: 6 Nov 2006 10:37:39 +0000 Message-Id: <454F025F.2070302@gmx.fr> 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); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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: ####@####.#### > > | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Subject:
RE: [nanogui] Button interaction over GPIO
From: Prafulla WADASKAR ####@####.#### Date: 9 Nov 2006 03:53:46 +0000 Message-Id: <006501c703b2$903ac0a0$872cc70a@dlh.st.com> Hi raph You need to develop kernel space keyboard driver which will generate keypress/release events to the linux input subsystem, you can find references in ./drivers/input/keyboard Then using standard event interface of linux input subsystem you can get events in userspace using device node /dev/input/event# (evdev.ko need to be installed for this) If you are configuring console=tty0 then your STDIN will become installed keypad and nano-X should work with appropreate configuration If you are using any other console (generally serial port in most of cases) then, for nano x you need to add keypad driver which polls events from /dev/input/event0 and generates events for nano-X Regards.. Prafulla . . -----Original Message----- From: Raph HP ####@####.#### Sent: Monday, November 06, 2006 3:08 PM To: ####@####.#### Subject: [nanogui] Button interaction over GPIO 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: ####@####.#### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[<<] [<] Page 1 of 1 [>] [>>] |