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:
104:8d1d3832a215
Child:
111:efe436c43aba
--- a/GraphicsDisplay.cpp	Sat Mar 05 16:20:11 2016 +0000
+++ b/GraphicsDisplay.cpp	Sat Mar 05 19:22:13 2016 +0000
@@ -133,7 +133,7 @@
     return noerror;
 }
 
-RetCode_t GraphicsDisplay::fill(int x, int y, int w, int h, color_t color)
+RetCode_t GraphicsDisplay::fill(loc_t x, loc_t y, dim_t w, dim_t h, color_t color)
 {
     return fillrect(x,y, x+w, y+h, color);
 }
@@ -143,7 +143,7 @@
     return fill(0, 0, width(), height(), _background);
 }
 
-RetCode_t GraphicsDisplay::blit(int x, int y, int w, int h, const int * color)
+RetCode_t GraphicsDisplay::blit(loc_t x, loc_t y, dim_t w, dim_t h, const int * color)
 {
     window(x, y, w, h);
     _StartGraphicsStream();
@@ -171,12 +171,12 @@
 //...
 
 
-const uint8_t * GraphicsDisplay::getCharMetrics(const unsigned char c, uint8_t * width, uint8_t * height)
+const uint8_t * GraphicsDisplay::getCharMetrics(const unsigned char c, dim_t * width, dim_t * height)
 {
     uint16_t offsetToCharLookup;
     uint16_t firstChar = font[3] * 256 + font[2];
     uint16_t lastChar  = font[5] * 256 + font[4];
-    uint8_t charHeight = font[6];
+    dim_t charHeight = font[6];
     const unsigned char * charRecord;   // width, data, data, data, ...
     
     INFO("first:%d, last:%d, c:%d", firstChar, lastChar, c);
@@ -185,7 +185,7 @@
     
     // 8 bytes of preamble to the first level lookup table
     offsetToCharLookup = 8 + 4 * (c - firstChar);    // 4-bytes: width(pixels), 16-bit offset from table start, 0
-    uint8_t charWidth = font[offsetToCharLookup];
+    dim_t charWidth = font[offsetToCharLookup];
     charRecord = font + font[offsetToCharLookup + 2] * 256 + font[offsetToCharLookup + 1];
     //INFO("hgt:%d, wdt:%d", charHeight, charWidth);
     if (width)
@@ -195,26 +195,11 @@
     return charRecord;
 }
 
-int GraphicsDisplay::fontblit(int x, int y, const unsigned char c)
+
+int GraphicsDisplay::fontblit(loc_t x, loc_t y, const unsigned char c)
 {
-    #if 0
-    uint16_t offsetToCharLookup;
-    uint16_t firstChar = font[3] * 256 + font[2];
-    uint16_t lastChar  = font[5] * 256 + font[4];
-    uint8_t charHeight = font[6];
-    const unsigned char * charRecord;   // width, data, data, data, ...
-    
-    INFO("first:%d, last:%d, c:%d", firstChar, lastChar, c);
-    if (c < firstChar || c > lastChar)
-        return 0;       // advance zero pixels since it was unprintable...
-    
-    // 8 bytes of preamble to the first level lookup table
-    offsetToCharLookup = 8 + 4 * (c - firstChar);    // 4-bytes: width(pixels), 16-bit offset from table start, 0
-    uint8_t charWidth = font[offsetToCharLookup];
-    charRecord = font + font[offsetToCharLookup + 2] * 256 + font[offsetToCharLookup + 1];
-#endif
-    const unsigned char * charRecord;   // width, data, data, data, ...
-    uint8_t charWidth, charHeight;
+    const uint8_t * charRecord;   // width, data, data, data, ...
+    dim_t charWidth, charHeight;
     charRecord = getCharMetrics(c, &charWidth, &charHeight);
     if (charRecord) {
         INFO("hgt:%d, wdt:%d", charHeight, charWidth);
@@ -223,28 +208,7 @@
         //    charWidth = width() - x;
         //if (y + charHeight >= height())
         //    charHeight = height() - y;
-        window(x, y, charWidth, charHeight);
-        _StartGraphicsStream();
-        while (charHeight--) {
-            uint8_t pixels = charWidth;
-            uint8_t bitmask = 0x01;
-            
-            while (pixels) {
-                uint8_t byte = *charRecord;
-                INFO("byte, mask: %02X, %02X", byte, bitmask);
-                color_t c = (byte & bitmask) ? _foreground : _background;
-                _putp(c);
-                bitmask <<= 1;
-                if (pixels > 1 && bitmask == 0) {
-                    bitmask = 0x01;
-                    charRecord++;
-                }
-                pixels--;
-            }
-            charRecord++;
-        }
-        _EndGraphicsStream();
-        WindowMax();
+        booleanStream(x,y,charWidth, charHeight, charRecord);
         return charWidth;
     } else {
         return 0;