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:
111:efe436c43aba
Parent:
109:7b94f06f085b
Child:
112:325ca91bc03d
--- a/GraphicsDisplay.cpp	Sat Mar 19 20:49:14 2016 +0000
+++ b/GraphicsDisplay.cpp	Mon Apr 25 01:43:59 2016 +0000
@@ -9,7 +9,7 @@
 #include "Bitmap.h"
 #include "string.h"
 
-//#define DEBUG "GD"
+//#define DEBUG "GD  "
 // ...
 // INFO("Stuff to show %d", var); // new-line is automatically appended
 //
@@ -100,16 +100,21 @@
     return fontblit(x, y, c);
 }
 
-RetCode_t GraphicsDisplay::window(loc_t x, loc_t y, dim_t w, dim_t h)
+RetCode_t GraphicsDisplay::window(rect_t r)
 {
+    return window(r.p1.x, r.p1.y, r.p2.x + 1 - r.p1.x, r.p2.y + 1 - r.p1.y);
+}
+
+RetCode_t GraphicsDisplay::window(loc_t x, loc_t y, dim_t width, dim_t height)
+{
+    // Save the window metrics
+    windowrect.p1.x = x;
+    windowrect.p1.y = y;
+    windowrect.p2.x = x + width - 1;
+    windowrect.p2.y = y + height - 1;
     // current pixel location
     _x = x;
     _y = y;
-    // window settings
-    _x1 = x;
-    _x2 = x + w - 1;
-    _y1 = y;
-    _y2 = y + h - 1;
     return noerror;
 }
 
@@ -123,11 +128,11 @@
     pixel(_x, _y, color);
     // update pixel location based on window settings
     _x++;
-    if(_x > _x2) {
-        _x = _x1;
+    if(_x > windowrect.p2.x) {
+        _x = windowrect.p1.x;
         _y++;
-        if(_y > _y2) {
-            _y = _y1;
+        if(_y > windowrect.p2.y) {
+            _y = windowrect.p1.y;
         }
     }
     return noerror;
@@ -145,13 +150,15 @@
 
 RetCode_t GraphicsDisplay::blit(loc_t x, loc_t y, dim_t w, dim_t h, const int * color)
 {
+    rect_t restore = windowrect;
     window(x, y, w, h);
     _StartGraphicsStream();
     for (int i=0; i<w*h; i++) {
         _putp(color[i]);
     }
     _EndGraphicsStream();
-    return WindowMax();
+    //return WindowMax();
+    return window(restore);
 }
 
 // 8 byte "info" section
@@ -331,6 +338,7 @@
     } while ((PixelWidth * recordSize + padd) % 4 != 0);
 
     // Define window for top to bottom and left to right so writing auto-wraps
+    rect_t restore = windowrect;
     window(x,y, PixelWidth,PixelHeight);
     SetGraphicsCursor(x, y);
     _StartGraphicsStream();
@@ -363,7 +371,7 @@
         pixelStream(pixelBuffer, PixelWidth, x, y++);
     }
     _EndGraphicsStream();
-    WindowMax();
+    window(restore);
     free(pixelBuffer);      // don't leak memory
     free(lineBuffer);
     if (colorPalette)