Help Compiling

Hello All,

This is my first time on the forums and while I’ve been able to figure out most of my compiling errors from google this one I can’t seem to find. To help as much as possible, for those on the site, here is the error message every time I try and Verify my code;

Arduino: 1.6.9 (Windows 10), Board: “Arduino/Genuino Uno”

Build options changed, rebuilding all
TFTuke:37: error: ‘Adafruit_STMPE610’ does not name a type

Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS);

^

C:\Users\Charles\Desktop\TFTuke\TFTuke.ino: In function ‘void setup()’:

TFTuke:76: error: ‘ts’ was not declared in this scope

if (!ts.begin())

^

C:\Users\Charles\Desktop\TFTuke\TFTuke.ino: In function ‘void loop()’:

TFTuke:115: error: ‘ts’ was not declared in this scope

if (!ts.bufferEmpty())

^

exit status 1
‘Adafruit_STMPE610’ does not name a type

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

If i write in #include <Adafruit_STMPE610.h> at the top the error message changes to this;

Arduino: 1.6.9 (Windows 10), Board: “Arduino/Genuino Uno”

In file included from C:\Users\Charles\Desktop\TFTuke\TFTuke.ino:24:0:

C:\Users\Charles\Documents\Arduino\libraries\Adafruit_FT6206/Adafruit_FT6206.h:49:7: error: redefinition of ‘class TS_Point’

class TS_Point {

^

In file included from C:\Users\Charles\Desktop\TFTuke\TFTuke.ino:23:0:

C:\Users\Charles\Documents\Arduino\libraries\Adafruit_STMPE610/Adafruit_STMPE610.h:116:7: error: previous definition of ‘class TS_Point’

class TS_Point {

^

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

From what I understand from reading up on other people who have had similar issues including both libraries will output this error because it can’t determine which one to pick from for the definition of “class TS_Point”

Any help would be greatly appreciated and if you would like the entire code let me know.
Thanks,

Charles

Welcome,

Need to see full code, an error might be above the indicated line.

The example worked ?

Please, you must show us your complete sketch. Attach your code using the </> icon on the left side of the posting menu.
Put your sketch between the code tags [code][/code]

TFTuke:37: error: 'Adafruit_STMPE610' does not name a type

99.9% of the time, that error is preceded by one that says that Adafruit_STMPE610.h was not found, which means that you failed to download or properly install a library.

#include <Adafruit_GFX.h> 
#include <SPI.h> 
#include <Wire.h> 
#include <Adafruit_ILI9341.h> 
#include <Adafruit_STMPE610.h>
#include <Adafruit_FT6206.h> 



#define TS_MINX 150 
#define TS_MINY 130
#define TS_MAXX 3800
#define TS_MAXY 4000

// pin definitions for touch screen
#define STMPE_CS 8 
#define TFT_CS 10
#define TFT_DC 9

Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS);
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

const int keyCount = 4;

// definition of struct Key (re struct see http://playground.arduino.cc/Code/Struct )
// Key object with frequency, x screen coordinate, and name (i.e. G, C, E, and A - the notes used for this ukulele tuning)
struct Key 
{
  int freq; 
  int x;
  char name;
};

// array of structures holding data about each key
// (frequency, x- screen coordinate, note name)
Key keys[] =
{
  { 392, 20, 'G'  },
  { 261, 90, 'C'  },
  { 329, 160, 'E'  },
  { 440, 230, 'A'  }
};

#define note_Y 50 // the y coordinate for drawing notes on screen
#define note_W 60 // note width on screen
#define note_H 100 // note height on screen

// piezo buzzer is connected to Arduino A0 and to ground
int buzzerPin= A0;

// duration that note plays and delay between notes
int duration = 500;
int del = 100;

void setup(void)
{
  Serial.begin(9600);
  tft.begin();
  if (!ts.begin()) 
  { 
    Serial.println("Unable to start touchscreen.");
  } 
  else 
  { 
    Serial.println("Touchscreen started."); 
  }
  tft.setTextColor(ILI9341_GREEN);
  tft.setTextSize(3);
  tft.setRotation(1); // 'landscape' screen rotation
  tft.fillScreen(ILI9341_BLACK);

  // Outline the keys
  for (int i = 0; i < keyCount; i++)
  {
    tft.drawRoundRect(keys[i].x + 5, note_Y+ 5, note_W - 10, note_H - 10, 10, ILI9341_BLUE);
    tft.drawRoundRect(keys[i].x, note_Y, note_W, note_H, 10,ILI9341_GREEN);
  }

  // Print note names on keys
  for (int i = 0; i < keyCount; i++)
  {
    tft.setCursor(keys[i].x + 22, note_Y + 10);
    tft.print(keys[i].name);
  }

  // print title 
  tft.drawRoundRect (70, 170, 180, 60, 10, ILI9341_WHITE);
  tft.drawRoundRect (75, 175, 170, 50, 10, ILI9341_WHITE);
  tft.setCursor(90, 190);
  tft.setTextColor(ILI9341_BLUE);
  tft.println("UKE TUNE");

}

void loop()
{
  // See if there are touch data
  if (!ts.bufferEmpty())
  {   
    // Retrieve a point  
    TS_Point p = ts.getPoint(); 
    // Scale using the calibration #'s
    // and rotate coordinate system
    p.x = map(p.x, TS_MINY, TS_MAXY, 0, tft.height());
    p.y = map(p.y, TS_MINX, TS_MAXX, 0, tft.width());
    int y = tft.height() - p.x;
    int x = p.y;


    // screen touch handler
    for (int i = 0; i < keyCount; i++)
    {
      if ((x > keys[i].x) && (x < (keys[i].x + note_W)))
      {
        if ((y > note_Y) && (y < (note_Y + note_H)))
        {
          playNote(keys[i].freq);
        }
      }
    }
  } 
}

void playNote(int f)
{
  {
    tone(buzzerPin, f, duration);
    delay(del);
  }
}

Here is the full code that I am working with in reference to my libraries the Adafruit_STMPE610.h is stored in my library folder and the .cpp file comes before the .h. I can try and redownload the library then add it back to the Arduino folder for LarryD’s suggestion.

What is the name of the folder?

Well with Arduino 1.6.9 the directory it creates is This PC>Documents>Arduino>Libraries
Inside that folder I have as follows in the attached image

did you re-start the Arduino ide after you put that library in that folder ?

Yes, I uploaded the void setup void loop sketch to the board (which completed) then after adding STMPE610 to the library tried to upload the TFTuke script again and received the same error message that says there is no such file or directory.