Basic demo showing how to use the touch screen present on the DISCO_F746NG board

Dependencies:   BSP_DISCO_F746NG

Touch screen example

Files at this revision

API Documentation at this revision

Comitter:
Jerome Coutant
Date:
Wed Nov 20 11:49:15 2019 +0100
Parent:
2:021843c33b0e
Commit message:
Update with STM32Cube_FW_F7_V1.15.0

Changed in this revision

.hgignore Show annotated file Show diff for this revision Revisions of this file
BSP_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
LCD_DISCO_F746NG.lib Show diff for this revision Revisions of this file
TS_DISCO_F746NG.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Wed Nov 20 11:49:15 2019 +0100
@@ -0,0 +1,2 @@
+BUILD
+mbed-os/
--- a/BSP_DISCO_F746NG.lib	Wed Jun 07 09:31:50 2017 +0200
+++ b/BSP_DISCO_F746NG.lib	Wed Nov 20 11:49:15 2019 +0100
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/#c9112f0c67e3
+https://mbed.org/teams/ST/code/BSP_DISCO_F746NG/#1050c589b2ad
--- a/LCD_DISCO_F746NG.lib	Wed Jun 07 09:31:50 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/teams/ST/code/LCD_DISCO_F746NG/#d44525b1de98
--- a/TS_DISCO_F746NG.lib	Wed Jun 07 09:31:50 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/teams/ST/code/TS_DISCO_F746NG/#fe0cf5e2960f
--- a/main.cpp	Wed Jun 07 09:31:50 2017 +0200
+++ b/main.cpp	Wed Nov 20 11:49:15 2019 +0100
@@ -1,9 +1,6 @@
 #include "mbed.h"
-#include "TS_DISCO_F746NG.h"
-#include "LCD_DISCO_F746NG.h"
-
-LCD_DISCO_F746NG lcd;
-TS_DISCO_F746NG ts;
+#include "stm32746g_discovery_lcd.h"
+#include "stm32746g_discovery_ts.h"
 
 int main()
 {
@@ -15,35 +12,39 @@
     uint8_t cleared = 0;
     uint8_t prev_nb_touches = 0;
 
-    lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN DEMO", CENTER_MODE);
-    wait(1);
+    BSP_LCD_Init();
+    BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
+    BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
 
-    status = ts.Init(lcd.GetXSize(), lcd.GetYSize());
+    BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN DEMO", CENTER_MODE);
+    HAL_Delay(1000);
+
+    status = BSP_TS_Init(BSP_LCD_GetXSize(), BSP_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);
+        BSP_LCD_Clear(LCD_COLOR_RED);
+        BSP_LCD_SetBackColor(LCD_COLOR_RED);
+        BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
+        BSP_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);
+        BSP_LCD_Clear(LCD_COLOR_GREEN);
+        BSP_LCD_SetBackColor(LCD_COLOR_GREEN);
+        BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
+        BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE);
     }
 
-    wait(1);
-    lcd.SetFont(&Font12);
-    lcd.SetBackColor(LCD_COLOR_BLUE);
-    lcd.SetTextColor(LCD_COLOR_WHITE);
+    HAL_Delay(1000);
+    BSP_LCD_SetFont(&Font12);
+    BSP_LCD_SetBackColor(LCD_COLOR_BLUE);
+    BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
 
     while(1) {
 
-        ts.GetState(&TS_State);
+        BSP_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);
+                    BSP_LCD_ClearStringLine(idx);
                 }
             }
             prev_nb_touches = TS_State.touchDetected;
@@ -51,21 +52,21 @@
             cleared = 0;
 
             sprintf((char*)text, "Touches: %d", TS_State.touchDetected);
-            lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
+            BSP_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);
+                BSP_LCD_DisplayStringAt(0, LINE(idx+1), (uint8_t *)&text, LEFT_MODE);
             }
 
-            lcd.DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_ORANGE);
+            BSP_LCD_DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_ORANGE);
         } else {
             if (!cleared) {
-                lcd.Clear(LCD_COLOR_BLUE);
+                BSP_LCD_Clear(LCD_COLOR_BLUE);
                 sprintf((char*)text, "Touches: 0");
-                lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
+                BSP_LCD_DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
                 cleared = 1;
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Wed Nov 20 11:49:15 2019 +0100
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#699372421a3b388fe568e9be85b1a985749a438f
--- a/mbed.bld	Wed Jun 07 09:31:50 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b
\ No newline at end of file