version with updated libs

Dependencies:   F7_Ethernet mbed MbedJSONValue LCD_DISCO_F746NG mbed-rtos BSP_DISCO_F746NG CANMsg NetworkAPI SDFileSystem_Warning_Fixed GroveStreamsmodified LcdDiscoF746NgTracer JSON

Branch:
jpa
Revision:
17:f3c5ec9ca00f
Parent:
12:15ae35cfb03f
--- a/touchScreenJPA.cpp	Wed Dec 30 17:22:27 2020 +0000
+++ b/touchScreenJPA.cpp	Wed Jan 13 19:52:35 2021 +0000
@@ -2,26 +2,22 @@
 #include "stm32746g_discovery_lcd.h"
 #include "stm32746g_discovery_ts.h"
 #include "mbed.h"
-#include "GroveStreams.h"
+//#include "GroveStreams.h"
 #include "MbedJSONValue.h"
 Timer    timer_touch[16];
+Timer           timer_lcd;
 
 void sendSerial2(char * str);
 void sendSerial7(char * str);
 
 int initDisplayTemp();
-
 // GroveStreams Settings
 //extern const char gsApiKey[];// = "YOUR_SECRET_API_KEY_HERE";   //Change This!!!
 extern const char gsCompName[];// = "STM32F746+Discovery";  //Optionally change. Set this to give your component a name when it initially registers. Encode special chars such as spaces.
-
 extern const char gsCompTmplId[];  //Optional. Tells GS what template to use when the feed initially arrives and a new component needs to be created.
-
 ////GroveStreams groveStreams(gsApiKey, &lcd);
-extern GroveStreams groveStreams;
-
+//extern GroveStreams groveStreams;
 extern const char* myMac;
-
 extern time_t seconds;
 time_t seconds_touches = 0;
 extern time_t lastToucheTime;  
@@ -46,8 +42,7 @@
         BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE);
     }
     else 
-    {
-        BSP_LCD_Clear(LCD_COLOR_DARKBLUE);
+    {   BSP_LCD_Clear(LCD_COLOR_DARKBLUE);
         BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
         BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
         //BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE);
@@ -69,10 +64,8 @@
 
 // -----------------------------------------------------------------------------------------
 int touchButtonJPA1(int numButton)
-    {
-    if ((numButton > 0) && (numButton < 5))
-        { 
-        BSP_LCD_SetBackColor(backColorButton[numButton]);
+  { if ((numButton > 0) && (numButton < 5))
+     {  BSP_LCD_SetBackColor(backColorButton[numButton]);
         BSP_LCD_SetTextColor(backColorButton[numButton]);
         BSP_LCD_FillRect(xButton[numButton], yButton[numButton], dxButton[numButton], dyButton[numButton]);
         BSP_LCD_SetTextColor(txtColorButton[numButton]);
@@ -128,16 +121,14 @@
 
 // --------------------------------------------------------------------------    
 int touchJPA1()
-    {
-    //touch screen
+    { //touch screen
     TS_StateTypeDef TS_State;
     uint16_t x, y;
     uint8_t text[30];
     uint8_t status = 0;
     uint8_t idx;
     static uint8_t cleared = 0;
-    uint8_t prev_nb_touches = 0;
-    
+    uint8_t prev_nb_touches = 0;  
         int tt = 0;
         for (tt=0;tt<16;tt++) 
             {if(timer_touch[tt].read_ms() > 200) 
@@ -151,25 +142,20 @@
                     //BSP_LCD_ClearStringLine(idx);
                 }
             }
-            prev_nb_touches = TS_State.touchDetected;
-            
+            prev_nb_touches = TS_State.touchDetected;            
             cleared = 0;
-
             //sprintf((char*)text, "Touches: %d", TS_State.touchDetected);
             //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);
                 //BSP_LCD_DisplayStringAt(0, LINE(idx+1), (uint8_t *)&text, LEFT_MODE);
             }
-
-            //BSP_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);           
             if ((TS_State.touchY[0] > 160) && (TS_State.touchY[0] < (160+80)))
-                {
-                int numTouche = 0;
+                { int numTouche = 0;
                 if ((TS_State.touchX[0] > 10) && (TS_State.touchX[0]  < (10+100)))  
                     {if(timer_touch[0].read_ms() == 0) {numTouche = 1;timer_touch[0].start();}}
                 if ((TS_State.touchX[0] > 130) && (TS_State.touchX[0] < (130+100))) 
@@ -179,14 +165,23 @@
                 if ((TS_State.touchX[0] > 370) && (TS_State.touchX[0] < (370+100))) 
                     {if(timer_touch[3].read_ms() == 0) {numTouche = 4;timer_touch[3].start();}}
                 if (numTouche >0) 
-                    {
-                    printf("Touche : %d", numTouche);
+                    { printf("Touche : %d", numTouche);
                     sprintf((char*)text, "Touche : %d", numTouche);
                     //BSP_LCD_DisplayStringAt(200,0, (uint8_t *)&text, LEFT_MODE);
                     status = numTouche;
                     }  
-                else {lastToucheTime = 0;}
+                else 
+                   {lastToucheTime = 0;
+                   }
                 }
+            else
+               { 
+               int numTouche = 9;
+               printf("Touche : %d", numTouche);
+               timer_lcd.stop();                       // stop the timer
+               timer_lcd.reset();                      // reset the timer
+               BSP_LCD_DisplayOn();
+               }   
         } else {
             lastToucheTime = 0;
             if (!cleared) {
@@ -213,7 +208,8 @@
              // modifier pour rajouter test ethernet / wifi et action en fonction                 
              if (ethernet_actif == 1 )  // ethernet actif
              {   printf("\ntraitement Ethernet\n",xx);               
-                 int sendResult = groveStreams.sendJPA(myMac, samples, gsCompName, gsCompTmplId, resultBuffer, sizeof resultBuffer);
+/////////////  int sendResult = groveStreams.sendJPA(myMac, samples, gsCompName, gsCompTmplId, resultBuffer, sizeof resultBuffer);
+                 int sendResult = 0;
                  if (sendResult == 0) 
                  {      ////lcd.printf("Send Successful");
                         printf("Send Successful\n");