display a picture by pressing the screen

Hello everyone!

I have a 2.8 TFT touch screen.
I have a keyboard as wallpaper, and when I press the buttons, I want the numbers displayed one after the other, the concern is that I want to be able to show that 4 digits, when I press a single digit, it appears 4 times, whereas I want it to appear only once .. I do not think that silliness in my code ..
here is my code (I use that number 1 and 2 for the moment):

int press()
{
  
   digitalWrite(13, HIGH);
    Point p = ts.getPoint();
    digitalWrite(13, LOW);
  
    // if sharing pins, you'll need to fix the directions of the touchscreen pins
    //pinMode(XP, OUTPUT);
    pinMode(XM, OUTPUT);
    pinMode(YP, OUTPUT);
    
    int i = 0;
    
    
    if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
      
      // scale from 0->1023 to tft.width
      p.x = map(p.x, TS_MINX, TS_MAXX, tft.width(), 0);
      p.y = map(p.y, TS_MINY, TS_MAXY, tft.height(), 0);
      
     
      for(i = 0; i < 4; i++) 
     
      {   
        if (p.y >= 7 && p.y <= 65 && p.x >= 175 && p.x <= 231)
        {
          
          Serial.println("hello  XY ");
    
          bmpDraw("1.bmp", 14, Yfirst + i*Yafter);
          
         }  
         if (p.y >= 71 && p.y <= 127 && p.x >= 175 && p.x <= 232)
         {
          
          Serial.println("hello  X1Y1 ");
          bmpDraw("2.bmp", 13, Yfirst + i*Yafter);
          
         }
      }
       
         
         /*if(i = 3)
         {
           bmpDraw("tiger.bmp",0,0);
         }
          */  
  
    }
    
  
  
}

If anyone can help me it would be cool! :slight_smile:

You haven't given us enough information to work with. But I guess the problem is with the touchscreen as far as I can understand. To help us give you more information, you could:

  1. Make it clear what library you are using / where you got this code.
  2. What's MINPRESSURE and MAXPRESSURE?
  3. Post your complete code. It could be that something else is the culprit as your touchscreen code looks fine.
  4. This may be non obvious, but check the power supply. This has happened with me many times. My code looks fine but the power supply fluctuates.
  5. Try just printing some text and activating something when that text is pressed. Build on that.
  6. You could use the UTFT and UTouch libraries (Electronics - Henning Karlsen and Electronics - Henning Karlsen) or the UTFT_Buttons (Electronics - Henning Karlsen) library. They are way easier to work with and can support many different types of controllers and almost all of the common ones. Just make sure you're using a shield (if you are) that connects the pins properly.
  7. Make it clear what XM, XP, and YP are.

here is my code (I use that number 1 and 2 for the moment):

What does that mean?

  1. What are the sizes of your bitmaps? >2GB = FAIL.
  2. Model? Controllers?

I have a 2.8 TFT touch screen.

We do not get anything from that.

10.Don't press the digit for too long. OR increase the time that is regarded as a 'touch'