LAST PUBLISH MATRIX PROJECT

Dependencies:   mbed

Committer:
antoine_carpentier
Date:
Tue Jun 22 11:55:19 2021 +0000
Revision:
1:7a7366246b30
last commit

Who changed what in which revision?

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