Library to control a Graphics TFT connected to 4-wire SPI - revised for the Raio RA8875 Display Controller.
Dependents: FRDM_RA8875_mPaint RA8875_Demo RA8875_KeyPadDemo SignalGenerator ... more
Fork of SPI_TFT by
See Components - RA8875 Based Display
Enhanced touch-screen support - where it previous supported both the Resistive Touch and Capacitive Touch based on the FT5206 Touch Controller, now it also has support for the GSL1680 Touch Controller.
Offline Help Manual (Windows chm)
/media/uploads/WiredHome/ra8875.zip.bin (download, rename to .zip and unzip)
Diff: RA8875_Touch.cpp
- Revision:
- 154:ad2450fc3dc3
- Parent:
- 150:35a4db3081c1
- Child:
- 155:b3f225ae572c
diff -r 8a85efb3eb71 -r ad2450fc3dc3 RA8875_Touch.cpp --- a/RA8875_Touch.cpp Sun Jul 29 00:32:51 2018 +0000 +++ b/RA8875_Touch.cpp Fri Aug 17 01:29:06 2018 +0000 @@ -8,6 +8,41 @@ #define NOTOUCH_TIMEOUT_uS 100000 #define TOUCH_TICKER_uS 1000 +//#define DEBUG "TUCH" +// ... +// INFO("Stuff to show %d", var); // new-line is automatically appended +// +#if (defined(DEBUG) && !defined(TARGET_LPC11U24)) +#define INFO(x, ...) std::printf("[INF %s %4d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); +#define WARN(x, ...) std::printf("[WRN %s %4d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); +#define ERR(x, ...) std::printf("[ERR %s %4d] "x"\r\n", DEBUG, __LINE__, ##__VA_ARGS__); +static void HexDump(const char * title, const uint8_t * p, int count) +{ + int i; + char buf[100] = "0000: "; + + if (*title) + INFO("%s", title); + for (i=0; i<count; ) { + sprintf(buf + strlen(buf), "%02X ", *(p+i)); + if ((++i & 0x0F) == 0x00) { + INFO("%s", buf); + if (i < count) + sprintf(buf, "%04X: ", i); + else + buf[0] = '\0'; + } + } + if (strlen(buf)) + INFO("%s", buf); +} +#else +#define INFO(x, ...) +#define WARN(x, ...) +#define ERR(x, ...) +#define HexDump(a, b, c) +#endif + // Translate from FT5206 Event Flag to Touch Code to API-match the // alternate resistive touch screen driver common in the RA8875 @@ -36,7 +71,7 @@ touchSample = 0; touchState = no_cal; //touchTicker.attach_us(callback(this, &RA8875::_TouchTicker), TOUCH_TICKER_uS); - #if MBED_LIBRARY_VERSION > 122 // Is this the right version? + #if (MBED_MAJOR_VERSION >= 5) || (MBED_LIBRARY_VERSION > 122) // Is this the right version? touchTicker.attach_us(callback(this, &RA8875::_TouchTicker), TOUCH_TICKER_uS); #else touchTicker.attach_us(this, &RA8875::_TouchTicker, TOUCH_TICKER_uS); @@ -74,7 +109,7 @@ touchState = no_cal; if (bTpEnable == TP_ENABLE) { //touchTicker.attach_us(callback(this, &RA8875::_TouchTicker), TOUCH_TICKER_uS); - #if MBED_LIBRARY_VERSION > 122 // Is this the right version? + #if (MBED_MAJOR_VERSION >= 5) || (MBED_LIBRARY_VERSION > 122) // Is this the right version? touchTicker.attach_us(callback(this, &RA8875::_TouchTicker), TOUCH_TICKER_uS); #else touchTicker.attach_us(this, &RA8875::_TouchTicker, TOUCH_TICKER_uS); @@ -353,13 +388,17 @@ TouchCode_t RA8875::TouchPanelA2DRaw(int *x, int *y) { + INFO("A2Raw"); if( (ReadCommand(INTC2) & RA8875_INT_TP) ) { // Test for TP Interrupt pending in register INTC2 + INFO("Int pending"); touchTimer.reset(); *y = ReadCommand(TPYH) << 2 | ( (ReadCommand(TPXYL) & 0xC) >> 2 ); // D[9:2] from reg TPYH, D[1:0] from reg TPXYL[3:2] *x = ReadCommand(TPXH) << 2 | ( (ReadCommand(TPXYL) & 0x3) ); // D[9:2] from reg TPXH, D[1:0] from reg TPXYL[1:0] + INFO("(x,y) = (%d,%d)", x, y); WriteCommand(INTC2, RA8875_INT_TP); // reg INTC2: Clear that TP interrupt flag touchState = touch; } else { + INFO("no touch"); touchState = no_touch; } return touchState;