How to read Rotary encoder pulses?
Hi,
I am new to this forum and QT applications. i hope the message is in right place.
i have an ARM9 development board running linux on it. without using GUI i can use all devices on the board like hardware buttons (as interrupts), ADCs, eeproms etc...
For external buttons, ı use this example (simply)
Code:
fd = open("/dev/button", 0);
if (fd < 0) {
perror("error open device");
exit(1);
}
for (;;)
{
char buttons[3];
read(fd, buttons, sizeof buttons);
printf("%s %s %s", buttons[0] , buttons[1] , buttons[2] );
}
this prints the buttons state as 0 or 1
How can i implement this to GUI. how can i read device data continuesly in a fast way? i want to connect a rotary encoder and count the number of pulses. using the console applıcation no problem but how can i make this using QT?
thank you
Re: How to read Rotary encoder pulses?
muisei,
thank you for answering.
i will try to use second method. after some tials i will share the result here.
Re: How to read Rotary encoder pulses?
Use QSocketNotifier on your /dev/button to be notified of changes in the button and only react when there actually is a change. There is no point in having a busy loop (and wasting cpu power and electricity) just for reading the button status.
Re: How to read Rotary encoder pulses?
Quote:
Originally Posted by
wysota
Use
QSocketNotifier on your /dev/button to be notified of changes in the button and only react when there actually is a change. There is no point in having a busy loop (and wasting cpu power and electricity) just for reading the button status.
Now i have tried both ways using processevents and Qsocketnotifier.
placing process events in a loop made the application heavy since CPU load
Qsocketnotifier works very good. now i have to check how fast the signals are caught.
here is the part for the code:
Code:
buttons_fd = ::open("/dev/buttons", 0);
connect(sockerNotifier,SIGNAL(activated(int)),this,SLOT(notify()));
thank you for your help