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:
61:8f3153bf0baa
Parent:
58:26658a56112a
Child:
62:ba5d33438fda
--- a/RA8875.h	Sat Aug 16 19:26:17 2014 +0000
+++ b/RA8875.h	Sun Aug 17 13:46:06 2014 +0000
@@ -32,6 +32,14 @@
 #define Yellow      (color_t)(RGB(255,255,85))
 #define White       (color_t)(RGB(255,255,255))
 
+#define DarkBlue    (color_t)(RGB(0,0,64))
+#define DarkGreen   (color_t)(RGB(0,64,0))
+#define DarkCyan    (color_t)(RGB(0,64,64))
+#define DarkRed     (color_t)(RGB(64,0,0))
+#define DarkMagenta (color_t)(RGB(64,0,64))
+#define DarkBrown   (color_t)(RGB(64,64,0))
+#define DarkGray    (color_t)(RGB(64,64,64))
+
 #define BrightRed   (color_t)(RGB(255,0,0))
 
 //namespace SW_graphics
@@ -132,10 +140,10 @@
         ACTIVEWINDOW    ///< active window/region
     } Region_t;
     
-    /// Set the Layer 1/2 Display Mode
+    /// Set the Layer Display Mode. @ref SetLayerMode
     typedef enum
     {
-        ShowLayer0,         ///< Only layer 0 is visible, layer 1 is hidden
+        ShowLayer0,         ///< Only layer 0 is visible, layer 1 is hidden (default)
         ShowLayer1,         ///< Only layer 1 is visible, layer 0 is hidden
         LightenOverlay,     ///< Lighten-overlay mode
         TransparentMode,    ///< Transparent mode
@@ -154,6 +162,8 @@
     /// Constructor for a display based on the RAiO RA8875 
     /// display controller.
     ///
+    /// This configures the registers and calls the @ref init method.
+    ///
     /// @code
     /// #include "RA8875.h"
     /// RA8875 lcd(p5, p6, p7, p12, NC, "tft");
@@ -198,23 +208,46 @@
     ///     lcd.SetLayerMode(ShowLayer1);
     /// @endcode
     ///
-    /// @note The user manual refers to Layer 1 and Layer 2, however the
-    ///     actual register values are value 0 and 1. This and other APIs
-    ///     that reference the layers use the values 0 and 1.
+    /// @attention The user manual refers to Layer 1 and Layer 2, however the
+    ///     actual register values are value 0 and 1. This API as well as
+    ///     others that reference the layers use the values 0 and 1 for
+    ///     cleaner iteration in the code.
     ///
-    /// @param layer selects the layer for subsequence commands, where
-    ///     the values 0 and 1 represent layers 1 and 2 (as referred
-    ///     to in the user manual).
+    /// @param layer is 0 or 1 to select the layer for subsequent 
+    ///     commands.
     /// @returns success/failure code. @see RetCode_t.
     ///
     RetCode_t SelectDrawingLayer(uint16_t layer);
     
+    /// Get the currently active drawing layer.
+    ///
+    /// This returns a value, 0 or 1, based on the screen configuration
+    /// and the currently active drawing layer.
+    ///
+    /// @code
+    ///     uint16_t prevLayer = lcd.GetDrawingLayer();
+    ///     lcd.SelectDrawingLayer(x);
+    ///     lcd.circle(400,25, 25, BrightRed);
+    ///     lcd.SelectDrawingLayer(prevLayer);
+    /// @endcode
+    ///
+    /// @attention The user manual refers to Layer 1 and Layer 2, however the
+    ///     actual register values are value 0 and 1. This API as well as
+    ///     others that reference the layers use the values 0 and 1 for
+    ///     cleaner iteration in the code.
+    ///
+    /// @returns the current drawing layer; 0 or 1.
+    /// 
+    uint16_t GetDrawingLayer(void);
+    
     /// Set the Layer presentation mode.
     ///
     /// This sets the presentation mode for layers, and permits showing
     /// a single layer, or applying a mode where the two layers
     /// are combined using one of the hardware methods.
     ///
+    /// Refer to the RA8875 data sheet for full details.
+    ///
     /// @code
     ///     //lcd.SetLayerMode(OnlyLayer0); // default is layer 0
     ///     lcd.rect(400,130, 475,155,Brown);
@@ -654,17 +687,25 @@
     ///
     virtual RetCode_t window(loc_t x, loc_t y, dim_t width, dim_t height);
     
-    /// Clear the screen.
+    /// Clear either the specified layer, or the active layer.
     ///
-    /// The behavior is to clear the whole screen. @see clsw().
+    /// The behavior is to clear the whole screen for the specified
+    /// layer. When not specified, the active drawing layer is cleared.
+    /// This command can also be used to specifically clear either,
+    /// or both layers. @see clsw().
     ///
     /// @code
     ///     lcd.cls();
     /// @endcode
     ///
+    /// @param layers is optional. If not provided, the active layer
+    ///     is cleared. If bit 0 is set, layer 0 is cleared, if bit
+    ///     1 is set, layer 1 is cleared. If both are set, both layers
+    ///     are cleared. Any other value does not cause an action.
+    ///     
     /// @returns success/failure code. @see RetCode_t.
     ///
-    virtual RetCode_t cls(void);
+    virtual RetCode_t cls(uint16_t layers = 0);
     
     /// Clear the screen, or clear only the active window.
     ///
@@ -1258,7 +1299,7 @@
 
 
     /// Initialize the chip, which is normally done as part of the
-    /// constructor, so not called by the user.
+    /// constructor, so not typically called by the user.
     ///
     /// @note This API permits configuration, however it is not [yet]
     ///     available to the end user. Be sure the parameters