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:
32:0e4f2ae512e2
Parent:
31:c72e12cd5c67
Child:
33:b6b710758ab3
--- a/RA8875.h	Mon Jan 20 19:19:48 2014 +0000
+++ b/RA8875.h	Tue Jan 21 03:28:36 2014 +0000
@@ -14,8 +14,6 @@
 // .cpp file. See also the bottom of this file.
 #define TESTENABLE
 
-#define RGB(r,g,b) ( ((r<<8)&0xF800) | ((g<<3)&0x07E0) | (b>>3) )
-
 /// DOS colors - slightly color enhanced
 #define Black       (color_t)(RGB(0,0,0))
 #define Blue        (color_t)(RGB(0,0,187))
@@ -39,24 +37,6 @@
 //namespace SW_graphics
 //{
 
-/// color type definition to let the compiler help keep us honest.
-/// 
-/// colors can be defined with the RGB(r,g,b) macro, and there
-/// are a number of predefined colors:
-/// - Black,    Blue,       Green,       Cyan,
-/// - Red,      Magenta,    Brown,       Gray,
-/// - Charcoal, BrightBlue, BrightGreen, BrightCyan,
-/// - Orange,   Pink,       Yellow,      White
-///
-typedef uint16_t color_t;   
-
-/// background fill info for drawing Text, Rectangles, RoundedRectanges, Circles, Ellipses and Triangles.
-typedef enum
-{
-    NOFILL,     ///< do not fill the object with the background color
-    FILL        ///< fill the object space with the background color
-} fill_t;
-
 /// cursor type to be shown as the text cursor.
 typedef enum
 {
@@ -87,9 +67,6 @@
 /// of column and row, which is measured in character positions (and dependent
 /// on the font size), and other text APIs permit pixel level positioning.
 ///
-/// @todo Bitmap support.
-/// @todo Bitmap support could be sped up significantly using more hw features 
-///         (e.g. graphics cursor to avoid setting x,y coords for every pixel)
 /// @todo Add Scroll support for text.
 /// @todo Add 2-Layer support.
 /// @todo Improve sync between internal and externa font support - cursor, window, scroll.
@@ -167,7 +144,7 @@
     ///     and only occurs if the data is in the range [0 - 0xFF].
     /// @returns success/failure code. @see RetCode_t.
     ///
-    RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF);
+    virtual RetCode_t WriteCommand(unsigned char command, unsigned int data = 0xFFFF);
     
     /// Write a data byte to the display
     ///
@@ -176,7 +153,7 @@
     /// @param data is the data to write.
     /// @returns success/failure code. @see RetCode_t.
     ///
-    RetCode_t WriteData(unsigned char data);
+    virtual RetCode_t WriteData(unsigned char data);
     
     /// Read a command register
     ///
@@ -229,21 +206,21 @@
     ///
     /// @returns screen width in pixels.
     ///
-    virtual int width(void);
+    virtual uint16_t width(void);
 
     /// get the screen height in pixels
     ///
     /// @returns screen height in pixels.
     ///
-    virtual int height(void);
+    virtual uint16_t height(void);
 
     /// Set cursor position based on the current font size.
     /// 
-    /// @param x is the horizontal position in character positions
-    /// @param y is the vertical position in character positions
+    /// @param column is the horizontal position in character positions
+    /// @param row is the vertical position in character positions
     /// @returns success/failure code. @see RetCode_t.
     ///
-    virtual RetCode_t locate(unsigned int x, unsigned int y);
+    virtual RetCode_t locate(unsigned int column, unsigned int row);
 
     /// Prepare the controller to write text to the screen by positioning
     /// the cursor.
@@ -369,7 +346,7 @@
     /// @param y is the vertical position in pixels (from the top edge)
     /// @returns success/failure code. @see RetCode_t.
     ///
-    RetCode_t SetMemoryCursor(unsigned int x, unsigned int y);
+    virtual RetCode_t SetGraphicsCursor(uint16_t x, uint16_t y);
     
     /// Set the window, which controls where items are written to the screen.
     ///
@@ -383,7 +360,7 @@
     /// @param height is the window height in pixels.
     /// @returns success/failure code. @see RetCode_t.
     ///
-    RetCode_t SetWindow(unsigned int x, unsigned int y, unsigned int width, unsigned int height);
+    virtual RetCode_t window(unsigned int x, unsigned int y, unsigned int width, unsigned int height);
     
     /// Clear the screen.
     ///
@@ -397,7 +374,7 @@
     ///
     /// The default behavior is to clear the whole screen. With the optional 
     /// parameter, the action can be restricted to the active window, which
-    /// can be set with the @see SetWindow method.
+    /// can be set with the @see window method.
     ///
     /// @param region is an optional parameter that defaults to FULLWINDOW
     ///         or may be set to ACTIVEWINDOW.
@@ -445,8 +422,8 @@
         
     /// Draw a pixel in the specified color.
     ///
-    /// @note As a side effect, this also sets the foreground color 
-    ///     affecting all subsequent operations.
+    /// @note As a side effect, this also sets the foreground  
+    ///     color affecting all subsequent operations.
     ///
     /// @param x is the horizontal offset to this pixel.
     /// @param y is the vertical offset to this pixel.
@@ -519,7 +496,7 @@
     /// @param fillit is optional to NOFILL the rectangle. default is FILL.
     /// @returns success/failure code. @see RetCode_t.
     ///
-    RetCode_t fillrect(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, 
+    virtual RetCode_t fillrect(unsigned int x1, unsigned int y1, unsigned int x2, unsigned int y2, 
         color_t color, fill_t fillit = FILL);
 
     /// Draw a rectangle
@@ -780,7 +757,7 @@
     ///
     RetCode_t Backlight(float brightness);
 
-    /// Set a reference to a bitmap font, provided by the user.
+    /// Select a bitmap font (provided by the user) for all subsequent text.
     ///
     /// @note Tool to create the fonts is accessible from its creator
     ///     available at http://www.mikroe.com. 
@@ -849,6 +826,45 @@
     ///
     RetCode_t init(void);
     
+    /// method indicating the start of a graphics stream.
+    ///
+    /// This is called prior to a stream of pixel data being sent.
+    /// This may cause register configuration changes in the derived
+    /// class in order to prepare the hardware to accept the streaming
+    /// data.
+    ///
+    /// Following this command, a series of @see putp() commands can
+    /// be used to send individual pixels to the screen.
+    ///
+    /// To conclude the graphics stream, @see _EndGraphicsStream should
+    /// be callled.
+    ///
+    /// @returns error code.
+    ///
+    virtual RetCode_t _StartGraphicsStream(void);
+    
+    /// method to put a single color pixel to the screen.
+    ///
+    /// This method may be called as many times as necessary after 
+    /// @see _StartGraphicsStream() is called, and it should be followed 
+    /// by _EndGraphicsStream.
+    ///
+    /// @param pixel is a color value to be put on the screen.
+    /// @returns error code.
+    ///
+    virtual RetCode_t putp(color_t pixel);
+    
+    /// method indicating the end of a graphics stream.
+    ///
+    /// This is called to conclude a stream of pixel data that was sent.
+    /// This may cause register configuration changes in the derived
+    /// class in order to stop the hardware from accept the streaming
+    /// data.
+    ///
+    /// @returns error code.
+    ///
+    virtual RetCode_t _EndGraphicsStream(void);
+
     /// Internal function to put a character using the built-in (internal) font engine
     ///
     /// @param is the character to put to the screen.