Here is the code. Library is <MCUFRIEND_kbv.h>
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;Â Â Â // hard-wired for UNO shields anyway.
#include <Fonts/Redressed_Regular_25.h>
uint16_t ID;
uint8_t Orientation = 1; // ZERO or ONE
// Assign human-readable names to some common 16-bit color values:
#define BLACKÂ 0x0000
#define MAGENTA 0xF81F
#define WHITEÂ 0xFFFF
int i = 0;
long oldPosition = -999;
uint16_t required_mL = 500, oldIntVal, intInput;
int16_t temp, encReading;
float setE = 2.0, oldFloatVal, floatInput;
float setInhalationTime = 1.3; // /Keep Initial Value always at one decimal place. I mean ACTUALY keep it! NO 1.33 or 1.333 sort of stuff.
uint16_t allowablePeakPressure = 30, setBPM = 15;
float setPEEP = 5.0;
int mL=required_mL, peakFlow=23, peakPressure=allowablePeakPressure, BPM=setBPM, pwm=255;
float E=setE, inhalationTime=setInhalationTime, PEEP=setPEEP;
unsigned long t;
bool indicator;
void setup()
{
 Serial.begin(57600);
 Â
 tft.reset();
 ID = tft.readID();
 tft.begin(ID);
 tft.setRotation(Orientation);
 tft.fillScreen(BLACK);
 delay(100);
Â
 tft.setFont(&Redressed_Regular_25);
Â
 tft.setTextColor(WHITE); //(textColor, HighLightColor)
 tft.setTextSize(3);
 tft.setCursor(25, 170); //(x, y) OR (horizontal, vertical)
 tft.print("Initialization");
Â
 delay(2000);
 tft.setTextColor(BLACK); //(textColor, HighLightColor)
 tft.setCursor(25, 170); //(x, y) OR (horizontal, vertical)
 tft.print("Initialization");
Â
 //_____________________________________________________________________
 // ____________________________________________________ Rectangles
 tft.fillRect(0,0, 150, 95, WHITE); //(x0, y0, width, height, color)
 tft.fillRect(0,110, 150, 95, WHITE);
 tft.fillRect(0,220, 150, 95, WHITE);
Â
 tft.fillRect(165,0, 150, 95, WHITE);
 tft.fillRect(165,110, 150, 95, WHITE);
 tft.fillRect(165,220, 150, 95, WHITE);
 tft.fillRect(330,0, 150, 95, WHITE);
 tft.fillRect(330,110, 150, 95, WHITE);
 tft.fillRect(330,220, 150, 95, WHITE);
 //_____________________________________________________________________
 // ____________________________________________________ Tidal Volume
 //tft.fillRect(0,0, 150, 95, WHITE);
 tft.setTextSize(1);
 tft.setCursor(33, 27);
 tft.print("Vt(mL)");
Â
 tft.setTextSize(2);
 tft.setCursor(20, 80);
 tft.print(required_mL);
 // ____________________________________________________ I:E
 //tft.fillRect(0,110, 150, 95, WHITE);
 tft.setTextSize(1);
 tft.setCursor(58, 137);
 tft.print("I:E");
 tft.setTextSize(2);
 tft.setCursor(17, 190);
 tft.print("1:");
 tft.setCursor(52, 190);
 tft.print(setE, 1);
Â
 // ____________________________________________________ RR
 //tft.fillRect(0,220, 150, 95, WHITE);
 tft.setTextSize(1);
 tft.setCursor(20, 247);
 tft.print("RR(BPM)");
 tft.setTextSize(2);
 tft.setCursor(47, 300);
 tft.print(setBPM);
 //_____________________________________________________________________
 // ____________________________________________________ Ppeak
 //tft.fillRect(330,0, 150, 95, WHITE);
 tft.setTextSize(1);
 tft.setCursor(332, 27);
 tft.print("PIP(cmH2O)");
 tft.setTextSize(2);
 tft.setCursor(380, 80);
 tft.print(allowablePeakPressure);
Â
 // ____________________________________________________ Ti
 //tft.fillRect(330,110, 150, 95, WHITE);
 tft.setTextSize(1);
 tft.setCursor(373, 137);
 tft.print("Ti(sec)");
 tft.setTextSize(2);
 tft.setCursor(375, 190);
 tft.print(setInhalationTime, 1);
 // ____________________________________________________ PEEP
 //tft.fillRect(330,220, 150, 95, WHITE);
 tft.setTextSize(1);
 tft.setCursor(377, 247);
 tft.print("PEEP");
 tft.setTextSize(2);
 tft.setCursor(375, 300);
 tft.print(setPEEP, 1);
 //_____________________________________________________________________
 // ____________________________________________________ PIF
 //tft.fillRect(165,0, 150, 95, WHITE);
 tft.setTextSize(1);
 tft.setCursor(180, 27);
 tft.print("PIF(LPM)");
 tft.setTextSize(2);
 tft.setCursor(215, 80);
 tft.print("00");
Â
 pinMode(13, INPUT_PULLUP);
}
void loop()
{
  delay(1000);
 Â
  t = millis();
  printTFT();
  Serial.println(millis()-t);
}
// This takes 160 MILLI-seconds on Arduino-UNO
// And takes 362 MILLI-seconds on Mega :/
// It is more than double :/
void printTFT()
{
  // ____________________________________________________ Vt
  tft.fillRect(18,40, 115, 45, MAGENTA);
  tft.setCursor(20, 80);
  tft.print(mL);
  // ____________________________________________________ I:E
  tft.fillRect(50,150, 90, 45, MAGENTA);
  tft.setCursor(52, 190);
  tft.print(E, 1);
  // ____________________________________________________ RR
  tft.fillRect(45,260, 80, 45, MAGENTA);
  tft.setCursor(47, 300);
  tft.print(BPM);
 Â
  // ____________________________________________________ PIF
  tft.fillRect(213, 40, 80, 45, MAGENTA);
  tft.setCursor(215, 80);
  tft.print(peakFlow);
 Â
  // ____________________________________________________ PIP
  tft.fillRect(378, 40, 80, 45, MAGENTA);
  tft.setCursor(380, 80);
  tft.print(peakPressure);
  // ____________________________________________________ Ti
  tft.fillRect(373, 150, 90, 45, MAGENTA);
  tft.setCursor(375, 190);
  tft.print(inhalationTime, 1);
  // ____________________________________________________ PEEP
  tft.fillRect(373,260, 90, 45, MAGENTA);
  tft.setCursor(375, 300);
  tft.print(PEEP, 1);
}