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:
83:7bad0068cca0
Parent:
82:f7d300f26540
Child:
84:e102021864b5
--- a/RA8875.h	Tue Dec 30 23:45:37 2014 +0000
+++ b/RA8875.h	Thu Jan 01 20:35:37 2015 +0000
@@ -468,9 +468,14 @@
     /// 
     /// @param[out] x is the x scale a/d value.
     /// @param[out] y is the y scale a/d value.
-    /// @returns true if touch was detected, in which case the x and y values were set.
+    /// @returns a value indicating the state of the touch,
+    ///         - no_cal:   no calibration matrix is available, touch coordinates are not returned.
+    ///         - no_touch: no touch is detected, touch coordinates are not returned.
+    ///         - touch:    touch is detected, touch coordinates are returned.
+    ///         - held:     held after touch, touch coordinates are returned.
+    ///         - release:  indicates a release, touch coordinates are returned.
     ///
-    bool TouchPanelA2DFiltered(loc_t *x, loc_t *y);
+    TouchCode_t TouchPanelA2DFiltered(int *x, int *y);
 
     /// Poll the TouchPanel and on a touch event return the a to d raw x, y coordinates.
     ///
@@ -486,10 +491,45 @@
     /// 
     /// @param[out] x is the x scale a/d value.
     /// @param[out] y is the y scale a/d value.
-    /// @returns true if touch was detected, in which case the x and y values were set.
+    /// @returns a value indicating the state of the touch,
+    ///         - no_cal:   no calibration matrix is available, touch coordinates are not returned.
+    ///         - no_touch: no touch is detected, touch coordinates are not returned.
+    ///         - touch:    touch is detected, touch coordinates are returned.
+    ///         - held:     held after touch, touch coordinates are returned.
+    ///         - release:  indicates a release, touch coordinates are returned.
+    ///
+    TouchCode_t TouchPanelA2DRaw(int *x, int *y);
+    
+    /// Get the screen calibrated point of touch.
+    ///
+    /// This method determines if there is a touch and if so it will provide
+    /// the screen-relative touch coordinates. This method can be used in
+    /// a manner similar to Serial.readable(), to determine if there was a 
+    /// touch and indicate that - but not care about the coordinates. Alternately,
+    /// if a valid pointer to a point_t is provided, then if a touch is detected
+    /// the point_t will be populated with data. 
     ///
-    bool TouchPanelA2DRaw(loc_t *x, loc_t *y);
-    
+    /// @code
+    ///     Timer t;
+    ///     t.start();
+    ///     do {
+    ///        point_t point = {0, 0};
+    ///        if (display.TouchPanelReadable(&point)) {
+    ///            display.pixel(point.x, point.y, Red);
+    ///        }
+    ///    } while (t.read_ms() < 30000);
+    /// @endcode
+    ///
+    /// @param[out] touch is the touch point, if a touch is registered.
+    /// @returns a value indicating the state of the touch,
+    ///         - no_cal:   no calibration matrix is available, touch coordinates are not returned.
+    ///         - no_touch: no touch is detected, touch coordinates are not returned.
+    ///         - touch:    touch is detected, touch coordinates are returned.
+    ///         - held:     held after touch, touch coordinates are returned.
+    ///         - release:  indicates a release, touch coordinates are returned.
+    ///
+    TouchCode_t TouchPanelReadable(point_t * touch = NULL);
+
     /// Calibrate the touch panel.
     ///
     /// This method accepts two lists - one list is target points in ,
@@ -569,32 +609,6 @@
     ///
     RetCode_t TouchPanelCalibrate(const char * msg, tpMatrix_t * matrix = NULL);
 
-    /// Get the screen calibrated point of touch.
-    ///
-    /// This method determines if there is a touch and if so it will provide
-    /// the screen-relative touch coordinates. This method can be used in
-    /// a manner similar to Serial.readable(), to determine if there was a 
-    /// touch and indicate that - but not care about the coordinates. Alternately,
-    /// if a valid pointer to a point_t is provided, then if a touch is detected
-    /// the point_t will be populated with data. 
-    ///
-    /// @code
-    ///     Timer t;
-    ///     t.start();
-    ///     do {
-    ///        point_t point = {0, 0};
-    ///        if (display.TouchPanelReadable(&point)) {
-    ///            display.pixel(point.x, point.y, Red);
-    ///        }
-    ///    } while (t.read_ms() < 30000);
-    /// @endcode
-    ///
-    /// @param[out] touch is the touch point, if a touch is registered.
-    /// @returns true if a touch was registered, and touch is updated.
-    /// @returns false if no touch was detected, or if the calibration matrix is not defined.
-    ///
-    bool TouchPanelReadable(point_t * touch = NULL);
-
     /// Wait for a touch panel touch and return it.
     /// 
     /// This method is similar to Serial.getc() in that it will wait for a touch
@@ -1204,6 +1218,28 @@
     /// @note As a side effect, this changes the current
     ///     foreground color for subsequent operations.
     ///
+    /// @param[in] p1 is the point to start the line.
+    /// @param[in] p2 is the point to end the line.
+    /// @param[in] color defines the foreground color.
+    /// @returns success/failure code. @see RetCode_t.
+    ///
+    RetCode_t line(point_t p1, point_t p2, color_t color);
+
+    /// Draw a line
+    ///
+    /// Draws a line using the foreground color setting.
+    ///
+    /// @param[in] p1 is the point to start the line.
+    /// @param[in] p2 is the point to end the line.
+    /// @returns success/failure code. @see RetCode_t.
+    ///
+    RetCode_t line(point_t p1, point_t p2);
+    
+    /// Draw a line in the specified color
+    ///
+    /// @note As a side effect, this changes the current
+    ///     foreground color for subsequent operations.
+    ///
     /// @param[in] x1 is the horizontal start of the line.
     /// @param[in] y1 is the vertical start of the line.
     /// @param[in] x2 is the horizontal end of the line.
@@ -1424,6 +1460,41 @@
     RetCode_t triangle(loc_t x1, loc_t y1, loc_t x2, loc_t y2, 
         loc_t x3, loc_t y3, fill_t fillit = NOFILL);
     
+
+    /// Draw a circle using the specified color.
+    ///
+    /// @note As a side effect, this changes the current
+    ///     foreground color for subsequent operations.
+    ///
+    /// @param[in] p defines the center of the circle.
+    /// @param[in] radius defines the size of the circle.
+    /// @param[in] color defines the foreground color.
+    /// @returns success/failure code. @see RetCode_t.
+    ///
+    RetCode_t circle(point_t p, dim_t radius, color_t color, fill_t fillit = NOFILL);
+
+    /// Draw a filled circle using the specified color.
+    ///
+    /// @note As a side effect, this changes the current
+    ///     foreground color for subsequent operations.
+    ///
+    /// @param[in] p defines the center of the circle.
+    /// @param[in] radius defines the size of the circle.
+    /// @param[in] color defines the foreground color.
+    /// @returns success/failure code. @see RetCode_t.
+    ///
+    RetCode_t fillcircle(point_t p, dim_t radius, color_t color, fill_t fillit = FILL);
+
+    /// Draw a circle.
+    ///
+    /// Draws a circle using the foreground color setting.
+    ///
+    /// @param[in] p defines the center of the circle.
+    /// @param[in] radius defines the size of the circle.
+    /// @returns success/failure code. @see RetCode_t.
+    ///
+    RetCode_t circle(point_t p, dim_t radius, fill_t fillit = NOFILL);
+
     /// Draw a circle using the specified color.
     ///
     /// @note As a side effect, this changes the current
@@ -1720,6 +1791,27 @@
     /// Other Touch Panel params
     #define TPBUFSIZE   16       // Depth of the averaging buffers for x and y data
 
+    // Needs both a ticker and a timer. (could have created a timer from the ticker, but this is easier).
+    // on a touch, the timer is reset.
+    // the ticker monitors the timer to see if it has been a long time since
+    // a touch, and if so, it then clears the sample counter so it doesn't get partial old
+    // and partial new.
+    
+    /// Touch State used by TouchPanelReadable. @see TouchCode_t.
+    TouchCode_t touchState;
+
+    /// Touch Panel ticker
+    Ticker touchTicker;
+    
+    /// Touch Panel timer
+    Timer touchTimer;
+    
+    /// keeps track of which sample we're collecting to filter out the noise.
+    int touchSample;
+    
+    /// Private function for touch ticker callback.
+    void _TouchTicker(void);
+    
     /// Touch Panel calibration matrix.
     tpMatrix_t tpMatrix;
 
@@ -1842,7 +1934,6 @@
 //     /__/      /_____________/ /_____________/       /__/
 
 #include "WebColors.h"
-#include "Arial12x12.h"
 #include <algorithm>
 
 extern "C" void mbed_reset();