Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Rotary encoder problem
Forum Updated to NodeBB v4.3 + New Features

Rotary encoder problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 1.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    allanbic
    wrote on 25 Mar 2022, 19:27 last edited by
    #1

    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:
     }
    

    ........

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 25 Mar 2022, 19:27 last edited by
      #2

      Hi and welcome to devnet,

      How is that method called in your code ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        allanbic
        wrote on 25 Mar 2022, 19:40 last edited by
        #3

        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.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 25 Mar 2022, 19:41 last edited by
          #4

          Hence my question: how is that method called ? Do you have a signal connected to it ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • A Offline
            A Offline
            allanbic
            wrote on 25 Mar 2022, 19:56 last edited by
            #5

            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!

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 25 Mar 2022, 19:58 last edited by
              #6

              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 ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • A Offline
                A Offline
                allanbic
                wrote on 25 Mar 2022, 20:09 last edited by
                #7

                connect(parent, SIGNAL(KeyPress(int)),this,SLOT(onKeyPress(int)));
                Is it?

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 25 Mar 2022, 20:11 last edited by
                  #8

                  Then how is KeyPress emitted ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    allanbic
                    wrote on 25 Mar 2022, 21:29 last edited by
                    #9

                    By KeyPressEvent(QKeyEvent * e).

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mchinand
                      wrote on 25 Mar 2022, 23:18 last edited by
                      #10

                      What is the output from the rotary encoder that your application can respond to? Does it appear as a keyboard to the OS?

                      A 1 Reply Last reply 30 Mar 2022, 00:24
                      0
                      • A Offline
                        A Offline
                        Anonymous_Banned275
                        wrote on 26 Mar 2022, 04:17 last edited by
                        #11

                        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 .

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          allanbic
                          wrote on 30 Mar 2022, 00:12 last edited by allanbic
                          #12

                          @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.

                          1 Reply Last reply
                          0
                          • M mchinand
                            25 Mar 2022, 23:18

                            What is the output from the rotary encoder that your application can respond to? Does it appear as a keyboard to the OS?

                            A Offline
                            A Offline
                            allanbic
                            wrote on 30 Mar 2022, 00:24 last edited by allanbic
                            #13

                            @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...

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on 30 Mar 2022, 20:44 last edited by
                              #14

                              Can you explain how it is "working with the OS" ?
                              How would you retrieve the data ?

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0

                              1/14

                              25 Mar 2022, 19:27

                              • Login

                              • Login or register to search.
                              1 out of 14
                              • First post
                                1/14
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • Users
                              • Groups
                              • Search
                              • Get Qt Extensions
                              • Unsolved