grove stream updated gerard 31/08

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

Files at this revision

API Documentation at this revision

Comitter:
38domo
Date:
Mon Aug 31 19:19:48 2020 +0000
Commit message:
grove stream upated 31/08

Changed in this revision

.mbed 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
CANMsg.lib Show annotated file Show diff for this revision Revisions of this file
F7_Ethernet.lib Show annotated file Show diff for this revision Revisions of this file
GettingStarted.html Show annotated file Show diff for this revision Revisions of this file
GroveStreams.lib Show annotated file Show diff for this revision Revisions of this file
GuiJPA.cpp Show annotated file Show diff for this revision Revisions of this file
JSON.lib Show annotated file Show diff for this revision Revisions of this file
LCD_DISCO_F746NG.lib Show annotated file Show diff for this revision Revisions of this file
LcdDiscoF746NgTracer.lib Show annotated file Show diff for this revision Revisions of this file
MbedJSONValue.lib Show annotated file Show diff for this revision Revisions of this file
NetworkAPI.lib Show annotated file Show diff for this revision Revisions of this file
SDFileSystem_Warning_Fixed.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
main.h Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
mbed_config.h Show annotated file Show diff for this revision Revisions of this file
touchScreen.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.mbed	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,2 @@
+ROOT=.
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BSP_DISCO_F746NG.lib	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/38domo/code/BSP_DISCO_F746NG/#ed51426706bd
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CANMsg.lib	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/38domo/code/CANMsg/#26efbc3fd451
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/F7_Ethernet.lib	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/DieterGraef/code/F7_Ethernet/#28ba13dd96f7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GettingStarted.html	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html lang="en-US">
+    <head>
+        <meta charset="UTF-8">
+        <meta http-equiv="refresh"
+              content="1;url="https://os.mbed.com/docs/latest/tools/exporting.html>
+        <script type="text/javascript">
+            window.location.href = "https://os.mbed.com/docs/latest/tools/exporting.html"
+        </script>
+        <title>Page Redirection</title>
+    </head>
+    <body>
+        If you are not redirected automatically, please follow the
+        <a href='https://os.mbed.com/docs/v5.6/tools/exporting.html/'>link to the online exporter documentation</a>
+    </body>
+</html>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GroveStreams.lib	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/38domo/code/GroveStreamsmodified/#e69854e65c88
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GuiJPA.cpp	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,222 @@
+#include "stm32746g_discovery_lcd.h"
+#include "stm32746g_discovery_ts.h"
+#include "MbedJSONValue.h"
+#include "GroveStreams.h"
+#include <string>
+
+int touchButtonJPA1(int numButton);
+extern uint32_t backColorButton[5];
+extern uint32_t txtColorButton[5];
+extern char textButton[5][30];
+extern char text1Button[5][30];
+extern char statusButton[5][30];
+uint32_t backColorTemp1=LCD_COLOR_BLACK, txtColorTemp1=LCD_COLOR_GREEN;
+uint32_t backColorTemp2=LCD_COLOR_BLACK, txtColorTemp2=LCD_COLOR_GREEN;
+
+int setTemp1(std::string temp1)
+    {
+    printf("\nTemp1 : %s\n", temp1.c_str());
+    BSP_LCD_SetBackColor(backColorTemp1);
+    BSP_LCD_SetTextColor(txtColorTemp1);
+    BSP_LCD_SetFont(&FontFreeMono64); 
+    BSP_LCD_DisplayStringAt(10, 60, (uint8_t *)temp1.c_str(), LEFT_MODE);
+    BSP_LCD_SetFont(&Font12);
+    return 1;
+    } 
+
+int setTemp2(std::string temp2)
+    {
+    printf("\nTemp2 : %s\n", temp2.c_str());
+    BSP_LCD_SetBackColor(backColorTemp2);
+    BSP_LCD_SetTextColor(txtColorTemp2);
+    BSP_LCD_SetFont(&FontFreeMono64); 
+    BSP_LCD_DisplayStringAt(260, 60, (uint8_t *)temp2.c_str(), LEFT_MODE);
+    BSP_LCD_SetFont(&Font12);
+    return 1;
+    } 
+    
+int xTempTitle[3],yTempTitle[3],dxTempTitle[3],dyTempTitle[3],xTxtTempTitle[3],yTxtTempTitle[3];
+uint32_t backColorTempTitle[3], txtColorTempTitle[3];
+char textTempTitle[3][30];
+
+int setDisplayTemp()
+   { int numTemp=0;    
+     for (numTemp=1;numTemp<3;numTemp=numTemp+1)
+        {
+         BSP_LCD_SetFont(&Font16); 
+         BSP_LCD_SetBackColor(backColorTempTitle[numTemp]);
+         BSP_LCD_SetTextColor(backColorTempTitle[numTemp]);
+         BSP_LCD_FillRect(xTempTitle[numTemp], yTempTitle[numTemp], dxTempTitle[numTemp], dyTempTitle[numTemp]);
+         BSP_LCD_SetTextColor(txtColorTempTitle[numTemp]);
+         BSP_LCD_DrawRect(xTempTitle[numTemp], yTempTitle[numTemp], dxTempTitle[numTemp], dyTempTitle[numTemp]);
+         BSP_LCD_DisplayStringAt(xTxtTempTitle[numTemp], yTxtTempTitle[numTemp], (uint8_t *)textTempTitle[numTemp], LEFT_MODE);
+        }
+    BSP_LCD_SetFont(&Font8); 
+    return 1;   
+    }
+
+int initDisplayTemp()
+   { printf("\nInit DisplayTemp \n");        
+     xTempTitle[1]=14;yTempTitle[1]=30;
+     dxTempTitle[1]=200;dyTempTitle[1]=23;
+     xTxtTempTitle[1]=15;yTxtTempTitle[1]=34;
+     backColorTempTitle[1]=LCD_COLOR_BLACK;txtColorTempTitle[1]=LCD_COLOR_GREEN;
+     sprintf(textTempTitle[1],"   temp Salon  ");
+     xTempTitle[2]=264;yTempTitle[2]=30;dxTempTitle[2]=200;dyTempTitle[2]=23;xTxtTempTitle[2]=265;yTxtTempTitle[2]=34;
+     backColorTempTitle[2]=LCD_COLOR_BLACK;txtColorTempTitle[2]=LCD_COLOR_GREEN;
+     sprintf(textTempTitle[2],"   temp Ext    ");
+     int xx=setDisplayTemp();
+    return 1;
+    }
+    
+// 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 const char* myMac;
+
+int initDatasGuiJPA()
+    {       ////lcd.clear();          
+            ////lcd.printf("Getting Samples...");
+            printf("Getting Samples...\n");           
+            //Assemble the samples into URL parameters which are seperated with the "&" character
+            // Example: &s1=6.2&s2=78.231
+            char samples[64] = {0};
+            sprintf(samples, "&datas=init");            
+            //Append on command requests (request stream values)
+            //This will indicate to GroveStreams to return the last value
+            // of each request stream during the sample upload
+            //strcat(samples, "&rsid=freq&rsid=led");           
+            char resultBuffer[2000]= {0};
+            //Sending Samples (and returning current command stream values)
+            int sendResult=1;
+            sendResult = groveStreams.sendInitDatasJPA(myMac, samples, gsCompName, gsCompTmplId, resultBuffer, sizeof resultBuffer);
+            if (sendResult == 0) {
+                ////lcd.printf("Send Successful");
+                printf("Send Successful\n");               
+                //Handle command streams
+                if (strlen(resultBuffer) > 0 && resultBuffer[0] == '{') {
+                    printf("Datas : %s\n",resultBuffer);
+                    MbedJSONValue mbedJson;
+                    parse(mbedJson, resultBuffer);       
+                    //sprintf((char*)text, "HTTP string : %s\n", resultBuffer);
+                    //BSP_LCD_DisplayStringAt(0, LINE(10), (uint8_t *)&text, LEFT_MODE);
+                    int displayOn = 0;
+                    string s;
+                    if (mbedJson.hasMember("Temp1")) {
+                        s = mbedJson["Temp1"]["backColorTemp"].get<std::string>();
+                        backColorTemp1 = (uint32_t)strtoul(s.c_str(), NULL,16);
+                        //printf("Temp1 backColorTemp1 : %s %X\n",s.c_str(),(uint32_t)strtoul(s.c_str(), NULL,0));
+                        s = mbedJson["Temp1"]["txtColorTemp"].get<std::string>();
+                        txtColorTemp1 = (uint32_t)strtoul(s.c_str(), NULL,16) ;
+                        //printf("Temp1 txtColorTemp1 : %s %X\n",s.c_str(),(uint32_t)strtoul(s.c_str(), NULL,0));
+                        s = mbedJson["Temp1"]["text"].get<std::string>();
+                        sprintf(textTempTitle[1],s.c_str());
+                        printf("Temp1 text : %s\n",s.c_str());
+                        displayOn = (0x01 | displayOn);
+                        }
+                    if (mbedJson.hasMember("Temp2")) {
+                        s = mbedJson["Temp2"]["backColorTemp"].get<std::string>();
+                        backColorTemp2 = (uint32_t)strtoul(s.c_str(), NULL,16);
+                        //printf("Temp2 text : %s\n",s.c_str());
+                        s = mbedJson["Temp2"]["txtColorTemp"].get<std::string>();
+                        txtColorTemp2 = (uint32_t)strtoul(s.c_str(), NULL,16) ;
+                        //printf("Temp2 backColorTemp2 : %s\n",s.c_str());
+                        s = mbedJson["Temp2"]["text"].get<std::string>();
+                        sprintf(textTempTitle[2],s.c_str());
+                        printf("Temp2 text : %s\n",s.c_str());
+                        displayOn = (0x01 | displayOn);
+                        }                   
+                    if (mbedJson.hasMember("Touche1")) {
+                        s = mbedJson["Touche1"]["Status"].get<std::string>();
+                        sprintf(statusButton[1],s.c_str());
+                        printf("Touche1 Status : %s\n",s.c_str());
+                        s = mbedJson["Touche1"]["BackColor"].get<std::string>();
+                        backColorButton[1] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                        printf("Touche1 BackColor : %s\n",s.c_str());
+                        s = mbedJson["Touche1"]["TextColor"].get<std::string>();
+                        txtColorButton[1] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                        printf("Touche1 TextColor : %s\n",s.c_str());
+                        s = mbedJson["Touche1"]["text"].get<std::string>();
+                        sprintf(textButton[1],s.c_str());
+                        printf("Touche1 text : %s\n",s.c_str());
+                        s = mbedJson["Touche1"]["text1"].get<std::string>();
+                        sprintf(text1Button[1],s.c_str());
+                        printf("Touche1 text1 : %s\n",s.c_str());
+                        displayOn = (0x02 | displayOn);
+                        }                                                               
+                    if (mbedJson.hasMember("Touche2")) {
+                        s = mbedJson["Touche2"]["Status"].get<std::string>();
+                        sprintf(statusButton[2],s.c_str());
+                        printf("Touche2 Status : %s\n",s.c_str());
+                        s = mbedJson["Touche2"]["BackColor"].get<std::string>();
+                        backColorButton[2] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                        printf("Touche1 BackColor : %s\n",s.c_str());
+                        s = mbedJson["Touche2"]["TextColor"].get<std::string>();
+                        txtColorButton[2] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                        printf("Touche2 TextColor : %s\n",s.c_str());
+                        s = mbedJson["Touche2"]["text"].get<std::string>();
+                        sprintf(textButton[2],s.c_str());
+                        printf("Touche2 text : %s\n",s.c_str());
+                        s = mbedJson["Touche2"]["text1"].get<std::string>();
+                        sprintf(text1Button[2],s.c_str());
+                        printf("Touche2 text1 : %s\n",s.c_str());
+                        displayOn = (0x04 | displayOn);
+                        }
+                    if (mbedJson.hasMember("Touche3")) {
+                        s = mbedJson["Touche3"]["Status"].get<std::string>();
+                        sprintf(statusButton[3],s.c_str());
+                        printf("Touche3 Status : %s\n",s.c_str());
+                        s = mbedJson["Touche3"]["BackColor"].get<std::string>();
+                        backColorButton[3] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                        printf("Touche3 BackColor : %s\n",s.c_str());
+                        s = mbedJson["Touche3"]["TextColor"].get<std::string>();
+                        txtColorButton[3] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                        printf("Touche3 TextColor : %s\n",s.c_str());
+                        s = mbedJson["Touche3"]["text"].get<std::string>();
+                        sprintf(textButton[3],s.c_str());
+                        printf("Touche3 text : %s\n",s.c_str());
+                        s = mbedJson["Touche3"]["text1"].get<std::string>();
+                        sprintf(text1Button[3],s.c_str());
+                        printf("Touche3 text1 : %s\n",s.c_str());
+                        displayOn = (0x08 | displayOn);
+                        }
+                    if (mbedJson.hasMember("Touche4")) {
+                        s = mbedJson["Touche4"]["Status"].get<std::string>();
+                        sprintf(statusButton[4],s.c_str());
+                        printf("Touche4 Status : %s\n",s.c_str());
+                        s = mbedJson["Touche4"]["BackColor"].get<std::string>();
+                        backColorButton[4] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                        printf("Touche4 BackColor : %s\n",s.c_str());
+                        s = mbedJson["Touche4"]["TextColor"].get<std::string>();
+                        txtColorButton[4] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                        printf("Touche4 TextColor : %s\n",s.c_str());
+                        s = mbedJson["Touche4"]["text"].get<std::string>();
+                        sprintf(textButton[4],s.c_str());
+                        printf("Touche4 text : %s\n",s.c_str());
+                        s = mbedJson["Touche4"]["text1"].get<std::string>();
+                        sprintf(text1Button[4],s.c_str());
+                        printf("Touche4 text1 : %s\n",s.c_str());
+                        displayOn = (0x10 | displayOn);
+                        }
+                    if (mbedJson.hasMember("Temp1")) {
+                        //int pp=setTemp1(mbedJson["Temp1"].get<std::string>());
+                        }
+                    if (mbedJson.hasMember("Temp2")) {
+                        //int pp=setTemp1(mbedJson["Temp2"].get<std::string>());
+                        }                    
+                    if ((displayOn & 0x01) > 0) {setDisplayTemp();}
+                    if ((displayOn & 0x02) > 0) {touchButtonJPA1(1);}
+                    if ((displayOn & 0x04) > 0) {touchButtonJPA1(2);}
+                    if ((displayOn & 0x08) > 0) {touchButtonJPA1(3);}
+                    if ((displayOn & 0x10) > 0) {touchButtonJPA1(4);}
+                }
+            }
+        return 1; 
+        }   
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/JSON.lib	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/38domo/code/JSON/#43e1e35bb7ec
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LCD_DISCO_F746NG.lib	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/38domo/code/LCD_DISCO_F746NG/#1fdce1141fc7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LcdDiscoF746NgTracer.lib	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/38domo/code/LcdDiscoF746NgTracer/#5c55632552e0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MbedJSONValue.lib	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/samux/code/MbedJSONValue/#10a99cdf7846
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/NetworkAPI.lib	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/NegativeBlack/code/NetworkAPI/#7ac7c29fea3d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem_Warning_Fixed.lib	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/38domo/code/SDFileSystem_Warning_Fixed/#72435639e4e7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,400 @@
+/* --------------------------------------------------------------------------
+// test compile ok 31/07/2020 
+
+// 30/08/2020 : emission CAN OK en Wifi sur tasmota ou udp bridge
+//              mais pb reception caracteres sur port serie ( idem port series pc ouu serial 7
+
+// 02/08/2020
+// add sd parameters: read ok
+// ip address
+// ethernet actif
+// wifi actif
+// can actif
+// serial actif
+// fonction
+// Touche1 status (0/1)
+// Touche1 backcolor
+// touche1 text color
+// Touche1 text
+// Touche1 text1
+// Touche2
+// Touche3
+// Touche4
+// Temp1 text
+// Temp2 text
+
+// works ok 31/07/2020
+// updated package from jpa
+// added fonts in  bsp_disco_f746ng/utilities/fonts
+// fonts.h updated to manage added fonts
+// grovestream.cpp & grovesttream.h updated
+// remove stm32746ng_dicovery_sd in /bsp_disco_f746ng/drivers/stm32746ng_discovery
+// mainSDAcardJPA issue: add sdcardjpa.cpp in lib /sdfilesystem_warning_fixed
+// isue with big fonts: replace /bsp_disco_f746ng/drivers/stm32746ng-discovery/stm32746ng-discovery_lcd.c &.h
+
+// need to add CAN and WiFi
+
+ STM32F746 GroveStreams Stream Feed via Ethernet
+
+ This GroveStreams example is designed for the STM32F746.
+ https://www.grovestreams.com/developers/getting_started_stm32F746.html
+
+ The STM32 uses DHCP and DNS for a simpler network setup.
+
+*/
+
+#if !FEATURE_LWIP
+#error [NOT_SUPPORTED] LWIP not supported for this target
+#endif
+
+#include "mbed.h"
+#include "LcdDiscoF746NgTracer.h"
+#include "GroveStreams.h"
+#include "MbedJSONValue.h"
+#include "stm32746g_discovery_lcd.h"
+#include "stm32746g_discovery_ts.h"
+#include "CANMsg.h"
+
+#include "main.h"
+
+//#include "touchScreen.cpp"
+int touchInitJPA1();
+int touchJPA1();
+int touchInitGuiJPA1();
+int sendTouchJPA(int xx);
+time_t lastToucheTime = 0;
+int touchButtonJPA1(int numButton);
+
+//#include "GuiJPA.cpp"
+int initDisplayTemp();
+int initDatasGuiJPA();
+int setTemp1(std::string temp1);
+int setTemp2(std::string temp2);
+int sendInitDatasJPA(int xx);
+
+//#SDCARD
+int mainSDCardJPA(); //in sdcardjpa.cpp in lib /sdfilesystem_warning_fixedd
+
+//GroveStreams Stream IDs. Stream IDs tell GroveStreams which component streams the values will be assigned to.
+//Don't change these unless you edit your GroveStreams component definition and change the stream IDs to match these.
+const char gsStreamId1[] = "voltage";
+const char gsStreamId2[] = "temperature";
+char gsStreamIPdatas[] = "192.168.1.49";
+char ethernet_actif[] = "O";
+char wifi_actif[] = "O";
+char can_actif[] = "O";
+char serial_actif[] = "O";
+char read_sd[] = "";
+uint8_t text2[30];
+uint8_t             counter = 0;
+float               voltage;
+const int kMaxBufferSize = 100;
+char      buffer[kMaxBufferSize];
+int       len = 0;
+int i = 0;
+int idx_ser =0;
+int recv_ser = 0;
+Timer               timer;
+AnalogIn        analogIn(A0);
+
+// CAN ------------------------------------------------------------
+CAN        can(PB_8, PB_9);  // CAN Rx pin name, CAN Tx pin name
+CANMsg     rxMsg;
+CANMsg     txMsg;
+
+// Other Settings
+int updateFrequency = 20;    // Update frequency in seconds. Change this to change your sample frequency.
+
+AnalogIn adc_temp(ADC_TEMP);
+AnalogIn adc_vref(ADC_VREF);
+DigitalOut myled(LED1);
+
+// serial port sur connecteur arduino (D0,D1)--------------------
+Serial    pc(USBTX, USBRX);    // serial PC
+Serial    serial2(PC_6, PC_7); // TX, RX for udp bridge
+Serial    serial7(PF_7, PF_6); // TX, RX for extension
+
+#define BOARD1                  1       // comment out this line when compiling for board #2
+#if defined(BOARD1)
+    const unsigned int  RX_ID = 0x100;
+    const unsigned int  TX_ID = 0x101;
+#else
+    const unsigned int  RX_ID = 0x101;
+    const unsigned int  TX_ID = 0x100;
+#endif
+
+// ---------------------------------------------------------------------------------------
+//* @brief   Prints CAN message to PC's serial terminal
+void printMsg(CANMessage& msg, int dir)
+{   if (dir ==0)
+    {  //BSP_LCD_DisplayStringAt(0, LINE(6), (uint8_t *)"Message sent    ", LEFT_MODE); 
+         serial7.printf(" Can message sent ok\n");
+         serial7.printf("ID = 0x%.3x Data=", msg.id);
+         for(int i = 0; i < msg.len; i++)
+        serial7.printf(" 0x%.2X", msg.data[i]);
+        serial7.printf("\r\n");       
+    }    
+    else
+    {  //BSP_LCD_DisplayStringAt(0, LINE(6), (uint8_t *)"Message received", LEFT_MODE); 
+    }
+    pc.printf("  ID      = 0x%.3x\r\n", msg.id);
+    pc.printf("  Type    = %d\r\n", msg.type);
+    pc.printf("  Format  = %d\r\n", msg.format);
+    pc.printf("  Length  = %d\r\n", msg.len);
+    pc.printf("  Data    =");
+    for(int i = 0; i < msg.len; i++)
+        pc.printf(" 0x%.2X", msg.data[i]);
+    pc.printf("\r\n");
+    serial7.printf(" Can message received ok\n");
+             serial7.printf("ID = 0x%.3x Data= ", msg.id);
+         for(int i = 0; i < msg.len; i++)
+        serial7.printf(" 0x%.2X", msg.data[i]);
+        serial7.printf("\r\n");       
+
+    sprintf((char*)text2, "ID: %d", msg.id);
+    //BSP_LCD_DisplayStringAt(2, LINE(7), (uint8_t *)&text2, LEFT_MODE);
+    sprintf((char*)text2, "Type: %d", msg.type);
+    //BSP_LCD_DisplayStringAt(2, LINE(8), (uint8_t *)&text2, LEFT_MODE);
+    sprintf((char*)text2, "Format: %d", msg.format);
+    //BSP_LCD_DisplayStringAt(2, LINE(9), (uint8_t *)&text2, LEFT_MODE);
+    sprintf((char*)text2, "Length: %d", msg.len);
+    //BSP_LCD_DisplayStringAt(2, LINE(10), (uint8_t *)&text2, LEFT_MODE);
+    sprintf((char*)text2, "Data: %d", msg.data[0]);
+    //BSP_LCD_DisplayStringAt(2, LINE(11), (uint8_t *)&text2, LEFT_MODE);   
+}
+
+/** -----------------------------------------------------------------------------------------
+ * @brief   Handles received CAN messages
+ * @note    Called on 'CAN message received' interrupt.
+ */
+void onCanReceived(void)
+{   can.read(rxMsg);
+    pc.printf("-------------------------------------\r\n");
+    pc.printf("CAN message received\r\n");
+    BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"Can msg rec", CENTER_MODE);
+    printMsg(rxMsg,1);   
+    serial7.printf("ID: 0x%.3x ", rxMsg.id);
+    serial7.printf("D: ");
+    for(int i = 0; i < rxMsg.len; i++)
+        serial7.printf(" 0x%.2X", rxMsg.data[i]);
+    serial7.printf("\r\n");   
+    if (rxMsg.id == RX_ID) {
+        // extract data from the received CAN message 
+        // in the same order as it was added on the transmitter side
+        rxMsg >> counter;
+        rxMsg >> voltage;    
+        pc.printf("  counter = %d\r\n", counter);
+        pc.printf("  voltage = %e V\r\n", voltage);
+    }
+    timer.start(); // to transmit next message in main
+}
+// ---------------------------------------------------
+void pc_recv()
+{    if(serial7.readable()) 
+    {   buffer[i]=(serial7.getc());
+    if (buffer[i] == '\n') {
+           serial7.printf("%s",buffer);
+            len = 0;
+            idx_ser =0;
+            recv_ser = 1;
+    }        
+    idx_ser++;
+    }
+}
+
+// ------------------------------------------------------------------------------------------
+int main()
+{   pc.baud(115200);
+    //serial2.baud(115200);  // required for tasmota
+    serial2.baud(57600);  // required for UDP bridge
+    serial7.baud(115200);  // required for tasmota
+    //serial7.attach(&pc_recv, Serial::RxIrq);
+    
+   // config can --------------------------------------
+    can.frequency(125000); // set CAN bit rate to 125 kbps
+    //can.filter(RX_ID, 0xFFF, CANStandard, 0); // set filter #0 to accept only standard messages with ID == RX_ID
+  //--  can.attach(onCanReceived);                // attach ISR to handle received messages
+#if defined(BOARD1)
+    timer.start();          // start timer
+    pc.printf("CAN_Hello board #1\r\n");
+#else
+    pc.printf("CAN_Hello board #2\r\n");
+#endif
+    buffer[0] = '\0';
+    printf("\nInit SDCard ...\n");
+    mainSDCardJPA() ;  // init SD - read  prog parameters from SD (from sdcardjpa.cpp in sdfilesystem_warning_fixed lib
+    // reaf following datas
+    // IP address, Ethernet actif, Wifi actif, Can actif, serial actif,fonction, buttons parameters
+    // store local variables from sd
+    //extern char gsStreamIPdatas[];
+    //extern char ethernet_actif[] ;
+    //extern char wifi_actif[];
+    //extern char can_actif[];
+    //extern char serial_actif[];
+    printf("\nFin init SDCard ...\n");
+    BSP_LCD_Clear(LCD_COLOR_DARKBLUE);  // clear LCD
+    uint8_t text[300];
+    printf("Start Prog\n");    
+    std::string temp1;
+    std::string temp2;
+    
+    //lastSuccessfulUploadTime is used for upload frequency.
+    time_t lastSuccessfulUploadTime = 0;    
+    printf("\n Init touchJPA1 ...\n");
+    int yy;
+    printf("\n Init initDisplayTemp ...\n"); 
+    yy = initDisplayTemp();   // from guijpa.cpp - Init display
+    printf("\ninit touchInitJPA1 ...\n");
+    yy = touchInitJPA1();  // from touchscreen.cpp - init touchscreen
+    yy = touchInitGuiJPA1();  // from touchscreen.cpp 
+    printf("\ninit initDatasGuiJPA ...\n");
+    yy = initDatasGuiJPA();  // from guijpa.cpp - config buttons             
+    ////lcd.printf("Starting...");
+    printf("Starting...\n");
+    lastToucheTime = time(NULL);
+     char data[5];
+     // main loop ---------------------------------------------------
+    while (true) {
+        // lecture sur port serie from tasmota
+    if(serial7.readable()) 
+    {   buffer[i]=(serial7.getc());
+        serial7.printf("%c",buffer[i]);
+        if (buffer[i] == '\n') {
+           serial7.printf("%s",buffer);
+            len = 0;
+            idx_ser =0;
+            recv_ser = 1;
+        }        
+        idx_ser++;
+     }
+      if ( recv_ser == 1)
+      {serial7.printf("sent: %s",buffer);
+      pc.printf("sent: %s",buffer);
+      recv_ser =0;
+      }
+               
+        // timer send can 
+       if(timer.read_ms() >= 1000)            // check for timeout
+       {    timer.stop();                       // stop the timer
+            timer.reset();                      // reset the timer
+            counter++;                          // increment the counter
+            voltage = (analogIn * 3.3f)/4096.0f;// read the small drifting voltage from analog input
+            txMsg.clear();                      // clear the Tx message storage
+            //txMsg.id = TX_ID;            // set ID
+            txMsg.id = 0x18881001;//TX_ID;                   // set the message ID
+            txMsg.format = CANExtended ; //extended
+            // We are about to transmit two data items to the CAN bus.
+            //     counter: uint_8 (unsigned eight bits int) value (one byte).
+            //     voltage: floating point value (four bytes).
+            // So the total length of payload data is five bytes.
+            // We'll use the "<<" (append) operator to add data to the CAN message.
+            // The usage is same as of the similar C++ io-stream operators.
+            // NOTE: The data length of CAN message is automatically updated when using "<<" operators.  
+            txMsg << counter << voltage;        // append data (total data length must be <= 8 bytes!)
+            
+            if(can.write(txMsg))       // transmit message
+            {   //if(can->write(txMsg)) {             // transmit the CAN message
+                //led = OFF;                      // turn the LED off
+                pc.printf("-------------------------------------\r\n");
+                pc.printf("CAN message sent\r\n");
+                printMsg(txMsg,0);
+                pc.printf("  counter = %d\r\n", counter);
+                pc.printf("  voltage = %e V\r\n", voltage);
+                BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"TX CAN OK", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"--------", CENTER_MODE);
+            }
+            else
+            {    pc.printf("Transmission error\r\n");
+                BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"TX CAN Fail", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"-----------", CENTER_MODE);
+            }    
+            //timer.start();                  // insert transmission lag
+        }  // end if timer
+        //touch screen
+        int xx = touchJPA1();  //
+        if (xx > 0) 
+        {  pc.printf("Touche appuyee %d \r\n",xx);
+        // send data to serial bridge tasmota
+           serial2.printf("  Touche %d appuyee to Tasmota", xx);  
+           serial7.printf("  Touche %d appuyee to Tasmota", xx);  
+           if (xx ==4 )
+           { // send trame to can
+           if(can.write(txMsg))       // transmit message
+            {   //if(can->write(txMsg)) {             // transmit the CAN message
+                //led = OFF;                      // turn the LED off
+                pc.printf("-------------------------------------\r\n");
+                pc.printf("CAN message sent\r\n");
+                printMsg(txMsg,0);
+                pc.printf("  counter = %d\r\n", counter);
+                pc.printf("  voltage = %e V\r\n", voltage);
+                BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"TX CAN OK", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"--------", CENTER_MODE);
+                serial7.printf(" send trame can ok");
+            }
+            else
+            {    pc.printf("Transmission error\r\n");
+                BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"TX CAN Fail", CENTER_MODE);
+                BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"-----------", CENTER_MODE);
+            }    
+           }    
+           pc.printf("data sent to tasmota serial bridge \n");
+           // data sent to ethernet
+           xx = sendTouchJPA(xx);  
+            
+           lastToucheTime = time(NULL);
+           
+        } 
+        else 
+        {  lastToucheTime = 0;
+        }   // send mqtt
+        // Update sensor data to GroveStreams
+        seconds = time(NULL);
+        if(seconds - lastSuccessfulUploadTime > updateFrequency) {
+            ////lcd.clear();            
+            ////lcd.printf("Getting Samples...");
+            printf("Getting Samples...\n");          
+            //Assemble the samples into URL parameters which are seperated with the "&" character
+            // Example: &s1=6.2&s2=78.231
+            int temperature = adc_temp.read() * 100.0f;
+            int voltage = adc_vref.read() * 100.0f;
+            char samples[64] = {0};
+            sprintf(samples, "&%s=%d&%s=%d", gsStreamId1, voltage, gsStreamId2, temperature);           
+            //Append on command requests (request stream values)
+            //This will indicate to GroveStreams to return the last value
+            // of each request stream during the sample upload
+            strcat(samples, "&rsid=freq&rsid=led");            
+            char resultBuffer[700]= {0};
+            //Sending Samples (and returning current command stream values)
+            time_t connectAttemptTime = time(NULL);
+            int sendResult = groveStreams.send(myMac, samples, gsCompName, gsCompTmplId, resultBuffer, sizeof resultBuffer);  //receive mqtt
+            
+            if (sendResult == 0) {
+                ////lcd.printf("Send Successful");
+                printf("Send Successful\n");
+                lastSuccessfulUploadTime = connectAttemptTime;               
+                //Handle command streams
+                if (strlen(resultBuffer) > 0 && resultBuffer[0] == '{') {
+                    MbedJSONValue mbedJson;
+                    parse(mbedJson, resultBuffer);                    
+                    sprintf((char*)text, "HTTP string : %s\n", resultBuffer);
+                    //BSP_LCD_DisplayStringAt(0, LINE(1), (uint8_t *)&text, LEFT_MODE);                
+                    if (mbedJson.hasMember("Temp1")) {
+                        int pp=setTemp1(mbedJson["Temp1"].get<std::string>());
+                    }
+                    if (mbedJson.hasMember("Temp2")) {
+                        int tt=setTemp2(mbedJson["Temp2"].get<std::string>());
+                    }
+                    if (mbedJson.hasMember("led")) {
+                        //Change LED
+                        myled = mbedJson["led"].get<bool>() ? 1 : 0;
+                        ////lcd.printf("LED: %s", mbedJson["led"].get<bool>() ? "On" : "Off");
+                        printf("LED: %s\n", mbedJson["led"].get<bool>() ? "On" : "Off");
+                    }
+                }
+            } 
+        }
+        
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.h	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,28 @@
+#ifndef __MAIN_H
+#define __MAIN_H
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+#include "GroveStreams.h"
+#include "mbed.h"
+
+// GroveStreams Settings
+const char gsApiKey[] = "YOUR_SECRET_API_KEY_HERE";   //Change This!!!
+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.
+
+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);
+GroveStreams groveStreams(gsApiKey);
+
+const char* myMac = groveStreams.getMACAddress();
+
+time_t seconds = time(NULL);
+
+
+#ifdef __cplusplus
+}
+#endif
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#58563e6cba1e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9baf128c2fab
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_config.h	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,47 @@
+/*
+ * mbed SDK
+ * Copyright (c) 2017 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Automatically generated configuration file.
+// DO NOT EDIT, content will be overwritten.
+
+#ifndef __MBED_CONFIG_DATA__
+#define __MBED_CONFIG_DATA__
+
+// Configuration parameters
+#define CLOCK_SOURCE                                    USE_PLL_HSE_XTAL|USE_PLL_HSI            // set by target:DISCO_F746NG
+#define LPTICKER_DELAY_TICKS                            0                                       // set by target:DISCO_F746NG
+#define MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE     9600                                    // set by library:platform
+#define MBED_CONF_PLATFORM_STDIO_BAUD_RATE              9600                                    // set by library:platform
+#define MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES       0                                       // set by library:platform
+#define MBED_CONF_PLATFORM_STDIO_FLUSH_AT_EXIT          1                                       // set by library:platform
+#define MBED_CONF_TARGET_BOOT_STACK_SIZE                0x1000                                  // set by target:Target
+#define MBED_CONF_TARGET_CONSOLE_UART                   1                                       // set by target:Target
+#define MBED_CONF_TARGET_DEEP_SLEEP_LATENCY             4                                       // set by target:MCU_STM32
+#define MBED_CONF_TARGET_DEFAULT_ADC_VREF               NAN                                     // set by target:Target
+#define MBED_CONF_TARGET_INIT_US_TICKER_AT_BOOT         1                                       // set by target:MCU_STM32
+#define MBED_CONF_TARGET_LPTICKER_LPTIM                 1                                       // set by target:DISCO_F746NG
+#define MBED_CONF_TARGET_LPTICKER_LPTIM_CLOCK           1                                       // set by target:MCU_STM32
+#define MBED_CONF_TARGET_LPUART_CLOCK_SOURCE            USE_LPUART_CLK_LSE|USE_LPUART_CLK_PCLK1 // set by target:MCU_STM32
+#define MBED_CONF_TARGET_LSE_AVAILABLE                  1                                       // set by target:MCU_STM32
+#define MBED_CONF_TARGET_MPU_ROM_END                    0x0fffffff                              // set by target:Target
+#define MBED_CONF_TARGET_NETWORK_DEFAULT_INTERFACE_TYPE ETHERNET                                // set by target:DISCO_F746NG
+#define MBED_CONF_TARGET_TICKLESS_FROM_US_TICKER        0                                       // set by target:Target
+#define MBED_CONF_TARGET_USB_SPEED                      USE_USB_OTG_FS                          // set by target:DISCO_F746NG
+#define MBED_CONF_TARGET_XIP_ENABLE                     0                                       // set by target:Target
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/touchScreen.cpp	Mon Aug 31 19:19:48 2020 +0000
@@ -0,0 +1,246 @@
+
+#include "stm32746g_discovery_lcd.h"
+#include "stm32746g_discovery_ts.h"
+#include "mbed.h"
+#include "GroveStreams.h"
+#include "MbedJSONValue.h"
+
+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 const char* myMac;
+
+extern time_t seconds;
+time_t seconds_touches = 0;
+extern time_t lastToucheTime;  
+
+int touchInitJPA1()
+    {    //touch screen init
+    //touch screen
+    uint8_t status;  
+    BSP_LCD_Init();
+    BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS);
+    BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER);
+    BSP_LCD_SetFont(&Font12); 
+    status = BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize());
+    if (status != TS_OK) {
+        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 {
+        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);
+        }  
+    
+    return 0;   
+    }
+
+int xButton[5],yButton[5],dxButton[5],dyButton[5],xTxtButton[5],yTxtButton[5];
+uint32_t backColorButton[5], txtColorButton[5];
+char textButton[5][30];
+char text1Button[5][30];
+char statusButton[5][30];
+
+int touchButtonJPA1(int 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]);
+        BSP_LCD_DrawRect(xButton[numButton], yButton[numButton], dxButton[numButton], dyButton[numButton]);
+        BSP_LCD_SetFont(&Font20); 
+        BSP_LCD_DisplayStringAt(xTxtButton[numButton]+52, yTxtButton[numButton], (uint8_t *)statusButton[numButton], LEFT_MODE);
+        BSP_LCD_DisplayStringAt(xTxtButton[numButton], yTxtButton[numButton]+28, (uint8_t *)textButton[numButton], LEFT_MODE);
+        BSP_LCD_DisplayStringAt(xTxtButton[numButton], yTxtButton[numButton]+48, (uint8_t *)text1Button[numButton], LEFT_MODE);
+        }
+    return 0;
+    }
+
+
+// generation de fonts : http://omz-software.com/pythonista/docs/ios/ImageFont.html
+int touchInitGuiJPA1()
+    {   
+    xButton[1]=10;yButton[1]=185;dxButton[1]=100;dyButton[1]=80;xTxtButton[1]=12;yTxtButton[1]=190;
+    backColorButton[1] = LCD_COLOR_GRAY; txtColorButton[1] = LCD_COLOR_GREEN;
+    sprintf(textButton[1],"Lampe ");
+    sprintf(text1Button[1],"Sejour");
+    sprintf(statusButton[1],"off");
+
+    xButton[2]=130;yButton[2]=185;dxButton[2]=100;dyButton[2]=80;xTxtButton[2]=132;yTxtButton[2]=190;
+    backColorButton[2] = LCD_COLOR_GRAY; txtColorButton[2] = LCD_COLOR_GREEN;
+    sprintf(textButton[2],"Lampe ");
+    sprintf(text1Button[2],"Sejours");
+    sprintf(statusButton[2],"off");
+       
+    xButton[3]=250;yButton[3]=185;dxButton[3]=100;dyButton[3]=80;xTxtButton[3]=252;yTxtButton[3]=190;
+    backColorButton[3] = LCD_COLOR_GRAY; txtColorButton[3] = LCD_COLOR_GREEN;
+    sprintf(textButton[3],"Lampe ");
+    sprintf(text1Button[3],"Sejour");
+    sprintf(statusButton[3],"off");
+       
+    xButton[4]=370;yButton[4]=185;dxButton[4]=100;dyButton[4]=80;xTxtButton[4]=372;yTxtButton[4]=190;
+    backColorButton[4] = LCD_COLOR_GRAY; txtColorButton[4] = LCD_COLOR_GREEN;
+    sprintf(textButton[4],"Lampe ");
+    sprintf(text1Button[4],"Sejour");
+    sprintf(statusButton[4],"off");
+
+    touchButtonJPA1(1);
+    touchButtonJPA1(2);
+    touchButtonJPA1(3);
+    touchButtonJPA1(4);
+    
+    BSP_LCD_SetFont(&FontFreeMono64); 
+    //BSP_LCD_DisplayStringAt(20, 30, (uint8_t *)"0123456789", LEFT_MODE);
+    //BSP_LCD_DisplayCharJPA(20, 90, '8');
+    BSP_LCD_SetFont(&Font12); 
+    return 0; 
+    }
+    
+int touchJPA1()
+    {
+    //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;
+    
+     
+        //touch screen
+        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++) {
+                    //BSP_LCD_ClearStringLine(idx);
+                }
+            }
+            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);
+            
+            if ((TS_State.touchY[0] > 160) && (TS_State.touchY[0] < (160+80)))
+                {
+                int numTouche = 0;
+                if ((TS_State.touchX[0] > 10) && (TS_State.touchX[0]  < (10+100)))  {numTouche = 1;}
+                if ((TS_State.touchX[0] > 130) && (TS_State.touchX[0] < (130+100))) {numTouche = 2;}
+                if ((TS_State.touchX[0] > 250) && (TS_State.touchX[0] < (250+100))) {numTouche = 3;}
+                if ((TS_State.touchX[0] > 370) && (TS_State.touchX[0] < (370+100))) {numTouche = 4;}
+                if (numTouche >0) 
+                    {
+                    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;
+            if (!cleared) {
+                //BSP_LCD_Clear(LCD_COLOR_DARKBLUE);
+                //sprintf((char*)text, "Touches: 0");
+                //BSP_LCD_DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
+                //cleared = 1;
+                //int ss = touchInitGuiJPA1();
+                //ss=initDisplayTemp();
+            }
+        }
+        //touch screen    
+    return status;
+    }
+    
+int sendTouchJPA(int xx)
+    {
+    uint8_t status = 0;
+            seconds = time(NULL);
+            if((seconds - lastToucheTime) > 1) 
+                {
+                char samples[64] = {0};char resultBuffer[2000]= {0};
+                sprintf(samples,"&Touche=%i",xx);
+                printf("\nSend Touche=%i\n",xx);
+                int sendResult = groveStreams.sendJPA(myMac, samples, gsCompName, gsCompTmplId, resultBuffer, sizeof resultBuffer);
+                if (sendResult == 0) {
+                        ////lcd.printf("Send Successful");
+                        printf("Send Successful\n");
+                        if (strlen(resultBuffer) > 0) {
+                            //printf("HTTP string : %s\n", resultBuffer);
+                            MbedJSONValue mbedJson;
+                            parse(mbedJson, resultBuffer);
+                            
+                            int displayOn = 0;
+                            string s;
+                            if (mbedJson.hasMember("Touche1")) {
+                                s = mbedJson["Touche1"]["BackColor"].get<std::string>();
+                                backColorButton[1] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                                s = mbedJson["Touche1"]["TextColor"].get<std::string>();
+                                txtColorButton[1] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                                s = mbedJson["Touche1"]["Status"].get<std::string>();
+                                sprintf(statusButton[1],s.c_str());
+                                displayOn = (0x02 | displayOn);}
+ 
+                             if (mbedJson.hasMember("Touche2")) {
+                                s = mbedJson["Touche2"]["BackColor"].get<std::string>();
+                                backColorButton[2] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                                s = mbedJson["Touche2"]["TextColor"].get<std::string>();
+                                txtColorButton[2] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                                s = mbedJson["Touche2"]["Status"].get<std::string>();
+                                sprintf(statusButton[2],s.c_str());
+                                displayOn = (0x04 | displayOn);}
+
+                            if (mbedJson.hasMember("Touche3")) {
+                                s = mbedJson["Touche3"]["BackColor"].get<std::string>();
+                                backColorButton[3] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                                s = mbedJson["Touche3"]["TextColor"].get<std::string>();
+                                txtColorButton[3] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                                s = mbedJson["Touche3"]["Status"].get<std::string>();
+                                sprintf(statusButton[3],s.c_str());
+                                displayOn = (0x08 | displayOn);}
+                                
+                            if (mbedJson.hasMember("Touche4")) {
+                                s = mbedJson["Touche4"]["BackColor"].get<std::string>();
+                                backColorButton[4] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                                s = mbedJson["Touche4"]["TextColor"].get<std::string>();
+                                txtColorButton[4] = (uint32_t)strtoul(s.c_str(), NULL,16);
+                                s = mbedJson["Touche4"]["Status"].get<std::string>();
+                                sprintf(statusButton[4],s.c_str());
+                                displayOn = (0x10 | displayOn);}  
+                                                             
+                            if ((displayOn & 0x02) > 0) {touchButtonJPA1(1);}
+                            if ((displayOn & 0x04) > 0) {touchButtonJPA1(2);}
+                            if ((displayOn & 0x08) > 0) {touchButtonJPA1(3);}
+                            if ((displayOn & 0x10) > 0) {touchButtonJPA1(4);}
+                            }
+                        }
+                }
+    
+    return status;    
+    }