![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
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
Diff: main.cpp
- Branch:
- jpa
- Revision:
- 12:15ae35cfb03f
- Parent:
- 11:b198b2f2676f
- Child:
- 13:fdec444a7b30
diff -r b198b2f2676f -r 15ae35cfb03f main.cpp --- a/main.cpp Wed Sep 16 05:47:02 2020 +0000 +++ b/main.cpp Thu Sep 17 20:32:02 2020 +0000 @@ -9,22 +9,38 @@ // 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 +192.168.1.30 +0;Ethernet +1;WiFi +1;can +1;serial +F;Fonction +0;Touche1 status : off +0xFF00FF00;Touche1 BackColor +0xFF000000;Touche1 TextColor +Pompe ; Touche1 text +Piscine ; Touche1 text1 +1;Touche2 Status : off +0xFFFF0000; Touche2 BackColor +0xFFFFFFFF; Touche2 TextColor +Eclair ;Touche2 text +Piscine ;Touche2 text1 +0; Touche3 Status : off +0xFF00FF00; Touche3 BackColor +0xFFFFFF00; Touche3 TextColor +Leds Bl ;Touche3 text +Piscine ; Touche3 text1 +1; Touche4 Status : off +0xFF800000; Touche4 BackColor +0xFFFFFF00; Touche4 TextColor +Porche ; Touche4 text +entree ; Touche4 text1 +Temp Piscine ; Temp1 text +0xFF404040; backColorTemp1 +0xFFFFFF00; txtColorTemp1 +Temp Exterieur ; Temp2 text +0xFF404040; backColorTemp2 +0xFFFFFF00; txtColorTemp2 // works ok 31/07/2020 // updated package from jpa @@ -64,6 +80,8 @@ extern char textButton[5][8]; extern char text1Button[5][8]; extern char textTempTitle[3][30]; +extern uint32_t backColorButton[5], txtColorButton[5]; +extern char statusButton[5][30]; //#include "touchScreen.cpp" int touchInitJPA1(); @@ -271,17 +289,8 @@ //BSP_LCD_SetBackColor(LCD_COLOR_RED); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_SetBackColor(LCD_COLOR_RED); - BSP_LCD_SetTextColor(LCD_COLOR_WHITE); - // backColorTemp1 = (uint32_t)strtoul("0xFF808080", NULL,16); //gray - // txtColorTemp1 = (uint32_t)strtoul("0xFFFFFF00", NULL,16) ; - // //sprintf(textTempTitle[1],s.c_str()); - //printf("Temp1 text : %s\n",s.c_str()); - // backColorTemp2 = (uint32_t)strtoul("0xFF808080", NULL,16); - // txtColorTemp2 = (uint32_t)strtoul("0xFFFFFF00", NULL,16) ; - - int pp = setTemp1("temp1"); // display temp1 on lcd - BSP_LCD_DisplayStringAt(0, LINE(7), (uint8_t *)"displ temp1", CENTER_MODE); - + BSP_LCD_SetTextColor(LCD_COLOR_WHITE); + // main loop --------------------------------------------------- while (true) { if (CanRcv > 0) @@ -308,27 +317,87 @@ //resultBuffer = stringSerial2; //if (strlen(resultBuffer) > 0 && resultBuffer[0] == '{') if (strlen(stringSerial2) > 0 && stringSerial2[0] == '{') - { MbedJSONValue mbedJson; - //parse(mbedJson, resultBuffer); + { MbedJSONValue mbedJson; //parse(mbedJson, resultBuffer); parse(mbedJson, stringSerial2); - //sprintf((char*)text, "HTTP string : %s\n", resultBuffer); - sprintf((char*)text, "HTTP string : %s\n", stringSerial2); - //BSP_LCD_DisplayStringAt(0, LINE(1), (uint8_t *)&text, LEFT_MODE); - if (mbedJson.hasMember("Temp1")) { - printf("Serial2 temp1: %s",stringSerial2); - //int pp=setTemp1(mbedJson["Temp1"].get<std::string>()); - int pp = setTemp1(mbedJson["Temp1"].get<std::string>()); // display temp1 on lcd - + sprintf((char*)text, "HTTP string : %s\n", stringSerial2); + if (mbedJson.hasMember("Temp1")) + { printf("Serial2 temp1: %s",stringSerial2); + int pp = setTemp1(mbedJson["Temp1"].get<std::string>()); // display temp1 on lcd + } + if (mbedJson.hasMember("Temp2")) + { int tt=setTemp2(mbedJson["Temp2"].get<std::string>()); + } + // add buttons parameters + // decode button trame + if (mbedJson.hasMember("Touche4")) + { printf("Touche 4 update status received"); + string s; + s = mbedJson["Touche4"]["Status"].get<std::string>(); + sprintf(statusButton[4],s.c_str()); + printf(s.c_str()); + printf("\n"); + if (s=="on") + { txtColorButton[4] = (uint32_t)strtoul("0xFF00FF00", NULL,16); + backColorButton[4] = (uint32_t)strtoul("0xFF000000", NULL,16); + } + else + { txtColorButton[4] = (uint32_t)strtoul("0xFF000000", NULL,16); + backColorButton[4] = (uint32_t)strtoul("0xFF00FF00", NULL,16); + } + touchButtonJPA1(4); } - if (mbedJson.hasMember("Temp2")) { - int tt=setTemp2(mbedJson["Temp2"].get<std::string>()); - + if (mbedJson.hasMember("Touche1")) + { printf("Touche 1 update status received"); + string s; + s = mbedJson["Touche1"]["Status"].get<std::string>(); + sprintf(statusButton[1],s.c_str()); + printf(s.c_str()); + printf("\n"); + if (s=="on") + { txtColorButton[1] = (uint32_t)strtoul("0xFF00FF00", NULL,16); + backColorButton[1] = (uint32_t)strtoul("0xFF000000", NULL,16); + } + else + { txtColorButton[1] = (uint32_t)strtoul("0xFF000000", NULL,16); + backColorButton[1] = (uint32_t)strtoul("0xFF00FF00", NULL,16); + } + touchButtonJPA1(1); } - - } - - - + if (mbedJson.hasMember("Touche2")) + { printf("Touche 2 update status received"); + string s; + s = mbedJson["Touche2"]["Status"].get<std::string>(); + sprintf(statusButton[2],s.c_str()); + printf(s.c_str()); + printf("\n"); + if (s=="on") + { txtColorButton[2] = (uint32_t)strtoul("0xFF00FF00", NULL,16); + backColorButton[2] = (uint32_t)strtoul("0xFF000000", NULL,16); + } + else + { txtColorButton[2] = (uint32_t)strtoul("0xFF000000", NULL,16); + backColorButton[2] = (uint32_t)strtoul("0xFF00FF00", NULL,16); + } + touchButtonJPA1(2); + } + if (mbedJson.hasMember("Touche3")) + { printf("Touche 3 update status received"); + string s; + s = mbedJson["Touche3"]["Status"].get<std::string>(); + sprintf(statusButton[3],s.c_str()); + printf(s.c_str()); + printf("\n"); + if (s=="on") + { txtColorButton[3] = (uint32_t)strtoul("0xFF00FF00", NULL,16); + backColorButton[3] = (uint32_t)strtoul("0xFF000000", NULL,16); + } + else + { txtColorButton[3] = (uint32_t)strtoul("0xFF000000", NULL,16); + backColorButton[3] = (uint32_t)strtoul("0xFF00FF00", NULL,16); + } + touchButtonJPA1(3); + } + } } if (msgSerial7 > 0) {receiveSerial7();} if (stringSerial7ok == 1) {printf("Trame Serial7 : %s",stringSerial7);stringSerial7ok=0;} @@ -346,14 +415,16 @@ txMsg.data[0]=8;txMsg.data[1]=counter; // append data (total data length must be <= 8 bytes!) if(can.write(txMsg)) // transmit message { //if(can->write(txMsg)) { // transmit the CAN message + printf("TX CAN OK \n"); printMsg(txMsg,0); - BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"TX CAN OK", CENTER_MODE); - BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"--------", CENTER_MODE); + //BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"TX CAN OK", CENTER_MODE); + //BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"--------", CENTER_MODE); } else { //serialUSB.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); + printf("TX CAN Fail \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 @@ -369,11 +440,13 @@ if(can.write(txMsg)) // transmit message { printMsg(txMsg,0); - BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"TX CAN OK", CENTER_MODE); - BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"--------", CENTER_MODE); + printf("TX CAN OK \n"); + //BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"TX CAN OK", CENTER_MODE); + //BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"--------", CENTER_MODE); } else - { BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"TX CAN Fail", CENTER_MODE); + { printf("TX CAN Fail \n"); + BSP_LCD_DisplayStringAt(0, LINE(4), (uint8_t *)"TX CAN Fail", CENTER_MODE); BSP_LCD_DisplayStringAt(0, LINE(3), (uint8_t *)"-----------", CENTER_MODE); } }