[SOLVED] New to TFT LCD, want value to change while holding a button

Hello! Hoping you can help me with this :disappointed_relieved:

I'm new to touch screen lcds. I'm using sainsmart 3.2" tft lcd with sd card slot along with its shield and an arduino mega 2560.

I have a project that alarms when the pressure read by the sensor falls out of range.

The display will look like this:

P1 _____ kPa [ + ] [ - ]
P2 _____ kPa [ + ] [ - ]

I'm still on the 'Selecting Range' step. I can decrease/increase P1 and P2 values by pressing +/- button but since the range should be from -101.3 to 101.3 and I can only add or subtract 0.1 per press, I'm not satisfied. I know the user will get tired just getting to 10 kPa.

This is my current code:

// UTouch_ButtonTest (C)2010-2014 Henning Karlsen
// web: http://www.henningkarlsen.com/electronics
//
// This program is a quick demo of how create and use buttons.
//
// This program requires the UTFT library.
//
// It is assumed that the display module is connected to an
// appropriate shield or that you know how to change the pin 
// numbers in the setup.
//
//Jiah was here

#include <UTFT.h>
#include <UTouch.h>
//#include <stdlib.h>

// Initialize display
// ------------------
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino Uno/2009 Shield            : <display model>,19,18,17,16
// Standard Arduino Mega/Due shield            : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Due       : <display model>,25,26,27,28
// Teensy 3.x TFT Test Board                   : <display model>,23,22, 3, 4
// ElecHouse TFT LCD/SD Shield for Arduino Due : <display model>,22,23,31,33
//
// Remember to change the model parameter to suit your display module!
UTFT    myGLCD(ITDB32S,38,39,40,41);

// Initialize touchscreen
// ----------------------
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino Uno/2009 Shield            : 15,10,14, 9, 8
// Standard Arduino Mega/Due shield            :  6, 5, 4, 3, 2
// CTE TFT LCD/SD Shield for Arduino Due       :  6, 5, 4, 3, 2
// Teensy 3.x TFT Test Board                   : 26,31,27,28,29
// ElecHouse TFT LCD/SD Shield for Arduino Due : 25,26,27,29,30
//
UTouch  myTouch( 6, 5, 4, 3, 2);

// Declare which fonts we will be using
extern uint8_t BigFont[];
extern uint8_t SmallFont[];
extern uint8_t SevenSegNumFont[];

long startTime = 0;

int test=0;
//int x, y;

float pressureOne=0.0;
float pressureTwo=0.0;

char stpOne[20]="";
char stpTwo[20]="";
String convOne;
String convTwo;
extern unsigned int logo[0x200];
/*************************
**   Custom functions   **
*************************/

void drawButtons()
{
  myGLCD.setFont(BigFont);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(0, 112, 185);
  
// Draw the upper row of buttons
  myGLCD.setColor(0, 112, 185);
  myGLCD.fillRoundRect (170, 90, 198, 118);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (170, 90, 198, 118);

  myGLCD.print("+", 176, 96, 0);

  myGLCD.setColor(0, 112, 185);
  myGLCD.fillRoundRect (206, 90, 234, 118);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (206, 90, 234, 118);
  
  myGLCD.print("-", 212, 96, 0);
  
// Draw the lower row of buttons
  myGLCD.setColor(0, 112, 185);
  myGLCD.fillRoundRect (170, 134, 198, 162);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (170, 134, 198, 162);
      
  myGLCD.print("+", 176, 140, 0);

  myGLCD.setColor(0, 112, 185);
  myGLCD.fillRoundRect (206, 134, 234, 162);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (206, 134, 234, 162);
  
  myGLCD.print("-", 212, 140, 0);
  
  
  myGLCD.setBackColor (0, 112, 185);
}

void calculateVal(){
//  convOne=dtostrf(pressureOne, 4, 1, stpOne);
//  convTwo=dtostrf(pressureTwo, 4, 1, stpTwo);
  
  myGLCD.setFont(BigFont);
  myGLCD.setColor(0, 0, 0);
  
//  myGLCD.print("HERE", 40, 96);
  
  myGLCD.printNumF(pressureOne, 1, 40, 96, 46, 6, 32);
  myGLCD.printNumF(pressureTwo, 1, 40, 140, 46, 6, 32);
}

void processTouch() {
  if (myTouch.dataAvailable())
  {
//    test += 1;
//    myGLCD.printNumI(x , 40, 184, 0);
//    myGLCD.printNumI(y , 40, 200, 0);
    
    myTouch.read();
    int x=myTouch.getX();
    int y=myTouch.getY();
    
    if ((y>=90) && (y<=118))  // Upper row
    {
      if((pressureOne >= -101.3) && (pressureOne <= 101.3)){ 
        if ((x>=170) && (x<=198))  // Button: P1 +
        {
//          calculateVal();
          pressureOne += 0.1;
          waitForIt(170, 90, 198, 118);                    
//          convOne=dtostrf(pressureOne,4,1,stpOne);
        }
        if ((x>=206) && (x<=234))  // Button: P1 -
        {
          pressureOne -= 0.1;
          waitForIt(206, 90, 234, 118);          
//          convOne=dtostrf(pressureOne,4,1,stpOne);
        }
      }
    }

    if ((y>=134) && (y<=162))  // Center row
    {
      if((pressureTwo >= -101.3) && (pressureTwo <= 101.3)){
        if ((x>=170) && (x<=198))  // Button: P2 +
        {
          pressureTwo += 0.1;
          waitForIt(170, 134, 198, 162);          
//          convTwo=dtostrf(pressureTwo,4,1,stpTwo);
        }
        if ((x>=206) && (x<=234))  // Button: P2 -
        {
          pressureTwo -= 0.1;
          waitForIt(206, 134, 234, 162);          
//          convTwo=dtostrf(pressureTwo,4,1,stpTwo);
        }
      }
    }
    
//    myGLCD.print("     ", 40, 96);
    
//    myGLCD.printNumF(pressureOne, 1, 40, 96, 46, 6, 32);
//    myGLCD.printNumF(pressureTwo, 1, 40, 140, 46, 6, 32);
    
    calculateVal();
    processTouch();
  }  
}

// Draw a red frame while a button is touched
void waitForIt(int x1, int y1, int x2, int y2)
{
  myGLCD.setColor(255, 0, 0);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
  while (myTouch.dataAvailable())
    myTouch.read();
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
}

/*************************
**  Required functions  **
*************************/

void setup()
{
// Initial setup
  myGLCD.InitLCD(PORTRAIT);
  myGLCD.clrScr();

  myTouch.InitTouch(PORTRAIT);
  myTouch.setPrecision(PREC_MEDIUM); 
  
  // Logo with white fill
  myGLCD.setColor(255, 255, 255); 
  myGLCD.fillRect(0, 0, 239, 73);
  myGLCD.drawBitmap(35, 5, 171, 63, logo, 0, 0, 0);
  
  // Setup, Gray fill
  myGLCD.setColor(192, 192, 192); 
  myGLCD.fillRect(0, 73, 239, 178);
  
  // Home, White fill
  myGLCD.setColor(255, 255, 255); 
  myGLCD.fillRect(0, 290, 239, 319);
  
  drawButtons();
}

void loop()
{     
  myGLCD.setFont(BigFont);
  
  myGLCD.setColor(0, 112, 185);
  
  myGLCD.setBackColor(255, 255, 255);  
  myGLCD.print("HOME" , 87, 298, 0);
  
  myGLCD.setBackColor(192, 192, 192);  
  myGLCD.print("P1 " , 3, 96, 0);
  myGLCD.print("P2 " , 3, 140, 0);  
 
  myGLCD.setFont(SmallFont);
  
  myGLCD.setColor(0, 0, 0);
  myGLCD.print(" kPa" , 133, 99, 0);
  myGLCD.print(" kPa" , 133, 143, 0);
  
  
  while(true)
  {   
    startTime = millis();
 // run measurements for one second and process keypresses during that time
//    while (millis() - startTime < 1000) {
//    while (myTouch.dataAvailable())
//    {
      processTouch();
//    }
    
//    calculateVal();
    
    myGLCD.setFont(BigFont);
    myGLCD.setColor(0, 0, 0);
//    myGLCD.printNumI(test, 40, 156);
//    myGLCD.print(convOne, 40, 96, 0); 
//    myGLCD.print(convTwo, 40, 140, 0);
    
//    myGLCD.printNumF(pressureOne, 1, 40, 96, 46, 6, 32);
//    myGLCD.printNumF(pressureTwo, 1, 40, 140, 46, 6, 32);
  }
}

Forgive me it has a lot of comment since I've been changing and changing the sequence trying to make the (hold) button work.

Add another variable call it something like

float buttonChangeAmount=0.1;

change your code so that

pressureOne += 0.1;

becomes

pressureOne += buttonChangeAmount;

Then write some code to increase buttonChangeAmount the longer the user holds the button down.

e.g.

if (someTimeHasElapsed)
{
buttonChangeAmount *=5;
}

remember when the user releases the button you need to set buttonChangeAmount back to 0.1;

I'll leave exactly when you change buttonChangeAmount up to you.

rogerClark:
Then write some code to increase buttonChangeAmount the longer the user holds the button down.

e.g.

if (someTimeHasElapsed)

{
buttonChangeAmount *=5;
}

Thank you Sir for the reply!
Is the "if (someTimeHasElapsed)" like a blink without delay? where will I put it? in the loop or the function?

I used blink without delay to replace someTimeHasElapsed. I tried it in void loop() and processTouch() but I think that's not the one I'm looking for. The pressure changes after I release the button whilst I want the lcd to be updated every time the user press a button. Example, if you just press the [ + ]/[ - ] it will add/sub 0.1 but if you hold the [ + ]/[ - ] it will continue adding/subtracting 0.1 until the user release the button.

Hi,

I'm new like you, I'm using arduino uno with 4.3" TFT screen and shield.

How did you test your screen? can you give me the code?
I'm failing at testing the screen nothing appears to me..

did you plug the shield to your arduino directly and the screen above it only or you added wire to ground whatsoever??

@Alanood

Hello!
Yes, I plugged the LCD directly to the shield and arduino. You should be using arduino mega 2560 since [correct me if I'm wrong] arduino uno can't handle the tft lcd.

Download the UTFT library here: Electronics - Henning Karlsen
and the UTouch library here: http://www.elabpeers.com/productattachments/index/download?id=130

You can get the code from the examples. Good luck! :wink:


@rogerClark

Sir, do you think its possible?

Actually arduino uno can be used with TFT screen and here are some tutorials

http://tronixstuff.com/2013/04/26/tutorial-arduino-and-ili9325-colour-tft-lcd-modules/#comment-169114

http://tronixstuff.com/2014/02/07/tutorial-arduino-tft-color-touch-screen/

but they're using TFT size 2.8"... the UTFT examples are too big for uno when I tried them (so yes)

now if I used the library that is used for 2.8" I won't get the result since mine is 4.3"?? that's what I'm wondering about! But also when purchasing it was said 4.3" shield for uno :slightly_frowning_face: :slightly_frowning_face:

Hi, I read your PM. My library has basic buttons, touch, latch, and delay.
Touch will return true if the buttons is pressed and held.
Latch will return true if pressed and false when pressed again.
Delay will return true if the button is pressed for a certain duration in millis() -> 0.5 seconds = 500.

What you can do is use the regular Touch button and together with this code, you can get the result you are looking for.

const byte buttonPin1 = 2; // Up button
const byte buttonPin2 = 3; // Down Button
//const int ledPin =  11;

boolean buttonState1 = 0;
boolean lastReading1 = 0;
boolean buttonState2 = 0;
boolean lastReading2 = 0;

unsigned long onTime1 = 0, onTime2 = 0;
unsigned long interval = 1000;
unsigned long holdAmount = 5;
int count = 0, lastCount;

void setup() { 
  //pinMode(ledPin, OUTPUT);      
  pinMode(buttonPin1, INPUT);
  pinMode(buttonPin2, INPUT);

  Serial.begin(115200);  
}

void loop()
{ 
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
  
  if (buttonState1 == HIGH && lastReading1 == LOW)
  {
    onTime1 = millis();
    count < 60 ? count++ : count = 0;
  }
  
  if (buttonState2 == HIGH && lastReading2 == LOW) 
  {
    onTime2 = millis();
    count > 0 ? count-- : count = 59;
  }

  //held UP button
  if (buttonState1 == HIGH && lastReading1 == HIGH) 
  { 
    if ((millis() - onTime1) > interval )    
    {
      onTime1 = millis();
      count < 60? count += holdAmount : count = 0;
      lastReading1 = LOW;
    } 
  }
  
  // held DOWN button
  if (buttonState2 == HIGH && lastReading2 == HIGH) 
  { 
    if ((millis() - onTime2) > interval )
    {
      onTime2 = millis();
      count > 0 ? count -= holdAmount : count = 59;
      lastReading2 = LOW;
    } 
  }
  
  // this prevents the serial monitor from flooding with data
  if(count != lastCount)
  {
   Serial.println(count);
   lastCount = count;
  }
  
  lastReading1 = buttonState1; // Update lastreading 1
  lastReading2 = buttonState2; // Update lastreading 2
}

The code above uses normal tactile buttons, but you can substitute digitalRead(buttonPin1); with myTFT.TouchButton(...); from my library and it should work just fine.

Let me know if you get stuck anywhere.

@HazardsMind

Sir, thank you for the reply!

converted your code to apply on tft lcd

#include <UTFT.h>
#include <UTouch.h>
#include <TFT_Extension.h>


UTFT    myGLCD(ITDB32S,38,39,40,41);
UTouch  myTouch( 6, 5, 4, 3, 2);
TFT_Extension myTFT(&myGLCD, &myTouch, LANDSCAPE);

// Declare which fonts we will be using
extern uint8_t BigFont[];

const byte buttonPin1 = 2; // Up button
const byte buttonPin2 = 3; // Down Button
//const int ledPin =  11;

boolean buttonState1 = 0;
boolean lastReading1 = 0;
boolean buttonState2 = 0;
boolean lastReading2 = 0;

unsigned long onTime1 = 0, onTime2 = 0;
unsigned long interval = 100;
unsigned long holdAmount = 1;
int count = 0, lastCount;

void drawButtons()
{
  myGLCD.setFont(BigFont);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(0, 112, 185);
  
// Draw the upper row of buttons
  myGLCD.setColor(0, 112, 185);
  myGLCD.fillRoundRect (170, 90, 198, 118);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (170, 90, 198, 118);
  myGLCD.print("+", 176, 96, 0);

  myGLCD.setColor(0, 112, 185);
  myGLCD.fillRoundRect (206, 90, 234, 118);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (206, 90, 234, 118);  
  myGLCD.print("-", 212, 96, 0);  
  
  myGLCD.setBackColor (0, 112, 185);
}

// Draw a red frame while a button is touched
void waitForIt(int x1, int y1, int x2, int y2)
{
  myGLCD.setColor(255, 0, 0);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
  while (myTouch.dataAvailable())
    myTouch.read();
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
}

void setup()
{
  // Initial setup
  myGLCD.InitLCD(LANDSCAPE);
  myGLCD.clrScr();

  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_MEDIUM);
  
  // Setup, Gray fill
  myGLCD.setColor(192, 192, 192); 
  myGLCD.fillRect(0, 73, 239, 228);

  drawButtons();  
}

void loop()
{
  myGLCD.setFont(BigFont);  
  myGLCD.setColor(0, 112, 185);
  
  myGLCD.setBackColor(192, 192, 192);  
  myGLCD.print("P1 " , 3, 96, 0);
  
  while(true)
  {    
    if (myTouch.dataAvailable())
    {
      myTouch.read();
      int x=myTouch.getX();
      int y=myTouch.getY();
      
      buttonState1 = myTFT.TouchButton(170, 90, 198, 118);
      buttonState2 = myTFT.TouchButton(206, 90, 234, 118);
      
      myGLCD.printNumI(buttonState1, 40, 140);
      myGLCD.printNumI(buttonState2, 40, 184);
      
      
      if (buttonState1 == HIGH && lastReading1 == LOW)
      {
        onTime1 = millis();
        count < 60 ? count++ : count = 0;
        waitForIt(170, 90, 198, 118);
      }
        
      //held UP button
      if (buttonState1 == HIGH && lastReading1 == HIGH) 
      { 
        if ((millis() - onTime1) > interval )    
        {
          onTime1 = millis();
          count < 60? count += holdAmount : count = 0;
          lastReading1 = LOW;
        }
        waitForIt(170, 90, 198, 118);            
      }

      if (buttonState2 == HIGH && lastReading2 == LOW) 
      {
        onTime2 = millis();
        count > 0 ? count-- : count = 59;
        waitForIt(206, 90, 234, 118);
      }
      
      // held DOWN button
      if (buttonState2 == HIGH && lastReading2 == HIGH) 
      { 
        if ((millis() - onTime2) > interval )
        {
          onTime2 = millis();
          count > 0 ? count -= holdAmount : count = 59;
          lastReading2 = LOW;
        }
        waitForIt(206, 90, 234, 118);            
      }

      
      // this prevents the serial monitor from flooding with data
      if(count != lastCount)
      {    
        myGLCD.setFont(BigFont);
        myGLCD.setColor(0, 0, 0);
        myGLCD.printNumI(count, 40, 96);
        lastCount = count;
      }
    
      lastReading1 = buttonState1; // Update lastreading 1
      lastReading2 = buttonState2; // Update lastreading 2
    }
  }
}

The myTFT.TouchButton() works but I think it's not what I'm looking for (?) Maybe I should use the delay. Can you help me how to set it up**? Also, I want the reading to be updated while I'm holding [ + ] / [ - ] button. Is this possible?

**
Could you, sir, explain this in laymans term? each line?

      if (buttonPress1 == HIGH && lastReading1 == LOW)
      {
        onTime1 = millis();
        count < 60 ? count++ : count = 0;
      }
        
      //held UP button
      if (buttonPress1 == HIGH && lastReading1 == HIGH) 
      { 
        if ((millis() - onTime1) > interval )    
        {
          onTime1 = millis();
          count < 60? count += holdAmount : count = 0;
          lastReading1 = LOW;
        }           
      }

Your waitForit was not allowing the code the to do what is was intended to do. Try this.

//#include <ITDB02_Graph16.h>
//#include <ITDB02_Touch.h>
//#include <TFT_Extension_old.h>
//
//ITDB02 myGLCD(A1, A2, A0, A3, A5, ITDB32S); //myGLCD(RS,WR,CS,RST,ALE,mode);
//ITDB02_Touch  myTouch(13, 10, 11, 12, A4); //myTouch(TCLK,TCS,DIN,DOUT,IRQ);
//TFT_Extension_old myTFT(&myGLCD, &myTouch);

#include <UTFT.h>
#include <UTouch.h>
#include <TFT_Extension.h>


UTFT    myGLCD(ITDB32S,38,39,40,41);
UTouch  myTouch( 6, 5, 4, 3, 2);
TFT_Extension myTFT(&myGLCD, &myTouch, LANDSCAPE);

// Declare which fonts we will be using
extern uint8_t BigFont[];
//const int ledPin =  11;

boolean buttonState1 = 0;
boolean lastReading1 = 0;
boolean buttonState2 = 0;
boolean lastReading2 = 0;

unsigned long onTime1 = 0, onTime2 = 0;
unsigned long interval = 1000;
unsigned long holdAmount = 1;
int count = 0, lastCount;

void drawButtons()
{
  myGLCD.setFont(BigFont);
  myGLCD.setColor(255, 255, 255);
  myGLCD.setBackColor(0, 112, 185);

  // Draw the upper row of buttons
  myGLCD.setColor(0, 112, 185);
  myGLCD.fillRoundRect (170, 90, 198, 118);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (170, 90, 198, 118);
  myGLCD.print("+", 176, 96, 0);

  myGLCD.setColor(0, 112, 185); // blue
  myGLCD.fillRoundRect (206, 90, 234, 118);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (206, 90, 234, 118);
  myGLCD.print("-", 212, 96, 0);

  myGLCD.setBackColor (0, 112, 185);
}

// Draw a red frame while a button is touched
void waitForIt(int x1, int y1, int x2, int y2)
{
  myGLCD.setColor(255, 0, 0);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
  while (myTouch.dataAvailable())
    myTouch.read();
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
}

void setup()
{
  // Initial setup
  myGLCD.InitLCD(LANDSCAPE);
  myGLCD.clrScr();

  myTouch.InitTouch(LANDSCAPE);
  myTouch.setPrecision(PREC_LOW);
  //myTFT.ExtSetup();

  // Setup, Gray fill
  myGLCD.setColor(192, 192, 192);
  myGLCD.fillRect(0, 73, 239, 228);

  drawButtons();
}

void loop()
{
  myGLCD.setFont(BigFont);
  myGLCD.setColor(0, 112, 185);

  myGLCD.setBackColor(192, 192, 192);
  myGLCD.print("P1 " , 3, 96, 0);

  while (true)
  {
    buttonState1 = myTFT.TouchButton(170, 90, 198, 118);
    buttonState2 = myTFT.TouchButton(206, 90, 234, 118);

    myGLCD.printNumI(buttonState1, 40, 140);
    myGLCD.printNumI(buttonState2, 40, 184);


    if (buttonState1 == HIGH && lastReading1 == LOW)
    {
      onTime1 = millis();
      count < 59 ? count++ : count = 0;
      //waitForIt(170, 90, 198, 118);
    }

    //held UP button
    if (buttonState1 == HIGH && lastReading1 == HIGH)
    {
      if ((millis() - onTime1) > interval )
      {
        onTime1 = millis();
        count < 59 ? count += holdAmount : count = 0;
        lastReading1 = LOW;
      }
      //waitForIt(170, 90, 198, 118);
    }

    if (buttonState2 == HIGH && lastReading2 == LOW)
    {
      onTime2 = millis();
      count > 0 ? count-- : count = 59;
      //waitForIt(206, 90, 234, 118);
    }

    // held DOWN button
    if (buttonState2 == HIGH && lastReading2 == HIGH)
    {
      if ((millis() - onTime2) > interval )
      {
        onTime2 = millis();
        count > 0 ? count -= holdAmount : count = 59;
        lastReading2 = LOW;
      }
      //waitForIt(206, 90, 234, 118);
    }


    // this prevents the serial monitor from flooding with data
    if (count != lastCount)
    {
      myGLCD.setFont(BigFont);
      myGLCD.setColor(0, 0, 0);
      myGLCD.printNumI(count, 40, 96);
      lastCount = count;
    }

    lastReading1 = buttonState1; // Update lastreading 1
    lastReading2 = buttonState2; // Update lastreading 2
  }
}

I recommend you download my latest library version, CLICK HERE

Downloaded your latest library

I'm now getting this error:
no matching function for call to 'TFT_Extension::TFT_Extension(UTFT*, UTouch*, int)'

I'm using Arduino 1.0.5

Am I doing something wrong?

You don't need have landscape or portrait anymore in the constructor, so now it is just TFT_Extension myTFT(&myGLCD, &myTouch);

And you also need to add in myTFT.ExtSetup(); directly under myTouch.setPrecision(PREC_LOW);

Once you do that, you shouldn't have anymore errors

No more errors! The code is working like described! It adds/sub when I press a button and it continuously add/sub when I hold it. And it also updates the value on screen.

Really nice! Thank you very much sir HazardsMind! :smiley:

I recommend you to download TFT_Extension library :wink: It's very easy to use

arduinoTime:
No more errors! The code is working like described! It adds/sub when I press a button and it continuously add/sub when I hold it. And it also updates the value on screen.

Really nice! Thank you very much sir HazardsMind! :smiley:

I recommend you to download TFT_Extension library :wink: It's very easy to use

Hello!

I used the code above with 3.2" TFT screen and arduino mega,
I removed landscape from TFT_Extension myTFT(&myGLCD, &myTouch); only and left the others,
I added myTFT.ExtSetup(); directly under myTouch.setPrecision(PREC_LOW);

But I got this weird error:
Sketch too big
(Binary sketch size: 36,374 bytes (of a 32,256 byte maximum)) !
why would it appear when I'm using Mega?? :slightly_frowning_face:

Ok sorry I solved it!

going to tools -> Board -> choose mega (it was uno)