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:
66:468a11f05580
Parent:
62:ba5d33438fda
Child:
68:ab08efabfc88
--- a/RA8875.h	Sun Aug 17 15:38:51 2014 +0000
+++ b/RA8875.h	Sun Aug 31 14:37:37 2014 +0000
@@ -85,7 +85,6 @@
 ///
 /// @todo Add Scroll support for text.
 /// @todo Improve sync between internal and external font support - cursor, window, scroll.
-/// @todo Find out why it can't shift frequency after constructor runs.
 /// @todo Add Hardware reset signal.
 /// @todo Add Keypad Support.
 /// @todo Add high level objects - x-y graph, meter, others... but these will
@@ -1200,17 +1199,23 @@
 
     /// Set the SPI port frequency (in Hz).
     ///
-    /// @note attempts to call this API at runtime, with the display
-    ///         already online, cause the system to lockup. 
-    ///         Investigation continues.
+    /// This uses the mbed SPI driver, and is therefore dependent on
+    /// its capabilities. The RA8875 can accept writes via SPI faster
+    /// than a read can be performed. The frequency set by this API
+    /// is for the SPI writes. It will automatically reduce the SPI
+    /// clock rate when a read is performed, and restore it for the 
+    /// next write.
     ///
-    /// This uses the mbed SPI driver, and is therefore dependent on
-    /// its capabilities. Limited tests were performed for the display
-    /// in the range of 1,000,000 to 10,000,000 Hz. The display was
-    /// a bit erratic above 5,000,000 Hz, so this became the default,
-    /// even though it might have been the bench-level wiring that posed
-    /// the limit.
+    /// @note The primary effect of this is to recover more CPU cycles
+    ///     for your application code. Keep in mind that when more than
+    ///     one command is sent to the display controller, that it
+    ///     will wait for the controller to finish the prior command.
+    ///     In this case, the performance is limited by the RA8875.
     ///
+    /// @param Hz is the frequency in Hz, tested range includes the
+    ///     range from 1,000,000 (1MHz) to 10,000,000 (10 MHz). Values
+    ///     outside this range will be accepted, but operation may
+    ///     be unreliable.
     /// @returns success/failure code. @see RetCode_t.
     ///
     RetCode_t frequency(unsigned long Hz = RA8875_DEFAULT_SPI_FREQ);
@@ -1220,6 +1225,12 @@
     /// Clear the performance metrics to zero.
     void ClearPerformance();
     
+    /// Count idle time.
+    ///
+    /// @param t is the amount of idle time to accumulate.
+    ///
+    void CountIdleTime(uint32_t t);
+    
     /// Report the performance metrics for drawing functions using
     /// the available serial channel.
     ///
@@ -1337,6 +1348,23 @@
     ///
     RetCode_t select(bool chipsel);
 
+    /// Wait while the status register indicates the controller is busy.
+    ///
+    /// @param mask is the mask of bits to monitor.
+    /// @returns true if a normal exit.
+    /// @returns false if a timeout exit.
+    ///
+    bool _WaitWhileBusy(uint8_t mask);
+
+    /// Wait while the the register anded with the mask is true.
+    ///
+    /// @param reg is the register to monitor
+    /// @param mask is the bit mask to monitor
+    /// @returns true if it was a normal exit
+    /// @returns false if it was a timeout that caused the exit.
+    ///
+    bool _WaitWhileReg(uint8_t reg, uint8_t mask);
+
     /// The most primitive - to write a data value to the SPI interface.
     ///
     /// @param data is the value to write.
@@ -1356,6 +1384,8 @@
     unsigned char spiread();
     
     SPI spi;                        ///< spi port
+    unsigned long spiwritefreq;          ///< saved write freq
+    unsigned long spireadfreq;      ///< saved read freq
     DigitalOut cs;                  ///< chip select pin, assumed active low
     DigitalOut res;                 ///< reset pin, assumed active low
     const unsigned char * font;     ///< reference to an external font somewhere in memory
@@ -1378,6 +1408,7 @@
         METRICCOUNT
     } method_e;
     unsigned long metrics[METRICCOUNT];
+    unsigned long idlecounter;
     void RegisterPerformance(method_e method);
     Timer performance;
     #endif