DISCO-F469NI_LCDTS_Test
Dependencies: mbed LCD_DISCO_F469NI BSP_DISCO_F469NI
Revision 0:7082d958eabc, committed 2021-04-27
- Comitter:
- junpapa
- Date:
- Tue Apr 27 10:55:10 2021 +0000
- Commit message:
- TSLCD_TEST
Changed in this revision
diff -r 000000000000 -r 7082d958eabc BSP_DISCO_F469NI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/BSP_DISCO_F469NI.lib Tue Apr 27 10:55:10 2021 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/BSP_DISCO_F469NI/#3cdfcc4f7c9d
diff -r 000000000000 -r 7082d958eabc LCD_DISCO_F469NI.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LCD_DISCO_F469NI.lib Tue Apr 27 10:55:10 2021 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/ST/code/LCD_DISCO_F469NI/#d38374480318
diff -r 000000000000 -r 7082d958eabc TS_DISCO_F469NI/TS_DISCO_F469NI.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F469NI/TS_DISCO_F469NI.cpp Tue Apr 27 10:55:10 2021 +0000 @@ -0,0 +1,68 @@ +/* Copyright (c) 2010-2011 mbed.org, MIT License +* +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software +* and associated documentation files (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or +* substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include "TS_DISCO_F469NI.h" + +// Constructor +TS_DISCO_F469NI::TS_DISCO_F469NI() +{ + BSP_TS_Init(100, 100); +} + +// Destructor +TS_DISCO_F469NI::~TS_DISCO_F469NI() +{ + +} + +//================================================================================================================= +// Public methods +//================================================================================================================= + +uint8_t TS_DISCO_F469NI::Init(uint16_t ts_SizeX, uint16_t ts_SizeY) +{ + return BSP_TS_Init(ts_SizeX, ts_SizeY); +} + +uint8_t TS_DISCO_F469NI::ITConfig(void) +{ + return BSP_TS_ITConfig(); +} + +uint8_t TS_DISCO_F469NI::GetState(TS_StateTypeDef *TS_State) +{ + return BSP_TS_GetState(TS_State); +} + +#if (TS_MULTI_TOUCH_SUPPORTED == 1) + +uint8_t TS_DISCO_F469NI::Get_GestureId(TS_StateTypeDef *TS_State) +{ + return BSP_TS_Get_GestureId(TS_State); +} + +uint8_t TS_DISCO_F469NI::ResetTouchData(TS_StateTypeDef *TS_State) +{ + return BSP_TS_ResetTouchData(TS_State); +} + +#endif // (TS_MULTI_TOUCH_SUPPORTED == 1) + +//================================================================================================================= +// Private methods +//=================================================================================================================
diff -r 000000000000 -r 7082d958eabc TS_DISCO_F469NI/TS_DISCO_F469NI.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TS_DISCO_F469NI/TS_DISCO_F469NI.h Tue Apr 27 10:55:10 2021 +0000 @@ -0,0 +1,120 @@ +/* Copyright (c) 2010-2011 mbed.org, MIT License +* +* Permission is hereby granted, free of charge, to any person obtaining a copy of this software +* and associated documentation files (the "Software"), to deal in the Software without +* restriction, including without limitation the rights to use, copy, modify, merge, publish, +* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or +* substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING +* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __TS_DISCO_F469NI_H +#define __TS_DISCO_F469NI_H + +#ifdef TARGET_DISCO_F469NI + +#include "mbed.h" +#include "stm32469i_discovery_ts.h" + +/* + This class drives the touch screen module ( device) of the LCD display + present on DISCO_F469NI board. + + Usage: + + #include "mbed.h" + #include "TS_DISCO_F469NI.h" + + TS_DISCO_F469NI ts; + + DigitalOut led1(LED1); + + int main() + { + TS_StateTypeDef TS_State; + + ts.Init(420, 272); + + while(1) + { + ts.GetState(&TS_State); + if ((TS_State.touchDetected) && (TS_State.touchX[0] > 240)) + { + led1 = 1; + } + else + { + led1 = 0; + } + } + } +*/ +class TS_DISCO_F469NI +{ + +public: + //! Constructor + TS_DISCO_F469NI(); + + //! Destructor + ~TS_DISCO_F469NI(); + + /** + * @brief Initializes and configures the touch screen functionalities and + * configures all necessary hardware resources (GPIOs, I2C, clocks..);. + * @param ts_SizeX : Maximum X size of the TS area on LCD + * @param ts_SizeY : Maximum Y size of the TS area on LCD + * @retval TS_OK if all initializations are OK. Other value if error. + */ + uint8_t Init(uint16_t ts_SizeX, uint16_t ts_SizeY); + + /** + * @brief Configures and enables the touch screen interrupts both at GPIO level and + * in TouchScreen IC driver configuration. + * @retval TS_OK if all initializations are OK. + */ + uint8_t ITConfig(void); + + /** + * @brief Returns status and positions of the touch screen. + * @param TS_State: Pointer to touch screen current state structure + * @retval TS_OK if all initializations are OK. Other value if error. + */ + uint8_t GetState(TS_StateTypeDef *TS_State); + +#if (TS_MULTI_TOUCH_SUPPORTED == 1) + + /** + * @brief Update gesture Id following a touch detected. + * @param TS_State: Pointer to touch screen current state structure + * @retval TS_OK if all initializations are OK. Other value if error. + */ + uint8_t Get_GestureId(TS_StateTypeDef *TS_State); + + /** + * @brief Function used to reset all touch data before a new acquisition + * of touch information. + * @param TS_State: Pointer to touch screen current state structure + * @retval TS_OK if OK, TE_ERROR if problem found. + */ + uint8_t ResetTouchData(TS_StateTypeDef *TS_State); + +#endif // (TS_MULTI_TOUCH_SUPPORTED == 1) + +private: + +}; + +#else +#error "This class must be used with DISCO_F469NI board only." +#endif // TARGET_DISCO_F469NI + +#endif
diff -r 000000000000 -r 7082d958eabc main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Apr 27 10:55:10 2021 +0000 @@ -0,0 +1,105 @@ +#include "mbed.h" +#include "TS_DISCO_F469NI.h" +#include "LCD_DISCO_F469NI.h" + +LCD_DISCO_F469NI lcd; +TS_DISCO_F469NI ts; + +DigitalIn Key_Chk(USER_BUTTON); +DigitalOut led1(LED1); + +int main() +{ + TS_StateTypeDef TS_State; + uint16_t x, y; + uint8_t text[30]; + uint8_t status; + uint8_t idx; + uint8_t cleared = 0; + uint8_t prev_nb_touches = 0; +//cs. + uint8_t i, key, key_buf; + + //if(Key_Chk) wait(1); //Key Pressed, 1 + //else wait(10); + + BSP_LCD_SetFont(&Font24); + + for (i=0; i<32; i++) + { + lcd.DisplayStringAt(0, LINE(i), (uint8_t *)"TOUCHSCREEN DEMO ", CENTER_MODE); + } + + //wait(10); + while(1) + { + if(Key_Chk) break; //Key Pressed + }; + + status = ts.Init(lcd.GetXSize(), lcd.GetYSize()); + if (status != TS_OK) + { + lcd.Clear(LCD_COLOR_RED); + lcd.SetBackColor(LCD_COLOR_RED); + lcd.SetTextColor(LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE); + } + else + { + lcd.Clear(LCD_COLOR_GREEN); + lcd.SetBackColor(LCD_COLOR_GREEN); + lcd.SetTextColor(LCD_COLOR_WHITE); + lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE); + } + + while(1) + { + if(Key_Chk) break; //Key Pressed + }; + + wait(1); + lcd.SetBackColor(LCD_COLOR_BLUE); + lcd.SetTextColor(LCD_COLOR_WHITE); + + while(1) + { + + ts.GetState(&TS_State); + if (TS_State.touchDetected) + { + // Clear lines corresponding to old touches coordinates + if (TS_State.touchDetected < prev_nb_touches) + { + for (idx = (TS_State.touchDetected + 1); idx <= 5; idx++) + { + lcd.ClearStringLine(idx); + } + } + prev_nb_touches = TS_State.touchDetected; + + cleared = 0; + + sprintf((char*)text, "Touches: %d", TS_State.touchDetected); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE); + + for (idx = 0; idx < TS_State.touchDetected; idx++) + { + x = TS_State.touchX[idx]; + y = TS_State.touchY[idx]; + sprintf((char*)text, "Touch %d: x=%d y=%d ", idx+1, x, y); + lcd.DisplayStringAt(0, LINE(idx+1), (uint8_t *)&text, LEFT_MODE); + lcd.FillCircle(TS_State.touchX[idx], TS_State.touchY[idx], 20); + } + } + else + { + if (!cleared) + { + lcd.Clear(LCD_COLOR_BLUE); + sprintf((char*)text, "Touches: 0"); + lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE); + cleared = 1; + } + } + } +}
diff -r 000000000000 -r 7082d958eabc mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Apr 27 10:55:10 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file