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:
146:373d59f08357
Parent:
142:6e9bff59878a
Parent:
145:5eb2492acdda
Child:
151:ae94daaaf8ad
Child:
152:a013ac0133e4
--- a/GraphicsDisplay.cpp	Sat May 06 20:14:48 2017 +0000
+++ b/GraphicsDisplay.cpp	Thu Jun 01 11:00:40 2017 +0000
@@ -9,6 +9,12 @@
 #include "Bitmap.h"
 #include "string.h"
 
+//#include "Utility.h"            // private memory manager
+#ifndef UTILITY_H
+#define swMalloc malloc         // use the standard
+#define swFree free
+#endif
+
 //#define DEBUG "GD  "
 // ...
 // INFO("Stuff to show %d", var); // new-line is automatically appended
@@ -313,7 +319,7 @@
         // Read the color palette
         colorCount = 1 << BMP_Info.biBitCount;
         paletteSize = sizeof(RGBQUAD) * colorCount;
-        colorPalette = (RGBQUAD *)malloc(paletteSize);
+        colorPalette = (RGBQUAD *)swMalloc(paletteSize);
         if (colorPalette == NULL) {
             fclose(Image);
             return(not_enough_ram);
@@ -324,17 +330,17 @@
 
     int lineBufSize = ((BPP_t * PixelWidth + 7)/8);
     INFO("BPP_t %d, PixelWidth %d, lineBufSize %d", BPP_t, PixelWidth, lineBufSize);
-    lineBuffer = (uint8_t *)malloc(lineBufSize);
+    lineBuffer = (uint8_t *)swMalloc(lineBufSize);
     if (lineBuffer == NULL) {
-        free(colorPalette);
+        swFree(colorPalette);
         fclose(Image);
         return(not_enough_ram);
     }
-    pixelBuffer = (color_t *)malloc(PixelWidth * sizeof(color_t));
+    pixelBuffer = (color_t *)swMalloc(PixelWidth * sizeof(color_t));
     if (pixelBuffer == NULL) {
-        free(lineBuffer);
+        swFree(lineBuffer);
         if (colorPalette)
-            free(colorPalette);
+            swFree(colorPalette);
         fclose(Image);
         return(not_enough_ram);
     }
@@ -384,10 +390,10 @@
     }
 //    _EndGraphicsStream();
     window(restore);
-    free(pixelBuffer);      // don't leak memory
-    free(lineBuffer);
+    swFree(pixelBuffer);      // don't leak memory
+    swFree(lineBuffer);
     if (colorPalette)
-        free(colorPalette);
+        swFree(colorPalette);
     return (noerror);
 }
 
@@ -407,7 +413,7 @@
 
 RetCode_t GraphicsDisplay::RenderJpegFile(loc_t x, loc_t y, const char *Name_JPG)
 {
-    #define JPEG_WORK_SPACE_SIZE 3100
+    #define JPEG_WORK_SPACE_SIZE 3100   // Worst case requirements for the decompression
     JDEC * jdec;
     uint16_t * work;
     RetCode_t r = noerror;  // start optimistic
@@ -415,12 +421,10 @@
     
     if (!fh)
         return(file_not_found);
-    
     //INFO("RenderJpegFile(%d,%d,%s)", x,y, Name_JPG);
-    work = (uint16_t *)malloc(JPEG_WORK_SPACE_SIZE);
-    
+    work = (uint16_t *)swMalloc(JPEG_WORK_SPACE_SIZE);
     if (work) {
-        jdec = (JDEC *)malloc(sizeof(JDEC));
+        jdec = (JDEC *)swMalloc(sizeof(JDEC));
         if (jdec) {
             memset(work, 0, JPEG_WORK_SPACE_SIZE/sizeof(uint16_t));
             memset(jdec, 0, sizeof(JDEC));
@@ -434,12 +438,12 @@
             } else {
                 r = not_supported_format;   // error("jd_prepare error:%d", r);
             }
-            free(jdec);
+            swFree(jdec);
         } else {
             WARN("checkpoint");
             r = not_enough_ram;
         }
-        free(work);
+        swFree(work);
     } else {
         WARN("checkpoint");
         r = not_enough_ram;