This class drives the touch screen module (FT5336 device) of the LCD display present on DISCO_F746NG board.

Dependents:   DISCO-F746NG_LCDTS_CC3000_NTP DISCO-F746NG_QSPI F746_SpectralAnalysis_NoPhoto ecte433 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TS_DISCO_F746NG.h Source File

TS_DISCO_F746NG.h

00001 /* Copyright (c) 2010-2011 mbed.org, MIT License
00002 *
00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00004 * and associated documentation files (the "Software"), to deal in the Software without
00005 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
00006 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
00007 * Software is furnished to do so, subject to the following conditions:
00008 *
00009 * The above copyright notice and this permission notice shall be included in all copies or
00010 * substantial portions of the Software.
00011 *
00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00017 */
00018 
00019 #ifndef __TS_DISCO_F746NG_H
00020 #define __TS_DISCO_F746NG_H
00021 
00022 #ifdef TARGET_DISCO_F746NG
00023 
00024 #include "mbed.h"
00025 #include "stm32746g_discovery_ts.h"
00026 
00027 /*
00028   This class drives the touch screen module (FT5336 device) of the LCD display
00029   present on DISCO_F746NG board.
00030 
00031   Usage:
00032 
00033   #include "mbed.h"
00034   #include "TS_DISCO_F746NG.h"
00035 
00036   TS_DISCO_F746NG ts;
00037 
00038   DigitalOut led1(LED1);
00039 
00040   int main()
00041   {
00042       TS_StateTypeDef TS_State;
00043     
00044       ts.Init(420, 272);
00045     
00046       while(1)
00047       {
00048         ts.GetState(&TS_State);
00049         if ((TS_State.touchDetected) && (TS_State.touchX[0] > 240))
00050         {
00051           led1 = 1;
00052         }
00053         else
00054         {
00055           led1 = 0;
00056         }
00057       }
00058   }
00059 */
00060 class TS_DISCO_F746NG
00061 {
00062   
00063 public:
00064   //! Constructor
00065   TS_DISCO_F746NG();
00066 
00067   //! Destructor
00068   ~TS_DISCO_F746NG();
00069 
00070   /**
00071     * @brief  Initializes and configures the touch screen functionalities and 
00072     *         configures all necessary hardware resources (GPIOs, I2C, clocks..);.
00073     * @param  ts_SizeX: Maximum X size of the TS area on LCD
00074     * @param  ts_SizeY: Maximum Y size of the TS area on LCD
00075     * @retval TS_OK if all initializations are OK. Other value if error.
00076     */
00077   uint8_t Init(uint16_t ts_SizeX, uint16_t ts_SizeY);
00078 
00079   /**
00080     * @brief  DeInitializes the TouchScreen.
00081     * @retval TS state
00082     */
00083   uint8_t DeInit(void);
00084 
00085   /**
00086     * @brief  Configures and enables the touch screen interrupts.
00087     * @retval TS_OK if all initializations are OK. Other value if error.
00088     */
00089   uint8_t ITConfig(void);
00090 
00091   /**
00092     * @brief  Gets the touch screen interrupt status.
00093     * @retval TS_OK if all initializations are OK. Other value if error.
00094     */
00095   uint8_t ITGetStatus(void);
00096 
00097   /**
00098     * @brief  Returns status and positions of the touch screen.
00099     * @param  TS_State: Pointer to touch screen current state structure
00100     * @retval TS_OK if all initializations are OK. Other value if error.
00101     */
00102   uint8_t GetState(TS_StateTypeDef *TS_State);
00103 
00104   /**
00105     * @brief  Update gesture Id following a touch detected.
00106     * @param  TS_State: Pointer to touch screen current state structure
00107     * @retval TS_OK if all initializations are OK. Other value if error.
00108     */
00109   uint8_t Get_GestureId(TS_StateTypeDef *TS_State);
00110 
00111   /**
00112     * @brief  Clears all touch screen interrupts.
00113     */
00114   void ITClear(void);
00115 
00116   /**
00117     * @brief  Function used to reset all touch data before a new acquisition
00118     *         of touch information.
00119     * @param  TS_State: Pointer to touch screen current state structure
00120     * @retval TS_OK if OK, TE_ERROR if problem found.
00121     */
00122   uint8_t ResetTouchData(TS_StateTypeDef *TS_State);
00123 
00124 private:
00125 
00126 };
00127 
00128 #else
00129 #error "This class must be used with DISCO_F746NG board only."
00130 #endif // TARGET_DISCO_F746NG
00131 
00132 #endif