0

Adafruit GFX Library
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Adafruit GFX Library

by Mosto on Wed Jun 02, 2021 2:47 am

Hi everyone.
In the Arduino example sketch of the telephone keypad, by holding down the same number button, in the text box where the number appears, the new number is accepted only after releasing and pressing the key again. I would like that by holding down the same numeric key, in the text box the number pressed would be added to the previous one every time. For example, if I leave button 1 pressed, "1", then "11", then "111" etc. appear sequentially in the text box.
I tried with the function of the Adafruit_GFX_Button Class isPressed (void), but it didn't work. Is there anyone who can point me to a working example of this.
Thanks in advance and sorry for my English.
Regards.

Mosto
 
Posts: 2
Joined: Wed Jun 02, 2021 2:24 am

Re: Adafruit GFX Library

by blnkjns on Wed Jun 02, 2021 4:18 am

I think for this to work as you like, we need to write a custom routine to do the readout. What is the frequency of your loop routine? Does it loop like 30-100 times a second, or is there a big delay in it? If that is the case, you need a timer or a pin interrupt to do the key reading. What board do you use?
Can you give the exact part number of your keypad?

blnkjns
 
Posts: 663
Joined: Fri Oct 02, 2020 3:33 am

Re: Adafruit GFX Library

by Mosto on Wed Jun 02, 2021 5:38 am

@blnkjns
Thank you for your answer.
I use an Arduino Mega with a 3.5 "TFT 320x480, which communicates with serial to an Arduino Due.
The loop must be 250 milliseconds. I have to solve this because I'm going to apply the logic of this type of routine to a button that increases the speed of a stepper motor. The code, very simple, has already been written, but I can only increase the speed by releasing and pressing the button again.
The only critical piece of code is the following. The Arduino Mega sends the command to the Arduino Due, which in turn controls the engine. The increase is calculated by the arduino due, based on the string received by the arduino Mega.
Code: Select all | TOGGLE FULL SIZE
for (uint8_t b = 0; b < 4; b++) {
    if (buttonsTrack[b].justReleased()) {
      buttonsTrack[b].drawButton();
    }
    if (buttonsTrack[b].justPressed()) {
      buttonsTrack[b].drawButton(true);
 
      // Custom Speed -- Speed decreases
      if (b == 0) {
             Serial1.print (":GG-#");
        // Go to Sidereal Track
       
      }

     // Custom Speed ++ Speed Up
      if (b == 1) {
          Serial1.print (":GG+#");
     
       }
     
      // Run/Stop step --
      if (b == 2) {
         Serial1.print (":SM#");
       
      }
    }
     
   delay(1); // UI debouncing
  }


Thanks in advance.

Mosto
 
Posts: 2
Joined: Wed Jun 02, 2021 2:24 am

Please be positive and constructive with your questions and comments.