adafruit / Adafruit_STMPE610

Arduino library for STMPE610/811 resistive touch screen controllers
MIT License
38 stars 32 forks source link

touched() function does not work #1

Closed driverblock closed 10 years ago

driverblock commented 10 years ago

boolean Adafruit_STMPE610::touched(void) always returns true, regardless of actual touch. This sketch demonstrates the issue:

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

// This is calibration data for the raw touch data to the screen coordinates
#define TS_MINX 150
#define TS_MINY 130
#define TS_MAXX 3800
#define TS_MAXY 4000

#define STMPE_CS 8
Adafruit_STMPE610 ts = Adafruit_STMPE610(STMPE_CS);
#define TFT_CS 10
#define TFT_DC 9
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

void setup(void)
{
  Serial.begin(9600);
  tft.begin();
  Serial.println("Touchscreen started.");
  if (!ts.begin()) { Serial.println("Unable to start touchscreen."); } 
  tft.fillScreen(ILI9341_BLUE);
}

void loop()
{
  if ( ts.touched())
  {
    Serial.println("This is printed repeatedly.");
    return;
  }

}
ladyada commented 10 years ago

fixed now!