KSM edits to RA8875

Dependents:   Liz_Test_Code

Revision:
157:1565f38ca44b
Parent:
156:4bdb2772128d
Child:
162:a2d7f1988711
Child:
172:7abb03bf31be
--- a/RA8875.h	Mon Nov 19 02:21:41 2018 +0000
+++ b/RA8875.h	Wed Jan 02 23:42:15 2019 +0000
@@ -439,7 +439,7 @@
     ///
     /// int main()
     /// {
-    ///     lcd.init();
+    ///     lcd.init();     // defaults for 480x272x16 at low brightness
     ///     lcd.printf("printing 3 x 2 = %d", 3*2);
     ///     lcd.circle(400,25, 25, BrightRed);
     /// }
@@ -521,7 +521,9 @@
     ///             and the default is 16.
     /// @param[in] poweron defines if the display should be initialized into the power-on or off state.
     ///            If power is non-zero(on), the backlight is set to this value. This parameter is optional
-    ///             and the default is 255 (on and full brightness). See @ref Power.
+    ///             and the default is 40 (on at a low brightness level because many users power
+    ///             the module from their PC USB port and it often cannot support the curent
+    ///             required for full brightness). See @ref Power.
     /// @param[in] keypadon defines if the keypad support should be enabled. This parameter is optional
     ///             and the default is true (enabled). See @ref KeypadInit.
     /// @param[in] touchscreeenon defines if the touchscreen support should be enabled. 
@@ -533,7 +535,7 @@
     /// @returns success/failure code. See @ref RetCode_t.
     ///
     RetCode_t init(int width = 480, int height = 272, int color_bpp = 16, 
-        uint8_t poweron = 255, bool keypadon = true, bool touchscreeenon = true);
+        uint8_t poweron = 40, bool keypadon = true, bool touchscreeenon = true);
 
 
     /// Get a pointer to the error code.
@@ -686,6 +688,9 @@
     /// most uses. The alternate API is available if fine-grained control
     /// of the numerous settings of the resistive panel is needed.
     ///
+    /// Additionally, for an even simpler interface for most RESISTIVE
+    /// touch use cases, the init() method can perform the calibration.
+    ///
     /// @returns success/failure code. See @ref RetCode_t.
     ///
     RetCode_t TouchPanelInit(void);
@@ -932,6 +937,37 @@
     TouchCode_t TouchPanelGet(point_t * TouchPoint);
 
 
+    /// Configuration Option for the Resistive Touch Panel Calibration.
+    ///
+    /// This method is only useful for the resistive touchscreen.
+    ///
+    /// Also, this method is optional - the user can take all of the responsibility
+    /// in their code, or for simplicity sake, this API can be used prior
+    /// to the init method.
+    ///
+    /// @code
+    ///     RA8875 lcd(p5, p6, p7, p12, NC);
+    ///     ...
+    ///     // Be sure you previously mounted the "/sd" file system to put the cal there.
+    ///     lcd.ResTouchPanelCfg("/sd/tpcal.cfg", "Touch '+' to calibrate the touch panel");
+    ///
+    ///     // Only if the touch panel is enabled, AND is configured as the resistive 
+    ///     // panel will the prior command be useful.
+    ///     lcd.init(LCD_W,LCD_H,LCD_C,40, false, true);
+    ///
+    /// @endcode
+    ///
+    /// @param[in] tpFQFN is a pointer to a fully qualified read-write accessible
+    ///     filename where the calibration is held.
+    /// @param[in] tpCalMessage is an optional pointer to a message shown to the
+    ///     user in the calibration process. 
+    ///     - If this parameter is not included, a default message will be shown.
+    ///     - If this parameter points to a NULL string, no message is shown.
+    ///     - If this parameter points to a non-NULL string, that string will be shown.
+    ///
+    void ResTouchPanelCfg(const char * tpFQFN = NULL, const char * tpCalMessage = NULL);
+
+
     /// Calibrate the touch panel.
     ///
     /// This method accepts two lists - one list is target points in ,
@@ -1016,7 +1052,7 @@
     RetCode_t TouchPanelCalibrate(const char * msg, tpMatrix_t * matrix = NULL, int maxwait_s = 30);
 
 
-    /// Set the calibration matrix for the touch panel.
+    /// Set the calibration matrix for the resistive touch panel.
     ///
     /// This method is used to set the calibration matrix for the touch panel. After
     /// performing the calibration (See @ref TouchPanelComputeCalibration), the matrix can be stored.
@@ -1039,7 +1075,16 @@
     /// @returns success/failure code. See @ref RetCode_t.
     ///
     RetCode_t TouchPanelSetMatrix(tpMatrix_t * matrix);
-   
+
+    /// Get the calibration matrix for the resistive touch panel.
+    ///
+    /// This method returns a const pointer to the matrix. If this matrix has
+    /// not be set, with either the TouchPanelSetMatrix API or the calibration
+    /// process, the results are indeterminate.
+    ///
+    /// return const tpMatrix_t pointer
+    /// 
+    const tpMatrix_t * TouchPanelGetMatrix();
 
 #if 0
     /// Append interrupt handler for specific RA8875 interrupt source
@@ -2851,6 +2896,16 @@
     /// Touch Panel calibration matrix.
     tpMatrix_t tpMatrix;
 
+    /// RESISTIVE TP: The fully qualified filename for the RESISTIVE touch panel configuration settings.
+    const char * tpFQFN;
+    
+    /// RESISTIVE TP: The text message shown to the user during the calibration process.
+    const char * tpCalMessage;
+
+    /// Internal method that performs the TS Cal when the user has so-configured it
+    RetCode_t _internal_ts_cal();
+
+
     ////////////////// End of Touch Panel parameters