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:
136:224e03d5c31f
Parent:
121:6bc4911f5e55
Child:
167:8aa3fb2a5a31
--- a/GraphicsDisplayJPEG.cpp	Sun Nov 13 02:06:30 2016 +0000
+++ b/GraphicsDisplayJPEG.cpp	Wed Nov 16 02:48:45 2016 +0000
@@ -839,14 +839,10 @@
         return privInFunc(jd, buff, ndata);
 }
 
-
+// RGB565 if JD_FORMAT == 1
+// RGB888 if JD_FORMAT == 0
 uint16_t GraphicsDisplay::privOutFunc(JDEC * jd, void * bitmap, JRECT * rect)
 {
-    #if JD_FORMAT == 1
-    uint16_t *src = (uint16_t *)bitmap;
-    #else
-    uint8_t *src = (uint8_t *)bitmap;
-    #endif
     int x0 = rect->left;
     int x1 = rect->right;
     int y0 = rect->top;
@@ -854,15 +850,34 @@
  
     INFO("privOutFunc: (%d,%d)-(%d,%d) : (%d,%d)", x0,y0, x1,y1, width(), height());
     if (y0 >= height() || x0 >= width())
-        return 1;
- 
-    if (x1 > width()-1) x1 = width() - 1;
-    if (y1 > height()-1) y1 = height() - 1;
- 
-    INFO("checkpoint");
+        return 1;                               // off the right || bottom of screen
+    if (x1 > width()-1) x1 = width() - 1;       // clip to width
+    if (y1 > height()-1) y1 = height() - 1;     // clip to height
+
     int w = x1 - x0 + 1;
+
+#if 1
+    uint32_t pixelCount = (1 + (y1-y0)) * (1+x1-x0);
+    #if JD_FORMAT == 0
+    uint8_t *s = (uint8_t *)bitmap;
+    uint16_t rgb565, *d = (uint16_t *)s;
+    uint32_t pCount = pixelCount;
+    
+    do {
+        rgb565 = (*s++ & 0xF8) << 8;     /* RRRRR----------- */
+        rgb565 |= (*s++ & 0xFC) << 3;    /* -----GGGGGG----- */
+        rgb565 |= *s++ >> 3;             /* -----------BBBBB */
+        *d++ = rgb565;
+    } while (--pCount);
+    #endif
+    //
+    window(x0+img_x, y0+img_y, w, y1 - y0 + 2);
+    uint16_t *src = (uint16_t *)bitmap;     // pointer to RGB565 format
+    pixelStream(src, pixelCount, x0+img_x, y0+img_y);
+    window();
+#else
     for (int y= y0; y <= y1; y++) {
-        SetGraphicsCursor(x0, y);
+        SetGraphicsCursor(x0+img_x, y+img_y);
         _StartGraphicsStream();
         #if JD_FORMAT == 1
         uint16_t *p = src + w * (y - y0);
@@ -879,6 +894,7 @@
         }
         _EndGraphicsStream();
     }
+#endif
     return 1;
 }
 
@@ -1188,6 +1204,5 @@
             if (rc != JDR_OK) return rc;
         }
     }
-
     return rc;
 }