UNO with 3.95 TFT ili9488 touch and graphics

I have a 3.95" tft and it reports that it is an ili9488 using readID.
I am using it with an UNO R3 and have the MCUFRIEND_kbv and TouchScreen classes

I can get the touch working or I can update the screen in the loop but I cannot get both working at the same time. Code below.

The reason for the guard clause is I don't want the screen constantly flashing with updates.

if I comment out the line to getPoint then the screen will update the clock time. If I leave the getPoint then I can get the point information but the screen will not update the clock.

Can someone point me in the appropriate direction to get this working?

Thanks,

int i=0;
void loop()
{

 if(i == 55000)
 {
   generateTimeDisplay();
   i=-1;
 }
 i++;
 pinMode(13, OUTPUT);
 digitalWrite(13, HIGH);
 TSPoint p = ts.getPoint();
 digitalWrite(13, LOW);
}


char bufback[32] = {""};
void generateTimeDisplay()
{

// prepare the new text to display
  time_t ptm = now();
  char buf[32];
  snprintf(buf, 32, "%.2d/%.2d/%d %.2d:%.2d:%.2d", month(ptm),day(ptm),year(ptm),hour(ptm),minute(ptm),second(ptm));

 

  // clear the old text from the screen
  tft.setCursor(50,80);
    tft.setTextColor(BLACK);
    tft.setTextSize(2);
    tft.println(bufback);

// put the new text on screen
  tft.setCursor( 50, 80);
    tft.setTextColor(WHITE);  
    tft.setTextSize(2);
    tft.println(buf);


// set the back buffer to the current text
    snprintf(bufback, 32, "%.2d/%.2d/%d %.2d:%.2d:%.2d", month(ptm),day(ptm),year(ptm),hour(ptm),minute(ptm),second(ptm));
    
}

I got a bit further in figuring this out. It appears that the touch and MCUFriend libs share the A2 and A3 pins. I am reviewing the register sets to identify if registers are over written as well.

I may have to reset registers when toggling between pushing graphics or reading the touch points from the buffer.

I will update this thread as I figure things out.

I think you will find that the Touch shares A1, A2 with the TFT on most mcufriend shields.
The example tftpaint.ino explicitly makes A1, A2 (YP, XM) pins OUTPUT after every call to ts.getPoint().

You will need to do the same with any of your programs that use Touchscreen and MCUFRIEND_kbv.

In an ideal world, the Touchscreen driver would restore the state of YP, XM in its method()s.
OTOH, most Touchscreen apps do not share pins. So it seems sensible to leave it to the "shared" app.

Incidentally, the Touchscreen is often connected differently for the 2.4" shields. e.g. you might have to swap X, Y or direction.
The Touch and TFT work fine with the UNO or MEGA2560. The Touchscreen is VERY flaky on DUE and ZERO.

David.

Thanks David,

I had tried the standard paint.ino and could not get that working. Figured it was the board. I found a tftpaint2_9327 and that sort of works. The coordinates are off and I only have access to the color red but the touch and screen updates are working. I will continue to modify this one till I get what I want. Thanks for your help and explanation.

Try the tftpaint.ino example(s) that come with the MCUFRIEND_kbv library.