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:
109:7b94f06f085b
Parent:
107:f9ccffcb84f1
Child:
111:efe436c43aba
--- a/RA8875.cpp	Sat Mar 05 16:20:11 2016 +0000
+++ b/RA8875.cpp	Sat Mar 05 19:22:13 2016 +0000
@@ -45,7 +45,7 @@
 #define HexDump(a, b, c)
 #endif
 
-
+// Defaults. Users can override this with the init() method.
 #define RA8875_DISPLAY_WIDTH  480
 #define RA8875_DISPLAY_HEIGHT 272
 #define RA8875_COLORDEPTH_BPP 16    /* Not an API */
@@ -55,7 +55,7 @@
 #define REGISTERPERFORMANCE(a) RegisterPerformance(a)
 #define COUNTIDLETIME(a) CountIdleTime(a)
 static const char *metricsName[] = {
-    "Cls", "Pixel", "Pixel Stream",
+    "Cls", "Pixel", "Pixel Stream", "Boolean Stream",
     "Read Pixel", "Read Pixel Stream",
     "Line",
     "Rectangle", "Rounded Rectangle",
@@ -860,7 +860,7 @@
         } else if (c == '\n') {
             cursor_y += extFontHeight;
         } else {
-            uint8_t charWidth, charHeight;
+            dim_t charWidth, charHeight;
             const uint8_t * charRecord;
             
             charRecord = getCharMetrics(c, &charWidth, &charHeight);
@@ -950,20 +950,9 @@
         WriteCommand(0x40,0x80);    // Put in Text mode if internal font
     }
     if (*string != '\0') {
-#if 1
         while (*string) {           // @TODO calling individual _putc is slower... optimizations?
             _putc(*string++);
         }
-#else
-        WriteCommand(0x02);
-        _select(true);
-        while (*string != '\0') {
-            WriteData(*string);
-            ++string;
-            _WaitWhileBusy(0x80);
-        }
-        _select(false);
-#endif
     }
 }
 
@@ -978,8 +967,6 @@
 
 RetCode_t RA8875::SetGraphicsCursorRead(loc_t x, loc_t y)
 {
-    //WriteCommand(0x40, 0);  // Graphics mode
-    //WriteCommand(0x45, 0);  // left->right, top->bottom
     WriteCommandW(0x4A, x);
     WriteCommandW(0x4C, y);
     return noerror;
@@ -1071,9 +1058,8 @@
 RetCode_t RA8875::pixelStream(color_t * p, uint32_t count, loc_t x, loc_t y)
 {
     PERFORMANCE_RESET;
-    WriteCommand(0x40,0x00);    // Graphics write mode
     SetGraphicsCursor(x, y);
-    WriteCommand(0x02);
+    _StartGraphicsStream();
     _select(true);
     _spiwrite(0x00);         // Cmd: write data
     while (count--) {
@@ -1086,10 +1072,48 @@
         p++;
     }
     _select(false);
+    _EndGraphicsStream();
     REGISTERPERFORMANCE(PRF_PIXELSTREAM);
     return(noerror);
 }
 
+RetCode_t RA8875::booleanStream(loc_t x, loc_t y, dim_t w, dim_t h, const uint8_t * boolStream) 
+{
+    PERFORMANCE_RESET;
+    window(x, y, w, h);
+    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));
+                }
+            bitmask <<= 1;
+            if (pixels > 1 && bitmask == 0) {
+                bitmask = 0x01;
+                boolStream++;
+            }
+            pixels--;
+        }
+        boolStream++;
+    }
+    _select(false);
+    _EndGraphicsStream();
+    WindowMax();
+    REGISTERPERFORMANCE(PRF_BOOLSTREAM);
+    return(noerror);
+}
 
 color_t RA8875::getPixel(loc_t x, loc_t y)
 {