Stuck between two unescapable errors


#include <Adafruit_TFTLCD.h> 
#include <Adafruit_GFX.h>    
#include <TouchScreen.h>

#define LCD_CS A3 
#define LCD_CD A2 
#define LCD_WR A1 
#define LCD_RD A0 
#define LCD_RESET A4 

#define TS_MINX 122
#define TS_MINY 111
#define TS_MAXX 1016
#define TS_MAXY 993

#define YP A3
#define XM A2
#define YM 9
#define XP 8

#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF


TouchScreen ts = TouchScreen(XP, YP, XM, YM, 364);

boolean buttonEnabled = true;

void setup() {
  uint16_t identifier = tft.readID();
  tft.print("TFT LCD Touch Screen");
  tft.print("Tutorial\n\n            by");
  tft.print("Mert Arduino and Tech");
  tft.fillRect(50,180, 210, 40, RED);
  tft.print("Please Subscribe");


void loop() {
  TSPoint p = ts.getPoint();
  if (p.z > ts.pressureThreshhold) {
   p.x = map(p.x, TS_MAXX, TS_MINX, 0, 320);
   p.y = map(p.y, TS_MAXY, TS_MINY, 0, 480);
   if(p.x>50 && p.x<260 && p.y>180 && p.y<270 && buttonEnabled){
    buttonEnabled = false;
    pinMode(XM, OUTPUT);
    pinMode(YP, OUTPUT);
    tft.print(" Thank you\n\n       for\n\n     your\n\n     support!");

So i want to have tft.setTextSize in my code, but it said “error: textsize not declared in scope.”. so i read some forums and they told them to move the code outside of loop and/or setup. so i did. i then tried to upload again and got “error: tft does not name a type.”. i read more forums on it and said “put it in setup/loop”. now i know im going to get an error one way or another. more people (including the youtuber i got the code from) have succeeded, and all i changed was adding “your” to the last message.

Please post the exact error message.

C/C++ is case sensitive.

Is Adafruit_TFTLCD.h still current? I thought that file was long gone.

-jim lee

The error is in the TFTLCD library:

.../Arduino/libraries/Adafruit_TFTLCD_Library/Adafruit_TFTLCD.cpp: In member function 'void Adafruit_TFTLCD::init()':
.../Arduino/libraries/Adafruit_TFTLCD_Library/Adafruit_TFTLCD.cpp:115:3: error: 'textsize' was not declared in this scope
   textsize = 1;
.../Arduino/libraries/Adafruit_TFTLCD_Library/Adafruit_TFTLCD.cpp:115:3: note: suggested alternative: 'textsize_x'
   textsize = 1;

This is/was inherited from base class Adafruit_GFX which now has textsize_x and textsize_y instead of textsize.

To fix change line 115 in Adafruit_TFTLCD.cpp to   textsize_x = textsize_y = 1;