Hi all,
Bit of a noob here and I'm having trouble understanding some bits of code for the adafruit TFT touch screen shield for arduino. The first bit of code can be found here: Arduin-o-Phone Sketch | Arduin-o-Phone | Adafruit Learning System
What I don't understand is this part here:
void loop(void) {
TS_Point p;
if (ts.bufferSize()) {
p = ts.getPoint();
} else {
// this is our way of tracking touch 'release'!
p.x = p.y = p.z = -1;
}
// Scale from ~0->4000 to tft.width using the calibration #'s
if (p.z != -1) {
p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());
Serial.print("("); Serial.print(p.x); Serial.print(", ");
Serial.print(p.y); Serial.print(", ");
Serial.print(p.z); Serial.println(") ");
}
What exactly is the 2nd line? TS_Point p;
Is that some sort of definition or initialization of p? Then, as I see it, p is assigned some properties in the line p = ts.getPoint();
is that right?
The second bit of code I'm having problems with is from adafruit's library for this screen.
void loop() {
uint16_t x, y;
uint8_t z;
if (touch.touched()) {
// read x & y & z;
while (! touch.bufferEmpty()) {
Serial.print(touch.bufferSize());
touch.readData(&x, &y, &z);
Serial.print("->(");
Serial.print(x); Serial.print(", ");
Serial.print(y); Serial.print(", ");
Serial.print(z);
Serial.println(")");
}
touch.writeRegister8(STMPE_INT_STA, 0xFF); // reset all ints
}
delay(10);
}
In this example, it's the touch.readData(&x, &y, &z);
line that I am a bit confused about. The '&' is a reference I found out on google, but the first search I did showed some confusion between a reference vs pointer usage. A link to a good description would be helpful if anyone has one, but I will google it further....
Thanks for any help,
Randy