use internal VREF. also some minimal calibration
This commit is contained in:
parent
08c25fa361
commit
72b11ed071
|
|
@ -418,12 +418,12 @@ void Adafruit_RA8875::touchEnable(boolean on)
|
|||
{
|
||||
/* Enable Touch Panel (Reg 0x70) */
|
||||
writeReg(RA8875_TPCR0, RA8875_TPCR0_ENABLE |
|
||||
RA8875_TPCR0_WAIT_4096CLK |
|
||||
RA8875_TPCR0_WAIT_4096CLK |
|
||||
RA8875_TPCR0_WAKEDISABLE |
|
||||
RA8875_TPCR0_ADCCLK_DIV4); // 10mhz max!
|
||||
RA8875_TPCR0_ADCCLK_DIV8); // 10mhz max!
|
||||
/* Set Auto Mode (Reg 0x71) */
|
||||
writeReg(RA8875_TPCR1, RA8875_TPCR1_AUTO |
|
||||
RA8875_TPCR1_VREFEXT |
|
||||
// RA8875_TPCR1_VREFEXT |
|
||||
RA8875_TPCR1_DEBOUNCE);
|
||||
/* Enable TP INT */
|
||||
writeReg(RA8875_INTC1, readReg(RA8875_INTC1) | RA8875_INTC1_TP);
|
||||
|
|
|
|||
|
|
@ -80,11 +80,13 @@ void setup()
|
|||
Serial.println("Waiting for touch events ...");
|
||||
}
|
||||
|
||||
#define XMIN 105
|
||||
#define XMAX 975
|
||||
#define YMIN 130
|
||||
#define YMAX 900
|
||||
|
||||
void loop()
|
||||
{
|
||||
float xScale = 1024.0F/tft.width();
|
||||
float yScale = 1024.0F/tft.height();
|
||||
|
||||
/* Wait around for touch events */
|
||||
if (! digitalRead(RA8875_INT))
|
||||
{
|
||||
|
|
@ -94,7 +96,9 @@ void loop()
|
|||
tft.touchRead(&tx, &ty);
|
||||
Serial.print(tx); Serial.print(", "); Serial.println(ty);
|
||||
/* Draw a circle */
|
||||
tft.fillCircle((uint16_t)(tx/xScale), (uint16_t)(ty/yScale), 10, RA8875_WHITE);
|
||||
tx = map(tx, XMIN, XMAX, 0, tft.width());
|
||||
ty = map(ty, YMIN, YMAX, 0, tft.height());
|
||||
tft.fillCircle(tx, ty, 5, RA8875_WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue