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:
151:ae94daaaf8ad
Parent:
150:35a4db3081c1
--- a/RA8875.cpp	Sun Sep 24 02:09:57 2017 +0000
+++ b/RA8875.cpp	Sat Apr 14 17:48:59 2018 +0000
@@ -116,6 +116,7 @@
     obj_callback = NULL;
     method_callback = NULL;
     idle_callback = NULL;
+    fontScaleX = fontScaleY = 1;
 }
 
 
@@ -133,6 +134,7 @@
     obj_callback = NULL;
     method_callback = NULL;
     idle_callback = NULL;
+    fontScaleX = fontScaleY = 1;
 
     // Cap touch panel config
     m_addr = (FT5206_I2C_ADDRESS << 1);
@@ -1014,6 +1016,8 @@
     if (vScale == -1)
         vScale = hScale;
     if (hScale >= 1 && hScale <= 4 && vScale >= 1 && vScale <= 4) {
+        fontScaleX = hScale;    // save for use with a Soft Font
+        fontScaleY = vScale;
         reg &= 0xF0;    // keep the high nibble as is.
         reg |= ((hScale - 1) << 2);
         reg |= ((vScale - 1) << 0);
@@ -1078,7 +1082,7 @@
                     cursor_y = windowrect.p1.y;               // @todo Should it scroll?
                 }
                 (void)character(cursor_x, cursor_y, c);
-                cursor_x += charWidth;
+                cursor_x += charWidth * fontScaleX;
             }
         }
     }
@@ -1310,38 +1314,48 @@
     return(noerror);
 }
 
+// With a font scale X = 1, a pixel stream is "abcdefg..."
+// With a font scale X = 2, a pixel stream is "aabbccddeeffgg..."
+// With a font scale Y = 2, a pixel stream is "abcdefg..."
+//                                            "abcdefg..."
+//
 RetCode_t RA8875::booleanStream(loc_t x, loc_t y, dim_t w, dim_t h, const uint8_t * boolStream) 
 {
     PERFORMANCE_RESET;
+    const uint8_t * rowStream;
     rect_t restore = windowrect;
-    
-    window(x, y, w, h);
+    window(x, y, w * fontScaleX, h * fontScaleY);       // Scale from font scale factors
     SetGraphicsCursor(x, y);
     _StartGraphicsStream();
     _select(true);
     _spiwrite(0x00);         // Cmd: write data
     while (h--) {
-        uint8_t pixels = w;
-        uint8_t bitmask = 0x01;
-        
-        while (pixels) {
-            uint8_t byte = *boolStream;
-            //INFO("byte, mask: %02X, %02X", byte, bitmask);
-            color_t c = (byte & bitmask) ? _foreground : _background;
-                if (screenbpp == 16) {
-                    _spiwrite(c >> 8);
-                    _spiwrite(c & 0xFF);
-                } else {
-                    _spiwrite(_cvt16to8(c));
+        for (int dy=0; dy<fontScaleY; dy++) {           // Vertical Font Scale Factor
+            uint8_t pixels = w;
+            uint8_t bitmask = 0x01;
+            rowStream = boolStream;        
+            while (pixels) {
+                uint8_t byte = *rowStream;
+                //INFO("byte, mask: %02X, %02X", byte, bitmask);
+                color_t c = (byte & bitmask) ? _foreground : _background;
+                
+                for (int dx=0; dx<fontScaleX; dx++) {   // Horizontal Font Scale Factor
+                    if (screenbpp == 16) {
+                        _spiwrite(c >> 8);
+                        _spiwrite(c & 0xFF);
+                    } else {
+                        _spiwrite(_cvt16to8(c));
+                    }
                 }
-            bitmask <<= 1;
-            if (pixels > 1 && bitmask == 0) {
-                bitmask = 0x01;
-                boolStream++;
+                bitmask <<= 1;
+                if (pixels > 1 && bitmask == 0) {
+                    bitmask = 0x01;
+                    rowStream++;
+                }
+                pixels--;
             }
-            pixels--;
         }
-        boolStream++;
+        boolStream += (rowStream - boolStream + 1);
     }
     _select(false);
     _EndGraphicsStream();