Help with shorting tft lcd print code

I have this repetitive code that just print some variables on lcd, how could i shorten this ?

    tft.setCursor(150, 40);
    tft.setTextSize(3);
    tft.setTextColor(ILI9341_WHITE);
    tft.print(Input_Current);
    tft.println("A");

    tft.setCursor(250, 0);
    tft.setTextSize(1);
    tft.setTextColor(ILI9341_GREEN);
    tft.print(Thermistor1);
    tft.println("°C");

Make it a function?

Change the name of the tft object to just t?

What are you trying to do with the code you didn't post?

make a macro

1 Like

A macro like this:

#define show(X, Y, Size, Color, Variable, Label) \
  do {                       \
    tft.setCursor(X, Y);     \
    tft.setTextSize(Size);   \
    tft.setTextColor(Color); \
    tft.print(Variable);     \
    tft.println(Label);      \
  } while (false)

show(150, 40, 3, ILI9341_WHITE, Input_Current, "A");
show(250,  0, 1, ILI9341_GREEN, Thermistor1,   "°C");

Yes, thanks so much this is exactly what i was looking for, but i forgot what it was called already :grin: