Compile error for LCD Screen

I have opened an example in the IDE(1.8.9) of Arduino TouchScreen buttons and when I try to compile it gives me an error code, I thought I had loaded all libraries applicable to the Sketch but I can’t seem to figure out what exactly is missing, I have added the following libraries

Adafruit_TouchScreen
Arduino-TouchScreen-Buttons-master
Arduino-TouchScreen-Geometry-master
Arduino-TouchScreen-Strings-master

I get this error message when I try to compile

///////////////////////////////////////////////////////////////////////////
Arduino: 1.8.9 (Mac OS X), Board: “Arduino/Genuino Uno”

radio_buttons_example:38:30: error: ‘XP’ was not declared in this scope
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
^
radio_buttons_example:38:34: error: ‘YP’ was not declared in this scope
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
^
radio_buttons_example:38:38: error: ‘XM’ was not declared in this scope
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
^
radio_buttons_example:38:42: error: ‘YM’ was not declared in this scope
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
^
radio_buttons_example:41:34: error: ‘WHITE’ was not declared in this scope
RadioButton radioButton1(50, 50, WHITE, RED);
^
radio_buttons_example:41:41: error: ‘RED’ was not declared in this scope
RadioButton radioButton1(50, 50, WHITE, RED);
^
radio_buttons_example:42:34: error: ‘WHITE’ was not declared in this scope
RadioButton radioButton2(50, 75, WHITE, YELLOW);
^
radio_buttons_example:42:41: error: ‘YELLOW’ was not declared in this scope
RadioButton radioButton2(50, 75, WHITE, YELLOW);
^
radio_buttons_example:43:35: error: ‘WHITE’ was not declared in this scope
RadioButton radioButton3(50, 100, WHITE, GREEN);
^
radio_buttons_example:43:42: error: ‘GREEN’ was not declared in this scope
RadioButton radioButton3(50, 100, WHITE, GREEN);
^
/Users/glennholberg/Documents/Arduino/libraries/Arduino-TouchScreen-Buttons-master/examples/radio_buttons_example/radio_buttons_example.ino: In function ‘void setup()’:
radio_buttons_example:53:3: error: ‘Tft’ was not declared in this scope
Tft.init();
^
/Users/glennholberg/Documents/Arduino/libraries/Arduino-TouchScreen-Buttons-master/examples/radio_buttons_example/radio_buttons_example.ino: In function ‘void loop()’:
radio_buttons_example:68:3: error: ‘Point’ was not declared in this scope
Point p = ts.getPoint();
^
radio_buttons_example:69:3: error: ‘p’ was not declared in this scope
p.x = map(p.x, TS_MINX, TS_MAXX, 240, 0);
^
exit status 1
‘XP’ was not declared in this scope
///////////////////////////////////////////////////////////////

Any clues to what I’m missing would be appreciated.

Here is the example from the IDE

/* 
  Title: TouchScreenRadioButton Tutorial
  About: Example/tutorial file for how to create radio buttons with the TouchScreenRadioButtons library
  Author: Richard Kirkpatrick
  Date: 20 July 2014
*/

// Libraries
#include <stdint.h>  
#include <TouchScreen.h>  // Library for the Seeed Studio TFT Touch Shield 
#include <TFT.h>      // Library for the Seeed Studio TFT Touch Shield 
#include <TouchScreenButtons.h> // Library for creating buttons for the keypad

#ifdef SEEEDUINO
  #define YP A2   // must be an analog pin, use "An" notation!
  #define XM A1   // must be an analog pin, use "An" notation!
  #define YM 14   // can be a digital pin, this is A0
  #define XP 17   // can be a digital pin, this is A3 
#endif

#ifdef MEGA
  #define YP A2   // must be an analog pin, use "An" notation!
  #define XM A1   // must be an analog pin, use "An" notation!
  #define YM 54   // can be a digital pin, this is A0
  #define XP 57   // can be a digital pin, this is A3 
#endif 

//Measured ADC values for (0,0) and (210-1,320-1)
//TS_MINX corresponds to ADC value when X = 0
//TS_MINY corresponds to ADC value when Y = 0
//TS_MAXX corresponds to ADC value when X = 240 -1
//TS_MAXY corresponds to ADC value when Y = 320 -1
#define TS_MINX 140
#define TS_MAXX 900
#define TS_MINY 120
#define TS_MAXY 940

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

// Global variables
RadioButton radioButton1(50, 50, WHITE, RED);
RadioButton radioButton2(50, 75, WHITE, YELLOW);
RadioButton radioButton3(50, 100, WHITE, GREEN);

boolean buttonState1 = false;
boolean buttonState2 = false;
boolean buttonState3 = false;


void setup()
{
  // Initializes the TFT library
  Tft.init();      
 
  // Start the Serial port. Used to determine which button was pressed.
  Serial.begin(9600); 
  
  // Draw the radio buttons
  radioButton1.draw();
  radioButton2.draw();
  radioButton3.draw(); 
}


void loop()
{
  // A point objects holds x, y, and z coordinates
  Point p = ts.getPoint(); 
  p.x = map(p.x, TS_MINX, TS_MAXX, 240, 0);
  p.y = map(p.y, TS_MINY, TS_MAXY, 320, 0);
  
  // Determine which button was pressed
  int userInput = -1; // -1 means no button is pressed.  Resets for each loop.
  if (p.z > ts.pressureThreshhold) 
    userInput = getButtonNumber(p.x, p.y); 
  
  // Show which button was pressed on the Serial monitor
  if (userInput >= 1 && userInput <= 3) {
    Serial.print("Radio Button #: ");
    Serial.println(userInput);
    Serial.print("Radio Button #'s State: ");
    Serial.print(radioButton1.getButtonState());
    Serial.print(radioButton2.getButtonState());
    Serial.println(radioButton3.getButtonState());
  }
  
  delay(50);
}


// Determines which radio button was pressed
const int getButtonNumber(const int xInput, const int yInput)
{
  if (radioButton1.isButtonPressed(xInput, yInput)) {
    radioButton1.resetButtonState();
    return 1;
  } else if (radioButton2.isButtonPressed(xInput, yInput)) {
    radioButton2.resetButtonState();  
    return 2;
  } else if (radioButton3.isButtonPressed(xInput, yInput)) {
    radioButton3.resetButtonState();
    return 3; 
  } else {
    return -1; // signified no button was pressed
  }
}

For a start, XP, YP, XM & YM are defined only if one of the following board types ( I presume) is defined:
Seeduino or Mega.

Maybe post a link to the example or tutorial you have found.

6v6gt:
For a start, XP, YP, XM & YM are defined only if one of the following board types ( I presume) is defined:
Seeduino or Mega.

Maybe post a link to the example or tutorial you have found.

I was looking for a way to do a type of radio button on my LCD and came across this GitHub download and thought I would play with it to see if it is what I'm looking for.

Radio Button

When I looked at the Button library I saw the other 2 libraries (Arduino-TouchScreen-Geometry-master,
Arduino-TouchScreen-Strings-master) so I loaded them also and brought up the examples that came with the button library to play with and then got the compile error.

I haven't tried to upload to any controller(Mega or Seeeduino) and just didn't know why it wouldn't compile.

OK, this is quite a messy situation.

ribbonman:

radio_buttons_example:38:30: error: 'XP' was not declared in this scope

TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
                             ^
radio_buttons_example:38:34: error: ‘YP’ was not declared in this scope
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
                                 ^
radio_buttons_example:38:38: error: ‘XM’ was not declared in this scope
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
                                     ^
radio_buttons_example:38:42: error: ‘YM’ was not declared in this scope
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);
                                         ^
radio_buttons_example:41:34: error: ‘WHITE’ was not declared in this scope
RadioButton radioButton1(50, 50, WHITE, RED);
                                 ^
radio_buttons_example:41:41: error: ‘RED’ was not declared in this scope
RadioButton radioButton1(50, 50, WHITE, RED);
                                        ^
radio_buttons_example:42:34: error: ‘WHITE’ was not declared in this scope
RadioButton radioButton2(50, 75, WHITE, YELLOW);
                                 ^
radio_buttons_example:42:41: error: ‘YELLOW’ was not declared in this scope
RadioButton radioButton2(50, 75, WHITE, YELLOW);
                                        ^
radio_buttons_example:43:35: error: ‘WHITE’ was not declared in this scope
RadioButton radioButton3(50, 100, WHITE, GREEN);
                                  ^
radio_buttons_example:43:42: error: ‘GREEN’ was not declared in this scope
RadioButton radioButton3(50, 100, WHITE, GREEN);
                                         ^
/Users/glennholberg/Documents/Arduino/libraries/Arduino-TouchScreen-Buttons-master/examples/radio_buttons_example/radio_buttons_example.ino: In function ‘void setup()’:
radio_buttons_example:53:3: error: ‘Tft’ was not declared in this scope
  Tft.init();      
  ^

These errors are all caused by using the wrong TFT library. The code is written for the Seeed Studio TFT Touch Shield V1.0 library. Unfortunately, Seeed made the horrible decision of naming the header file of that library “TFT.h”. The official Arduino TFT library, which comes bundled with the Arduino IDE, has a header file of the same name. This means that, even after you install the Seeed Studio TFT Touch Shield V1.0 library, the Arduino IDE will continue to use the official Arduino TFT library, which is not compatible with this code. Here’s the least invasive solution:

  • Download the latest release of the Seeed Studio TFT Touch Shield V1.0 library: https://github.com/Seeed-Studio/TFT_Touch_Shield_V1/archive/1.0.2.zip
  • Unzip the downloaded file.
  • In the unzipped folder, create a file named TFT_Touch_Shield_V1.h. The file can be blank, it just needs to be present in that folder.
  • (In the Arduino IDE) Sketch > Include Library > Add .ZIP Library
  • Select the unzipped folder (NOT the downloaded .zip file).
  • Click the “Open” button.

Now you have installed the correct library with a unique header file added. The purpose of the added file is to force the Arduino IDE to use the correct library. You do this by adding this line before the #include directive for TFT.h:

#include <TFT_Touch_Shield_V1.h>

The Seeed Studio TFT Touch Shield V1.0 library defines the SEEEDUINO macro so these pin definitions will be used:

#ifdef SEEEDUINO
  #define YP A2   // must be an analog pin, use "An" notation!
  #define XM A1   // must be an analog pin, use "An" notation!
  #define YM 14   // can be a digital pin, this is A0
  #define XP 17   // can be a digital pin, this is A3 
#endif

You need to modify those pin numbers according to how you have your TFT wired to your Arduino board. Note that the first two must be analog pins.

Now for the next batch of errors, which have a completely different cause:

ribbonman:

/Users/glennholberg/Documents/Arduino/libraries/Arduino-TouchScreen-Buttons-master/examples/radio_buttons_example/radio_buttons_example.ino: In function 'void loop()':

radio_buttons_example:68:3: error: ‘Point’ was not declared in this scope
  Point p = ts.getPoint();
  ^
radio_buttons_example:69:3: error: ‘p’ was not declared in this scope
  p.x = map(p.x, TS_MINX, TS_MAXX, 240, 0);

The Adafruit Touchscreen’s Point class was renamed TSPoint five years ago. Since you’re using a modern version of the Touchscreen library, you’ll need to change line 69 from:

 Point p = ts.getPoint();

to:

 TSPoint p = ts.getPoint();

After that, the sketch should compile.

Thanks pert, I knew it had something to do with the libraries I just thought it was 1 not 2 libraries.

I realized the IDE was grabbing the wrong TFT.h file so I removed the TFT file that is in the app and installed the seeed v1 TFT and that cleared that problem but then I had the problem with the "Point p = ts.getPoint();" and it was late and reading code with tired eyes just doesn't work when you are looking for a needle in a haystack.

I might be better off using the up to date Adafruit libraries for the LCD screen and just mimic the way the Seeed button examples work.

I like the way if you have multiple buttons when you press one the other reverts back to different color if it was the last one pressed before the new press.

ribbonman:
I realized the IDE was grabbing the wrong TFT.h file so I removed the TFT file that is in the app and installed the seeed v1 TFT and that cleared that problem

That's a good solution too. I chose the one I recommended in my previous reply because I hesitate to recommend deleting files unless absolutely necessary, since it's possible someone might get the instructions wrong and accidentally delete irreplaceable files.

pert:
That's a good solution too. I chose the one I recommended in my previous reply because I hesitate to recommend deleting files unless absolutely necessary, since it's possible someone might get the instructions wrong and accidentally delete irreplaceable files.

I don't like deleting files in the app either, I copied it back in and added the V1 file like your instructions and installed it and everything compiles now but since I'm using an Adafruit LCD shield the pinouts are different than the Seeed, it connects using ICSP so no analog pins as with the seeed.

Hopefully I can adapt the seeed code for how the buttons operate with respect to changing back to original color when another button is pressed over to the Adafruit code that the screen runs on. Right now it's a wish with no knowledge on how to accomplish it. LOL