Rotary encoder problem
-
wrote on 25 Mar 2022, 19:27 last edited by
How do I make the system understand that the encoder increment is Key_Left and Key_Right decrement?
I believe I should have to direct this in a module, correct? If yes, how to do it? Thanks for listening!For example,
void FControl::onKeyPress(int Key)
{
qDebug() << "received";
qDebug() << Page;
int press;switch(key) { case Qt::Key_Enter: case Qt::Key_Return: press=0; break; case Qt::Key_Left: press= -120; break; case Qt::Key_Right: press= +120; break; case Qt::Key_Return: }
........
-
Hi and welcome to devnet,
How is that method called in your code ?
-
wrote on 25 Mar 2022, 19:40 last edited by
Hello, how are you? Thanks my dear!
I'm using a toradex verdin, I've already generated the kernel and binaries for the rotary encoder. I tested the encoder with the multimeter and everything is ok.
My application uses the left key for decrement and right for increment. I would like to make the encoder work in the application in the same way, when turning the encoder, the app already understands the side and increments or decrements.
Today I'm using onKeyPress. -
Hence my question: how is that method called ? Do you have a signal connected to it ?
-
wrote on 25 Mar 2022, 19:56 last edited by
Yes, I have some knobs connected to the application, which increment or decrement with the rotation. It's a lung ventilator project, each knob has a function, such as: tidal volume, frequency, flow, peep, limit pressure... when I click on the screen, I can control these knobs through the left and right keys, however I would like to use an encoder for this and also keep the keys working!
-
That is clear and understood. What you are not answering is: how is onKeyPress called ?
What is the flow between your encoder back to your GUI ? -
wrote on 25 Mar 2022, 20:09 last edited by
connect(parent, SIGNAL(KeyPress(int)),this,SLOT(onKeyPress(int)));
Is it? -
Then how is KeyPress emitted ?
-
wrote on 25 Mar 2022, 21:29 last edited by
By KeyPressEvent(QKeyEvent * e).
-
wrote on 25 Mar 2022, 23:18 last edited by
What is the output from the rotary encoder that your application can respond to? Does it appear as a keyboard to the OS?
-
wrote on 26 Mar 2022, 04:17 last edited by
Doesn't rotary encoder outputs min of two "digits" ? Then you compare previous to current output to determine direction of rotation and from that derive "up or down " value to be added / deleted .
-
wrote on 30 Mar 2022, 00:12 last edited by allanbic
@mchinand Hi, how are you? Have a great day. No, It is found as rotary encoder even by the operating system, but the qt app was configured to detect only the keyboard keys, and I would like to make the keyboard and the encoder work simultaneously. But I'm not sure how to make the encoder work in the qt application.
-
What is the output from the rotary encoder that your application can respond to? Does it appear as a keyboard to the OS?
wrote on 30 Mar 2022, 00:24 last edited by allanbic@AnneRanch , Thanks for your answer! The problem is that I don't know how to add the encoder functions in my application. It is already working on the OS, but I don't know how to call it in the app...
-
Can you explain how it is "working with the OS" ?
How would you retrieve the data ?
1/14