Automate écran capacitif

Dependencies:   BSP_DISCO_F469NI LCD_DISCO_F469NI SeeedStudioTFTv2 TFT_fonts mbed

Fork of DISCO-F469NI_LCD_demo by ST

Committer:
SquirrelGod
Date:
Fri Mar 31 15:36:26 2017 +0000
Revision:
2:2182df2d7810
Programme ?cran capacitif

Who changed what in which revision?

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