Hi @Jonny_rhodes,
here is a quick touchscreen test program, (use the same common.h, gsl1680.h, gsl1680.cpp and gslX680firmware.h from the project):
// This #include statement was automatically added by the Particle IDE.
#include "common.h"
#include "gsl1680.h"
#define LOGGING_ON TRUE
#if (LOGGING_ON)
SerialLogHandler logHandler(LOG_LEVEL_WARN,
{{"app", LOG_LEVEL_ALL},
{"app.touch", LOG_LEVEL_ALL}});
#endif
Logger touchLog("app.touch");
int WAKE = D4;
int INTRPT = D2;
int LED = D7;
bool led = false;
bool Interrupt = false;
uint32_t now;
uint32_t lastInterrupt = 0;
// Objects
gsl1680 GSL = gsl1680();
void debugEvent(touchScreenEvent e)
{
touchLog.info("Number of Fingers: %d", e.numberOfFingers);
touchLog.info("Finger 1 Postion[X,Y]: %d, %d", e.fingerPositions[0].x, e.fingerPositions[0].y);
touchLog.info("Finger 2 Postion[X,Y]: %d, %d", e.fingerPositions[1].x, e.fingerPositions[1].y);
touchLog.info("Finger 3 Postion[X,Y]: %d, %d", e.fingerPositions[2].x, e.fingerPositions[2].y);
touchLog.info("Finger 4 Postion[X,Y]: %d, %d", e.fingerPositions[3].x, e.fingerPositions[3].y);
touchLog.info("Finger 5 Postion[X,Y]: %d, %d", e.fingerPositions[4].x, e.fingerPositions[4].y);
}
void setup()
{
Serial.begin(115200);
delay(1000);
// Log some debug info
Log.info("Starting up...");
Log.info("System version: %s", System.version().c_str());
Log.info("Device ID: %s", System.deviceID().c_str());
Log.info("IP: %d.%d.%d.%d", WiFi.localIP()[0], WiFi.localIP()[1], WiFi.localIP()[2], WiFi.localIP()[3]);
Log.info("Subnet: %d.%d.%d.%d", WiFi.subnetMask()[0], WiFi.subnetMask()[1], WiFi.subnetMask()[2], WiFi.subnetMask()[3]);
Log.info("Gateway: %d.%d.%d.%d", WiFi.gatewayIP()[0], WiFi.gatewayIP()[1], WiFi.gatewayIP()[2], WiFi.gatewayIP()[3]);
Log.info("SSID: %s", WiFi.SSID());
// Setup IO
pinMode(LED, OUTPUT);
pinMode(WAKE, OUTPUT);
pinMode(INTRPT, INPUT_PULLUP);
digitalWrite(LED, HIGH);
GSL.initialise(WAKE);
digitalWrite(LED, LOW);
//get status on start up.
}
void loop()
{
now = millis();
// Check for touchscreen input data
if (digitalRead(INTRPT) == HIGH)
{
led = !led; //flick led
digitalWrite(LED, led);
bool success = GSL.readData();
if (success == 1)
{
debugEvent(GSL.event);
Interrupt = true;
lastInterrupt = now;
}
else
{
touchLog.error("Interrupt High: Failed Read...");
}
}
else
{
if (Interrupt == true && (now - 100 > lastInterrupt))
{
bool success = GSL.readData();
if (success == 1)
{
int fCount = GSL.event.numberOfFingers;
if (fCount > 0)
{
Interrupt = true;
lastInterrupt = now;
}
else
{
Interrupt = false;
}
debugEvent(GSL.event);
}
else
{
touchLog.error("Interrupt Low: Failed Read...");
Interrupt = true;
lastInterrupt = now;
}
}
}
}
Start up the serial monitor and you should see something like:
0000027468 [app.touch] INFO: Number of Fingers: 2
0000027468 [app.touch] INFO: Finger 0 Postion[X,Y]: 80, 459
0000027469 [app.touch] INFO: Finger 1 Postion[X,Y]: 238, 409
0000027469 [app.touch] INFO: Finger 2 Postion[X,Y]: 0, 0
0000027469 [app.touch] INFO: Finger 3 Postion[X,Y]: 0, 0
0000027470 [app.touch] INFO: Finger 4 Postion[X,Y]: 0, 0
0000027488 [app.touch] INFO: Number of Fingers: 2
0000027488 [app.touch] INFO: Finger 0 Postion[X,Y]: 78, 462
0000027489 [app.touch] INFO: Finger 1 Postion[X,Y]: 237, 411
0000027489 [app.touch] INFO: Finger 2 Postion[X,Y]: 0, 0
0000027489 [app.touch] INFO: Finger 3 Postion[X,Y]: 0, 0
0000027489 [app.touch] INFO: Finger 4 Postion[X,Y]: 0, 0
0000027526 [app.touch] INFO: Number of Fingers: 2
0000027526 [app.touch] INFO: Finger 0 Postion[X,Y]: 72, 469
0000027527 [app.touch] INFO: Finger 1 Postion[X,Y]: 230, 414
0000027527 [app.touch] INFO: Finger 2 Postion[X,Y]: 0, 0
0000027527 [app.touch] INFO: Finger 3 Postion[X,Y]: 0, 0
0000027527 [app.touch] INFO: Finger 4 Postion[X,Y]: 0, 0
Let us know how you go.
Regards