KSM edits to RA8875

Dependents:   Liz_Test_Code

Revision:
168:37a0c4d8791c
Parent:
166:53fd4a876dac
Child:
170:7e26d51bc48b
--- 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;