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 Peter Drescher

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)

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Fri Mar 01 19:27:49 2019 +0000
Parent:
167:8aa3fb2a5a31
Child:
169:1c1a495983bc
Commit message:
Added debug aids to GSL1680 controller driver.

Changed in this revision

RA8875_Touch.cpp Show annotated file Show diff for this revision Revisions of this file
RA8875_Touch_GSL1680.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/RA8875_Touch.cpp	Tue Feb 26 19:52:57 2019 +0000
+++ b/RA8875_Touch.cpp	Fri Mar 01 19:27:49 2019 +0000
@@ -10,7 +10,7 @@
 #define NOTOUCH_TIMEOUT_uS 100000
 #define TOUCH_TICKER_uS      1000
 
-//#define DEBUG "TUCH"
+#define DEBUG "TUCH"
 // ...
 // INFO("Stuff to show %d", var); // new-line is automatically appended
 //
--- a/RA8875_Touch_GSL1680.cpp	Tue Feb 26 19:52:57 2019 +0000
+++ b/RA8875_Touch_GSL1680.cpp	Fri Mar 01 19:27:49 2019 +0000
@@ -69,6 +69,42 @@
 #include "RA8875.h"
 #include "RA8875_Touch_GSL1680_Firmware.h"
 
+#define DEBUG "RAGL"
+// ...
+// 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
+
+
 #if 0
 // Translate from GSL1680 Event Flag to Touch Code to API-match the
 // alternate resistive touch screen driver common in the RA8875
@@ -88,6 +124,7 @@
     unsigned int source_len;
     const struct fw_data *ptr_fw;
 
+    INFO("GSL1680_Init()");
     // Wake it
     m_wake->write(false);
     wait_ms(20);
@@ -139,6 +176,7 @@
         {
             buf[0] = 0xf0;
             buf[1] = (uint8_t)(ptr_fw[source_line].val & 0x000000ff);
+            INFO("GSL1680 Firmware set page: %02X", buf[1]);
             m_i2c->write(m_addr, (char *)buf, 2);
         }
         else 
@@ -148,6 +186,7 @@
             buf[2] = (uint8_t)((ptr_fw[source_line].val & 0x0000ff00) >> 8);
             buf[3] = (uint8_t)((ptr_fw[source_line].val & 0x00ff0000) >> 16);
             buf[4] = (uint8_t)((ptr_fw[source_line].val & 0xff000000) >> 24);
+            //INFO("GSL1680 Firmware write[%02X] = %08X", ptr_fw[source_line].offset, ptr_fw[source_line].val);
             m_i2c->write(m_addr, (char *)buf, 5);
         }
     }
@@ -198,6 +237,7 @@
         numberOfTouchPoints = touch_data[0];
         gesture = FT5206_GEST_ID_NO_GESTURE;    // no gesture support
 
+        INFO("GSL1680 Touch %d points", numberOfTouchPoints);
         int tNdx = GSL1680_TOUCH_POINTS - 1;
         int dNdx = TD_SPACE - 1;
         for ( ; tNdx >= 0; tNdx--, dNdx -= 4) {
@@ -206,7 +246,10 @@
             touchInfo[tNdx].coordinates.y = fingerAndY & 0x0FFF;
             touchInfo[tNdx].coordinates.x = AndX & 0x0FFFF;
             touchInfo[tNdx].touchID = (fingerAndY >> 12);
-            touchInfo[tNdx].touchCode = (numberOfTouchPoints > tNdx) ? touch : no_touch;            
+            touchInfo[tNdx].touchCode = (numberOfTouchPoints > tNdx) ? touch : no_touch;
+            //INFO("  Code %d, Finger %d, xy (%4d,%4d)",
+            //    touchInfo[tNdx].touchCode, touchInfo[tNdx].touchID,
+            //    touchInfo[tNdx].coordinates.x, touchInfo[tNdx].coordinates.y);
         }
     } else {
         numberOfTouchPoints = 0;