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)

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Sat Aug 06 20:04:23 2016 +0000
Parent:
126:c91bd2e500b9
Child:
128:3c74ba4533dc
Commit message:
Added GetUserFont and GetTextFontSize apis, which were helpful for saving and restoring settings on the fly.

Changed in this revision

RA8875.cpp Show annotated file Show diff for this revision Revisions of this file
RA8875.h Show annotated file Show diff for this revision Revisions of this file
RA8875_Touch.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/RA8875.cpp	Sat Aug 06 15:09:34 2016 +0000
+++ b/RA8875.cpp	Sat Aug 06 20:04:23 2016 +0000
@@ -887,6 +887,16 @@
     }
 }
 
+RetCode_t RA8875::GetTextFontSize(RA8875::HorizontalScale * hScale, RA8875::VerticalScale * vScale)
+{
+    unsigned char reg = ReadCommand(0x22);
+
+    if (hScale)
+        *hScale = 1 + (reg >> 2) & 0x03;
+    if (vScale)
+        *vScale = 1 + reg & 0x03;
+    return noerror;
+}
 
 int RA8875::_putc(int c)
 {
--- a/RA8875.h	Sat Aug 06 15:09:34 2016 +0000
+++ b/RA8875.h	Sat Aug 06 20:04:23 2016 +0000
@@ -293,10 +293,10 @@
         align_full      ///< align - full
     } alignment_t;    
     
-    /// Scale factor - 1, 2, 3 4
+    /// Font Horizontal Scale factor - 1, 2, 3 4
     typedef int HorizontalScale;
     
-    /// Scale factor - 1, 2, 3, 4
+    /// Font Vertical Scale factor - 1, 2, 3, 4
     typedef int VerticalScale;
 
     /// Clear screen region
@@ -1476,7 +1476,21 @@
     /// @returns success/failure code. See @ref RetCode_t.
     ///
     RetCode_t SetTextFontSize(HorizontalScale hScale = 1, VerticalScale vScale = -1);
-    
+
+
+    /// Get the text font size of the RA8875 internal fonts.
+    ///
+    /// This command lets you retrieve the current settings for the font
+    /// horizontal and vertical scale factors. The return value is 
+    /// one of the scale factors 1, 2, 3, or 4.
+    ///
+    /// @param[out] hScale is a pointer to memory where the horizontal scale factor
+    ///     will be written. If the pointer is null, that item will be ignored.
+    /// @param[out] vScale is a pointer to memory where the vertical scale factor
+    ///     will be written. If the pointer is null, that item will be ignored.
+    /// @returns success/failure code. See @ref RetCode_t.
+    ///
+    RetCode_t GetTextFontSize(HorizontalScale * hScale, VerticalScale * vScale);
 
     /// put a character on the screen.
     ///
@@ -2267,6 +2281,11 @@
     ///
     virtual RetCode_t SelectUserFont(const uint8_t * font = NULL);
 
+    /// Get the currently selected user font.
+    ///
+    /// @returns a pointer to the font, or null, if no user font is selected.
+    ///
+    virtual const uint8_t * GetUserFont(void) { return font; }
 
     /// Get the RGB value for a DOS color.
     ///
--- a/RA8875_Touch.cpp	Sat Aug 06 15:09:34 2016 +0000
+++ b/RA8875_Touch.cpp	Sat Aug 06 20:04:23 2016 +0000
@@ -248,19 +248,15 @@
             numberOfTouchPoints = 1;
 
             if (tpMatrix.Divider != 0) {
-
                 /* Operation order is important since we are doing integer */
                 /*  math. Make sure you add all terms together before      */
                 /*  dividing, so that the remainder is not rounded off     */
                 /*  prematurely.                                           */
                 touchInfo[0].coordinates.x = ( (tpMatrix.An * a2dX) +
-                                  (tpMatrix.Bn * a2dY) +
-                                  tpMatrix.Cn
+                                  (tpMatrix.Bn * a2dY) + tpMatrix.Cn
                                 ) / tpMatrix.Divider ;
-
                 touchInfo[0].coordinates.y = ( (tpMatrix.Dn * a2dX) +
-                                  (tpMatrix.En * a2dY) +
-                                  tpMatrix.Fn
+                                  (tpMatrix.En * a2dY) + tpMatrix.Fn
                                 ) / tpMatrix.Divider ;
             } else {
                 ts = no_cal;
@@ -275,8 +271,9 @@
         if (TouchPoint) {
             *TouchPoint = touchInfo[0].coordinates;
             ts = touchInfo[0].touchCode;
+        } else {
+            ts = touch;
         }
-        ts = touch;
     }
     return ts;
 }