![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
updated version with parameters loaded from sdcard
Dependencies: F7_Ethernet mbed MbedJSONValue LCD_DISCO_F746NG mbed-rtos BSP_DISCO_F746NG CANMsg NetworkAPI SDFileSystem_Warning_Fixed GroveStreamsmodified LcdDiscoF746NgTracer JSON
Diff: GuiJPA.cpp
- Branch:
- jpa
- Revision:
- 10:41aff2b7acc6
- Parent:
- 0:48863a0964f5
- Child:
- 11:b198b2f2676f
--- a/GuiJPA.cpp Tue Sep 08 15:01:08 2020 +0000 +++ b/GuiJPA.cpp Tue Sep 15 19:11:11 2020 +0000 @@ -7,12 +7,17 @@ int touchButtonJPA1(int numButton); extern uint32_t backColorButton[5]; extern uint32_t txtColorButton[5]; -extern char textButton[5][30]; -extern char text1Button[5][30]; +char textButton[5][30]; + char text1Button[5][30]; extern char statusButton[5][30]; + +extern int ethernet_actif ; // use ethernet connection +extern int wifi_actif ; // use wifi connection + 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()); @@ -23,7 +28,7 @@ BSP_LCD_SetFont(&Font12); return 1; } - +// ------------------------------------------------ int setTemp2(std::string temp2) { printf("\nTemp2 : %s\n", temp2.c_str()); @@ -39,6 +44,7 @@ uint32_t backColorTempTitle[3], txtColorTempTitle[3]; char textTempTitle[3][30]; +// ------------------------------------------------------------ int setDisplayTemp() { int numTemp=0; for (numTemp=1;numTemp<3;numTemp=numTemp+1) @@ -55,6 +61,7 @@ return 1; } +// ------------------------------------------------------- int initDisplayTemp() { printf("\nInit DisplayTemp \n"); xTempTitle[1]=14;yTempTitle[1]=30; @@ -79,7 +86,8 @@ extern GroveStreams groveStreams; extern const char* myMac; - +int displayOn = 0; +// ------------------------------------------------------------ int initDatasGuiJPA() { ////lcd.clear(); ////lcd.printf("Getting Samples..."); @@ -95,21 +103,39 @@ char resultBuffer[2000]= {0}; //Sending Samples (and returning current command stream values) int sendResult=1; + printf("InitDataGuiJPA - Ethernet actif %i \n", ethernet_actif); + if (ethernet_actif == 0) // ethernet inactif + { // on n'utilise pas ethernet. lecture valeurs from sdcard + printf("Use local graphic datas\n"); + // display temp1 window + // display temp2 + // add wifi test. + // if wifi actif send request tasmota to retrieve values text box & buttons status + if (wifi_actif == 0) + { // si wifi actif launch tasmota request + + // reteive tasmota results to display + } + displayOn = (0x01 | displayOn);// display temp1 & temp2 box + + } + else + { sendResult = groveStreams.sendInitDatasJPA(myMac, samples, gsCompName, gsCompTmplId, resultBuffer, sizeof resultBuffer); - if (sendResult == 0) { - ////lcd.printf("Send Successful"); + 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); + 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; + //int displayOn = 0; string s; - if (mbedJson.hasMember("Temp1")) { - s = mbedJson["Temp1"]["backColorTemp"].get<std::string>(); + 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>(); @@ -119,9 +145,9 @@ 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>(); + } + 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>(); @@ -131,9 +157,9 @@ 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>(); + } + 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>(); @@ -149,9 +175,9 @@ 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>(); + } + 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>(); @@ -167,9 +193,9 @@ 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>(); + } + 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>(); @@ -185,9 +211,9 @@ 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>(); + } + 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>(); @@ -203,20 +229,23 @@ 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 (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 & 0x02) > 0) {touchButtonJPA1(1);} if ((displayOn & 0x04) > 0) {touchButtonJPA1(2);} if ((displayOn & 0x08) > 0) {touchButtonJPA1(3);} if ((displayOn & 0x10) > 0) {touchButtonJPA1(4);} } - } + } // fin test send result + } // fin test ethernet actif + if ((displayOn & 0x01) > 0) {setDisplayTemp();} + return 1; }