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:
75:ca78388cfd77
Parent:
74:686faa218914
Child:
76:c981284eb513
--- a/RA8875.h	Sun Nov 09 20:38:49 2014 +0000
+++ b/RA8875.h	Fri Nov 28 22:37:53 2014 +0000
@@ -8,11 +8,11 @@
 
 // Define this to enable code that monitors the performance of various
 // graphics commands.
-//#define PERF_METRICS
+#define PERF_METRICS
 
 // What better place for some test code than in here and the companion
 // .cpp file. See also the bottom of this file.
-//#define TESTENABLE
+#define TESTENABLE
 
 /// DOS colors - slightly color enhanced
 #define Black       (color_t)(RGB(0,0,0))
@@ -85,8 +85,7 @@
 ///
 /// @todo Add Scroll support for text.
 /// @todo Improve sync between internal and external font support - cursor, window, scroll.
-/// @todo Add Hardware reset signal.
-/// @todo Add Keypad Support.
+/// @todo Add Hardware reset signal - but testing to date indicates it is not needed.
 /// @todo Add high level objects - x-y graph, meter, others... but these will
 ///     probably be best served in another class, since they may not
 ///     be needed for many uses.
@@ -363,6 +362,7 @@
     ///
     uint8_t TouchPanelReadRaw(loc_t *x, loc_t *y);
     
+#if 0
     /// Append interrupt handler for specific RA8875 interrupt source
     ///
     /// @param[in]    bISRType        Interrupt Source, should be:
@@ -387,8 +387,7 @@
     /// @return       none
     ///
     void UnAppendISR(uint8_t bISRType);
-
-
+#endif
     /// Initialize the keypad interface on the RA8875 controller.
     ///
     /// Enables the keypad subsystem. It will scan the 4 x 5 matrix
@@ -414,11 +413,43 @@
         uint8_t longTimeAdjustment = 0,
         bool interruptEnable = false, bool wakeupEnable = false);
 
+    /// Create Key Code definitions for the key matrix.
+    ///
+    /// This API provides a table of 22 key-code assignments for the matrix of keys.
+    /// This can be used to translate the keys 1 - 20 into some other value, as
+    /// well as to communicate the "no key" (zero) and "error state" (21).
+    ///
+    /// In this way, a keypad could easily emulate a piece of a keyboard, transforming
+    /// 0 - 20 into the values 0, '0', '1', '2', '3', '4', '5', '6', '7', '8',
+    /// '9', '+', '-', '*' , '/', '=', '<bs>', '<cr>', and so on...
+    ///
+    /// @code
+    /// //        Return Value by Row, Column   Example reassignment
+    /// //    Column    0    1    2    3    4 
+    /// //          +-------------------------+  +-------------------------+
+    /// // Row   0  |   1    2    3    4    5 |  | '7'  '8'  '9'  ' '  ' ' |
+    /// //       1  |   6    7    8    9   10 |  | '4'  '5'  '6'  '/'  '-' |
+    /// //       2  |  11   12   13   14   15 |  | '1'  '2'  '3'  '*'  '+' |
+    /// //       3  |  16   17   18   19   20 |  | '0'  '.'  ','  ' ' '\n' |
+    /// //          +-------------------------+  +-------------------------+
+    /// //     Return value  0 = No Key pressed
+    /// //     Return value 21 = Error
+    /// @endcode
+    /// 
+    /// @param[in] CodeList is a pointer to an always available byte-array 
+    ///             where the first 22 bytes are used as the transformation 
+    ///             from raw code to your reassigned value.
+    ///            If CodeList is NULL, the original raw value key map is
+    ///             restored.
+    /// @returns noerror.
+    ///
+    RetCode_t SetKeyMap(const uint8_t * CodeList = NULL);
+
     /// Determine if a key has been hit
     ///
     /// @returns true if a key has been hit
     ///
-    bool _kbhit();
+    bool readable();
 
     /// Blocking read of the keypad.
     ///
@@ -426,26 +457,18 @@
     ///         to avoid hanging your processes.
     ///
     /// A keypad connected to the RA8875 is connected in a matrix of 4 rows and 5 columns.
-    /// The row where a key is pressed is returned in the lower 2 bits of the upper nibble,
-    /// and the column where a key is pressed is returned in the lower 3 bits of the lower nibble.
+    /// When pressed, this method will return a code in the range of 1 through 20, reserving
+    /// the value 0 to indicate that no key is pressed.
     ///
     /// Additionally, if configured to detect a "long press", bit 7 will be set to indicate
     /// this. In this situation, first a "normal press" would be detected and signaled and
     /// soon after that a "long press" of the same key would be detected and communicated.
     ///
-    /// Return value encoding: LxRR xCCC
-    /// L = Long Press was detected
-    /// RR = Row number 0 to 3
+    /// @return 8-bit where bit 7 indicates a long press. The remaining bits indicate the
+    ///     keypress using 0 = no key pressed, 1 - 20 = the key pressed.
     ///
-    /// @return 8-bit value coded as L0RR 0CCC:
-    ///     - L = 1 = Long Press detected
-    ///     - x = 0 = not used
-    ///     - R = 0-3 = Row Number
-    ///     - C = 0-4 = Column Number
-    ///
-    uint8_t _getch();
-
-
+    uint8_t getc();
+    
     /// Write a command to the display with a word of data.
     ///
     /// This is a high level command, and may invoke several primitives.
@@ -1505,6 +1528,8 @@
     ///
     unsigned char spiread();
     
+    const uint8_t * pKeyMap;
+    
     SPI spi;                        ///< spi port
     bool spiWriteSpeed;             ///< indicates if the current mode is write or read
     unsigned long spiwritefreq;     ///< saved write freq
@@ -1531,7 +1556,7 @@
         METRICCOUNT
     } method_e;
     unsigned long metrics[METRICCOUNT];
-    unsigned long idlecounter;
+    unsigned long idletime_usec;
     void RegisterPerformance(method_e method);
     Timer performance;
     #endif