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:
123:2f45e80fec5f
--- a/RA8875.cpp	Sat Mar 19 20:49:14 2016 +0000
+++ b/RA8875.cpp	Mon Apr 25 01:43:59 2016 +0000
@@ -856,7 +856,7 @@
 {
     if (c) {
         if (c == '\r') {
-            cursor_x = 0;
+            cursor_x = windowrect.p1.x;
         } else if (c == '\n') {
             cursor_y += extFontHeight;
         } else {
@@ -865,15 +865,17 @@
             
             charRecord = getCharMetrics(c, &charWidth, &charHeight);
             //int advance = charwidth(c);
-            INFO("(%d,%d) ,charWidth: %d '%c", cursor_x, cursor_y, charWidth, c);
+            INFO("(%d,%d) - (%d,%d):(%d,%d), charWidth: %d '%c", cursor_x, cursor_y, 
+                windowrect.p1.x, windowrect.p1.y, windowrect.p2.x, windowrect.p2.y,
+                charWidth, c);
             if (charRecord) {
                 //cursor_x += advance;
-                if (cursor_x + charWidth >= screenwidth) {
-                    cursor_x = 0;
+                if (cursor_x + charWidth >= windowrect.p2.x) {
+                    cursor_x = windowrect.p1.x;
                     cursor_y += charHeight;
                 }
-                if (cursor_y + charHeight >= screenheight) {
-                    cursor_y = 0;               // @todo Should it scroll?
+                if (cursor_y + charHeight >= windowrect.p2.y) {
+                    cursor_y = windowrect.p1.y;               // @todo Should it scroll?
                 }
                 (void)character(cursor_x, cursor_y, c);
                 cursor_x += charWidth;
@@ -972,15 +974,29 @@
     return noerror;
 }
 
+RetCode_t RA8875::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 RA8875::window(loc_t x, loc_t y, dim_t width, dim_t height)
 {
+    INFO("window(%d,%d,%d,%d)", x, y, width, height);
+    if (width == (dim_t)-1)
+        width = screenwidth - x;
+    if (height == (dim_t)-1)
+        height = screenheight - y;
+    windowrect.p1.x = x;
+    windowrect.p1.y = y;
+    windowrect.p2.x = x + width - 1;
+    windowrect.p2.y = y + height - 1;
     GraphicsDisplay::window(x,y, width,height);
     WriteCommandW(0x30, x);
     WriteCommandW(0x32, y);
     WriteCommandW(0x34, (x+width-1));
     WriteCommandW(0x36, (y+height-1));
-    SetGraphicsCursor(x,y);
+    //SetTextCursor(x,y);
+    //SetGraphicsCursor(x,y);
     return noerror;
 }
 
@@ -1080,6 +1096,8 @@
 RetCode_t RA8875::booleanStream(loc_t x, loc_t y, dim_t w, dim_t h, const uint8_t * boolStream) 
 {
     PERFORMANCE_RESET;
+    rect_t restore = windowrect;
+    
     window(x, y, w, h);
     SetGraphicsCursor(x, y);
     _StartGraphicsStream();
@@ -1091,7 +1109,7 @@
         
         while (pixels) {
             uint8_t byte = *boolStream;
-            INFO("byte, mask: %02X, %02X", byte, bitmask);
+            //INFO("byte, mask: %02X, %02X", byte, bitmask);
             color_t c = (byte & bitmask) ? _foreground : _background;
                 if (screenbpp == 16) {
                     _spiwrite(c >> 8);
@@ -1110,7 +1128,7 @@
     }
     _select(false);
     _EndGraphicsStream();
-    WindowMax();
+    window(restore);
     REGISTERPERFORMANCE(PRF_BOOLSTREAM);
     return(noerror);
 }