This class drives the touch screen module of the LCD display present on DISCO_F469NI board.

Dependents:   DISCO-F469NI_LCDTS_GUI_demo Configurable_Robots DISCO-F469NI_LCDTS_demo DISCO-F469NI_LCDTS_demo ... more

Committer:
bcostm
Date:
Fri Dec 18 09:06:26 2015 +0000
Revision:
0:ee8fa51422c7
Initial version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:ee8fa51422c7 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
bcostm 0:ee8fa51422c7 2 *
bcostm 0:ee8fa51422c7 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
bcostm 0:ee8fa51422c7 4 * and associated documentation files (the "Software"), to deal in the Software without
bcostm 0:ee8fa51422c7 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
bcostm 0:ee8fa51422c7 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
bcostm 0:ee8fa51422c7 7 * Software is furnished to do so, subject to the following conditions:
bcostm 0:ee8fa51422c7 8 *
bcostm 0:ee8fa51422c7 9 * The above copyright notice and this permission notice shall be included in all copies or
bcostm 0:ee8fa51422c7 10 * substantial portions of the Software.
bcostm 0:ee8fa51422c7 11 *
bcostm 0:ee8fa51422c7 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
bcostm 0:ee8fa51422c7 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
bcostm 0:ee8fa51422c7 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
bcostm 0:ee8fa51422c7 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
bcostm 0:ee8fa51422c7 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bcostm 0:ee8fa51422c7 17 */
bcostm 0:ee8fa51422c7 18
bcostm 0:ee8fa51422c7 19 #ifndef __TS_DISCO_F469NI_H
bcostm 0:ee8fa51422c7 20 #define __TS_DISCO_F469NI_H
bcostm 0:ee8fa51422c7 21
bcostm 0:ee8fa51422c7 22 #ifdef TARGET_DISCO_F469NI
bcostm 0:ee8fa51422c7 23
bcostm 0:ee8fa51422c7 24 #include "mbed.h"
bcostm 0:ee8fa51422c7 25 #include "stm32469i_discovery_ts.h"
bcostm 0:ee8fa51422c7 26
bcostm 0:ee8fa51422c7 27 /*
bcostm 0:ee8fa51422c7 28 This class drives the touch screen module ( device) of the LCD display
bcostm 0:ee8fa51422c7 29 present on DISCO_F469NI board.
bcostm 0:ee8fa51422c7 30
bcostm 0:ee8fa51422c7 31 Usage:
bcostm 0:ee8fa51422c7 32
bcostm 0:ee8fa51422c7 33 #include "mbed.h"
bcostm 0:ee8fa51422c7 34 #include "TS_DISCO_F469NI.h"
bcostm 0:ee8fa51422c7 35
bcostm 0:ee8fa51422c7 36 TS_DISCO_F469NI ts;
bcostm 0:ee8fa51422c7 37
bcostm 0:ee8fa51422c7 38 DigitalOut led1(LED1);
bcostm 0:ee8fa51422c7 39
bcostm 0:ee8fa51422c7 40 int main()
bcostm 0:ee8fa51422c7 41 {
bcostm 0:ee8fa51422c7 42 TS_StateTypeDef TS_State;
bcostm 0:ee8fa51422c7 43
bcostm 0:ee8fa51422c7 44 ts.Init(420, 272);
bcostm 0:ee8fa51422c7 45
bcostm 0:ee8fa51422c7 46 while(1)
bcostm 0:ee8fa51422c7 47 {
bcostm 0:ee8fa51422c7 48 ts.GetState(&TS_State);
bcostm 0:ee8fa51422c7 49 if ((TS_State.touchDetected) && (TS_State.touchX[0] > 240))
bcostm 0:ee8fa51422c7 50 {
bcostm 0:ee8fa51422c7 51 led1 = 1;
bcostm 0:ee8fa51422c7 52 }
bcostm 0:ee8fa51422c7 53 else
bcostm 0:ee8fa51422c7 54 {
bcostm 0:ee8fa51422c7 55 led1 = 0;
bcostm 0:ee8fa51422c7 56 }
bcostm 0:ee8fa51422c7 57 }
bcostm 0:ee8fa51422c7 58 }
bcostm 0:ee8fa51422c7 59 */
bcostm 0:ee8fa51422c7 60 class TS_DISCO_F469NI
bcostm 0:ee8fa51422c7 61 {
bcostm 0:ee8fa51422c7 62
bcostm 0:ee8fa51422c7 63 public:
bcostm 0:ee8fa51422c7 64 //! Constructor
bcostm 0:ee8fa51422c7 65 TS_DISCO_F469NI();
bcostm 0:ee8fa51422c7 66
bcostm 0:ee8fa51422c7 67 //! Destructor
bcostm 0:ee8fa51422c7 68 ~TS_DISCO_F469NI();
bcostm 0:ee8fa51422c7 69
bcostm 0:ee8fa51422c7 70 /**
bcostm 0:ee8fa51422c7 71 * @brief Initializes and configures the touch screen functionalities and
bcostm 0:ee8fa51422c7 72 * configures all necessary hardware resources (GPIOs, I2C, clocks..);.
bcostm 0:ee8fa51422c7 73 * @param ts_SizeX : Maximum X size of the TS area on LCD
bcostm 0:ee8fa51422c7 74 * @param ts_SizeY : Maximum Y size of the TS area on LCD
bcostm 0:ee8fa51422c7 75 * @retval TS_OK if all initializations are OK. Other value if error.
bcostm 0:ee8fa51422c7 76 */
bcostm 0:ee8fa51422c7 77 uint8_t Init(uint16_t ts_SizeX, uint16_t ts_SizeY);
bcostm 0:ee8fa51422c7 78
bcostm 0:ee8fa51422c7 79 /**
bcostm 0:ee8fa51422c7 80 * @brief Configures and enables the touch screen interrupts both at GPIO level and
bcostm 0:ee8fa51422c7 81 * in TouchScreen IC driver configuration.
bcostm 0:ee8fa51422c7 82 * @retval TS_OK if all initializations are OK.
bcostm 0:ee8fa51422c7 83 */
bcostm 0:ee8fa51422c7 84 uint8_t ITConfig(void);
bcostm 0:ee8fa51422c7 85
bcostm 0:ee8fa51422c7 86 /**
bcostm 0:ee8fa51422c7 87 * @brief Returns status and positions of the touch screen.
bcostm 0:ee8fa51422c7 88 * @param TS_State: Pointer to touch screen current state structure
bcostm 0:ee8fa51422c7 89 * @retval TS_OK if all initializations are OK. Other value if error.
bcostm 0:ee8fa51422c7 90 */
bcostm 0:ee8fa51422c7 91 uint8_t GetState(TS_StateTypeDef *TS_State);
bcostm 0:ee8fa51422c7 92
bcostm 0:ee8fa51422c7 93 #if (TS_MULTI_TOUCH_SUPPORTED == 1)
bcostm 0:ee8fa51422c7 94
bcostm 0:ee8fa51422c7 95 /**
bcostm 0:ee8fa51422c7 96 * @brief Update gesture Id following a touch detected.
bcostm 0:ee8fa51422c7 97 * @param TS_State: Pointer to touch screen current state structure
bcostm 0:ee8fa51422c7 98 * @retval TS_OK if all initializations are OK. Other value if error.
bcostm 0:ee8fa51422c7 99 */
bcostm 0:ee8fa51422c7 100 uint8_t Get_GestureId(TS_StateTypeDef *TS_State);
bcostm 0:ee8fa51422c7 101
bcostm 0:ee8fa51422c7 102 /**
bcostm 0:ee8fa51422c7 103 * @brief Function used to reset all touch data before a new acquisition
bcostm 0:ee8fa51422c7 104 * of touch information.
bcostm 0:ee8fa51422c7 105 * @param TS_State: Pointer to touch screen current state structure
bcostm 0:ee8fa51422c7 106 * @retval TS_OK if OK, TE_ERROR if problem found.
bcostm 0:ee8fa51422c7 107 */
bcostm 0:ee8fa51422c7 108 uint8_t ResetTouchData(TS_StateTypeDef *TS_State);
bcostm 0:ee8fa51422c7 109
bcostm 0:ee8fa51422c7 110 #endif // (TS_MULTI_TOUCH_SUPPORTED == 1)
bcostm 0:ee8fa51422c7 111
bcostm 0:ee8fa51422c7 112 private:
bcostm 0:ee8fa51422c7 113
bcostm 0:ee8fa51422c7 114 };
bcostm 0:ee8fa51422c7 115
bcostm 0:ee8fa51422c7 116 #else
bcostm 0:ee8fa51422c7 117 #error "This class must be used with DISCO_F469NI board only."
bcostm 0:ee8fa51422c7 118 #endif // TARGET_DISCO_F469NI
bcostm 0:ee8fa51422c7 119
bcostm 0:ee8fa51422c7 120 #endif