ouhh

Dependencies:   mbed

Committer:
antoine_carpentier
Date:
Fri Jun 25 20:24:25 2021 +0000
Revision:
0:e2ba640a07ba
ouhhh;

Who changed what in which revision?

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