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)

Revision:
200:ae29b60d087c
Parent:
198:9b6851107426
Child:
202:a22cbc04f332
--- a/RA8875.cpp	Sat Mar 28 15:08:43 2020 +0000
+++ b/RA8875.cpp	Sun Mar 29 14:33:19 2020 +0000
@@ -190,9 +190,11 @@
     : GraphicsDisplay(name)
     , spi(mosi, miso, sclk)
     , cs(csel)
-    , res(reset)
+    , res(NULL)
 {
     INFO("RA8875");
+    if (reset != NC)
+        res = new DigitalOut(reset);
     InitAllMemberVars();
     touchInfo = (touchInfo_T *)malloc(RESISTIVE_TOUCH_POINTS * sizeof(touchInfo_T));
     if (touchInfo)
@@ -206,9 +208,11 @@
     : GraphicsDisplay(name)
     , spi(mosi, miso, sclk)
     , cs(csel)
-    , res(reset)
+    , res(NULL)
 {
     INFO("RA8875");
+    if (reset != NC)
+        res = new DigitalOut(reset);
     InitAllMemberVars();
     m_irq = new InterruptIn(irq);
     m_i2c = new I2C(sda, scl);
@@ -244,9 +248,11 @@
     : GraphicsDisplay(name)
     , spi(mosi, miso, sclk)
     , cs(csel)
-    , res(reset)
+    , res(NULL)
 {
     INFO("RA8875");
+    if (reset != NC)
+        res = new DigitalOut(reset);
     InitAllMemberVars();
 
     m_irq = new InterruptIn(irq);
@@ -430,10 +436,10 @@
     RetCode_t ret;
 
     #if 1
-    if (res != (PinName)NC) {
-        res = 0;                            // Active low - assert reset
-        wait_us(2000);                         // must be > 1024 clock periods. (@25 MHz, this is 40.96 usec)
-        res = 1;                            // de-assert reset
+    if (res) {
+        res->write(0);                      // Active low - assert reset
+        wait_us(2000);                      // must be > 1024 clock periods. (@25 MHz, this is 40.96 usec)
+        res->write(1);                      // de-assert reset
     }
     #endif
     ret = WriteCommand(RA8875_PWRR, 0x01);         // Apply Display Off, Reset
@@ -1493,25 +1499,25 @@
                 }
                 dim_t cWidth = GetTextWidth(p, true);
                 INFO("txtPos: %d, cWidth: %d, p2.x: %d", txtPos, cWidth, windowrect.p2.x);
-                if (txtPos + cWidth < windowrect.p2.x) {
+                if (txtPos + cWidth <= windowrect.p2.x) {
                     txtPos += cWidth;
                 } else {
                     newLineNeeded = true;
                     break;
                 }
-                INFO("+ %c width %d, ttl Width %d < %d", *p, cWidth, txtPos, windowrect.p2.x);
+                INFO("+ %c width %d, ttl Width %d <= %d", *p, cWidth, txtPos, windowrect.p2.x);
                 p++;
             } while (*p);
             INFO("p: len(%d), (%s)", strlen(p), p);
-            if (*p != ' ' && pSpace) {
+            if (*p && *p != ' ' && pSpace) {
                 p = pSpace;
                 INFO("p: len(%d), (%s)", strlen(p), p);
             }
             char dbgBuf[256];
             strncpy(dbgBuf, string, (p - string));
             dbgBuf[p - string] = '\0';
-            INFO("chunk: %d < w.p2.x: %d - '%s'", txtPos, windowrect.p2.x, dbgBuf);
-            if (txtPos < windowrect.p2.x) {
+            INFO("chunk: %d <= w.p2.x: %d - '%s'", txtPos, windowrect.p2.x, dbgBuf);
+            if (txtPos <= windowrect.p2.x) {
                 while (*string && string <= p) {
                     INFO("*string %02X", *string);
                     if (*string == '\r') {