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
touchScreenJPA.cpp@16:f0d946e6da36, 2020-12-30 (annotated)
- Committer:
- 38domo
- Date:
- Wed Dec 30 17:22:27 2020 +0000
- Branch:
- jpa
- Revision:
- 16:f0d946e6da36
- Parent:
- 12:15ae35cfb03f
version with updated libs
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
38domo | 0:48863a0964f5 | 1 | |
38domo | 0:48863a0964f5 | 2 | #include "stm32746g_discovery_lcd.h" |
38domo | 0:48863a0964f5 | 3 | #include "stm32746g_discovery_ts.h" |
38domo | 0:48863a0964f5 | 4 | #include "mbed.h" |
38domo | 0:48863a0964f5 | 5 | #include "GroveStreams.h" |
38domo | 0:48863a0964f5 | 6 | #include "MbedJSONValue.h" |
jeanpierreaulas | 5:ceefd0cfa233 | 7 | Timer timer_touch[16]; |
38domo | 0:48863a0964f5 | 8 | |
38domo | 12:15ae35cfb03f | 9 | void sendSerial2(char * str); |
38domo | 12:15ae35cfb03f | 10 | void sendSerial7(char * str); |
38domo | 12:15ae35cfb03f | 11 | |
38domo | 0:48863a0964f5 | 12 | int initDisplayTemp(); |
38domo | 0:48863a0964f5 | 13 | |
38domo | 0:48863a0964f5 | 14 | // GroveStreams Settings |
38domo | 0:48863a0964f5 | 15 | //extern const char gsApiKey[];// = "YOUR_SECRET_API_KEY_HERE"; //Change This!!! |
38domo | 0:48863a0964f5 | 16 | 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. |
38domo | 0:48863a0964f5 | 17 | |
38domo | 0:48863a0964f5 | 18 | extern const char gsCompTmplId[]; //Optional. Tells GS what template to use when the feed initially arrives and a new component needs to be created. |
38domo | 0:48863a0964f5 | 19 | |
38domo | 0:48863a0964f5 | 20 | ////GroveStreams groveStreams(gsApiKey, &lcd); |
38domo | 0:48863a0964f5 | 21 | extern GroveStreams groveStreams; |
38domo | 0:48863a0964f5 | 22 | |
38domo | 0:48863a0964f5 | 23 | extern const char* myMac; |
38domo | 0:48863a0964f5 | 24 | |
38domo | 0:48863a0964f5 | 25 | extern time_t seconds; |
38domo | 0:48863a0964f5 | 26 | time_t seconds_touches = 0; |
38domo | 0:48863a0964f5 | 27 | extern time_t lastToucheTime; |
38domo | 10:41aff2b7acc6 | 28 | // char touch1_text1; |
38domo | 12:15ae35cfb03f | 29 | extern int ethernet_actif ; // use ethernet connection |
38domo | 12:15ae35cfb03f | 30 | extern int wifi_actif ; // use wifi connection |
38domo | 0:48863a0964f5 | 31 | |
38domo | 10:41aff2b7acc6 | 32 | // ----------------------------------------------------------------- |
38domo | 0:48863a0964f5 | 33 | int touchInitJPA1() |
38domo | 0:48863a0964f5 | 34 | { //touch screen init |
38domo | 0:48863a0964f5 | 35 | //touch screen |
38domo | 0:48863a0964f5 | 36 | uint8_t status; |
38domo | 0:48863a0964f5 | 37 | BSP_LCD_Init(); |
38domo | 0:48863a0964f5 | 38 | BSP_LCD_LayerDefaultInit(LTDC_ACTIVE_LAYER, LCD_FB_START_ADDRESS); |
38domo | 0:48863a0964f5 | 39 | BSP_LCD_SelectLayer(LTDC_ACTIVE_LAYER); |
38domo | 0:48863a0964f5 | 40 | BSP_LCD_SetFont(&Font12); |
38domo | 0:48863a0964f5 | 41 | status = BSP_TS_Init(BSP_LCD_GetXSize(), BSP_LCD_GetYSize()); |
38domo | 10:41aff2b7acc6 | 42 | if (status != TS_OK) |
38domo | 10:41aff2b7acc6 | 43 | { BSP_LCD_Clear(LCD_COLOR_RED); |
38domo | 0:48863a0964f5 | 44 | BSP_LCD_SetBackColor(LCD_COLOR_RED); |
38domo | 0:48863a0964f5 | 45 | BSP_LCD_SetTextColor(LCD_COLOR_WHITE); |
38domo | 0:48863a0964f5 | 46 | BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT FAIL", CENTER_MODE); |
38domo | 10:41aff2b7acc6 | 47 | } |
38domo | 10:41aff2b7acc6 | 48 | else |
38domo | 10:41aff2b7acc6 | 49 | { |
38domo | 0:48863a0964f5 | 50 | BSP_LCD_Clear(LCD_COLOR_DARKBLUE); |
38domo | 0:48863a0964f5 | 51 | BSP_LCD_SetBackColor(LCD_COLOR_BLACK); |
38domo | 0:48863a0964f5 | 52 | BSP_LCD_SetTextColor(LCD_COLOR_GREEN); |
38domo | 0:48863a0964f5 | 53 | //BSP_LCD_DisplayStringAt(0, LINE(5), (uint8_t *)"TOUCHSCREEN INIT OK", CENTER_MODE); |
38domo | 10:41aff2b7acc6 | 54 | } |
jeanpierreaulas | 5:ceefd0cfa233 | 55 | int tt = 0; |
jeanpierreaulas | 5:ceefd0cfa233 | 56 | for (tt=0;tt<16;tt++) |
38domo | 10:41aff2b7acc6 | 57 | { if(timer_touch[tt].read_ms() > 500) |
38domo | 10:41aff2b7acc6 | 58 | { timer_touch[tt].stop();timer_touch[tt].reset(); |
38domo | 10:41aff2b7acc6 | 59 | } |
38domo | 10:41aff2b7acc6 | 60 | } |
38domo | 0:48863a0964f5 | 61 | return 0; |
38domo | 0:48863a0964f5 | 62 | } |
38domo | 10:41aff2b7acc6 | 63 | // ------------------------------------------------------- |
38domo | 0:48863a0964f5 | 64 | int xButton[5],yButton[5],dxButton[5],dyButton[5],xTxtButton[5],yTxtButton[5]; |
38domo | 0:48863a0964f5 | 65 | uint32_t backColorButton[5], txtColorButton[5]; |
38domo | 10:41aff2b7acc6 | 66 | extern char textButton[5][8]; |
38domo | 10:41aff2b7acc6 | 67 | extern char text1Button[5][8]; |
38domo | 0:48863a0964f5 | 68 | char statusButton[5][30]; |
38domo | 0:48863a0964f5 | 69 | |
38domo | 10:41aff2b7acc6 | 70 | // ----------------------------------------------------------------------------------------- |
38domo | 0:48863a0964f5 | 71 | int touchButtonJPA1(int numButton) |
38domo | 0:48863a0964f5 | 72 | { |
38domo | 0:48863a0964f5 | 73 | if ((numButton > 0) && (numButton < 5)) |
38domo | 0:48863a0964f5 | 74 | { |
38domo | 0:48863a0964f5 | 75 | BSP_LCD_SetBackColor(backColorButton[numButton]); |
38domo | 0:48863a0964f5 | 76 | BSP_LCD_SetTextColor(backColorButton[numButton]); |
38domo | 0:48863a0964f5 | 77 | BSP_LCD_FillRect(xButton[numButton], yButton[numButton], dxButton[numButton], dyButton[numButton]); |
38domo | 0:48863a0964f5 | 78 | BSP_LCD_SetTextColor(txtColorButton[numButton]); |
38domo | 0:48863a0964f5 | 79 | BSP_LCD_DrawRect(xButton[numButton], yButton[numButton], dxButton[numButton], dyButton[numButton]); |
38domo | 0:48863a0964f5 | 80 | BSP_LCD_SetFont(&Font20); |
38domo | 0:48863a0964f5 | 81 | BSP_LCD_DisplayStringAt(xTxtButton[numButton]+52, yTxtButton[numButton], (uint8_t *)statusButton[numButton], LEFT_MODE); |
38domo | 0:48863a0964f5 | 82 | BSP_LCD_DisplayStringAt(xTxtButton[numButton], yTxtButton[numButton]+28, (uint8_t *)textButton[numButton], LEFT_MODE); |
38domo | 0:48863a0964f5 | 83 | BSP_LCD_DisplayStringAt(xTxtButton[numButton], yTxtButton[numButton]+48, (uint8_t *)text1Button[numButton], LEFT_MODE); |
38domo | 0:48863a0964f5 | 84 | } |
38domo | 0:48863a0964f5 | 85 | return 0; |
38domo | 0:48863a0964f5 | 86 | } |
38domo | 0:48863a0964f5 | 87 | |
38domo | 10:41aff2b7acc6 | 88 | // ---------------------------------------------------------------------------------- |
38domo | 0:48863a0964f5 | 89 | // generation de fonts : http://omz-software.com/pythonista/docs/ios/ImageFont.html |
38domo | 0:48863a0964f5 | 90 | int touchInitGuiJPA1() |
38domo | 10:41aff2b7acc6 | 91 | { // button 1 en bas a gauche |
38domo | 0:48863a0964f5 | 92 | xButton[1]=10;yButton[1]=185;dxButton[1]=100;dyButton[1]=80;xTxtButton[1]=12;yTxtButton[1]=190; |
38domo | 10:41aff2b7acc6 | 93 | backColorButton[1] = LCD_COLOR_GRAY; |
38domo | 10:41aff2b7acc6 | 94 | txtColorButton[1] = LCD_COLOR_GREEN; |
38domo | 10:41aff2b7acc6 | 95 | //sprintf(textButton[1],"Lampe "); |
38domo | 10:41aff2b7acc6 | 96 | //sprintf(text1Button[1],"Sejour"); |
38domo | 0:48863a0964f5 | 97 | sprintf(statusButton[1],"off"); |
38domo | 10:41aff2b7acc6 | 98 | // bouton 2 a cote bouton 1 |
38domo | 0:48863a0964f5 | 99 | xButton[2]=130;yButton[2]=185;dxButton[2]=100;dyButton[2]=80;xTxtButton[2]=132;yTxtButton[2]=190; |
38domo | 0:48863a0964f5 | 100 | backColorButton[2] = LCD_COLOR_GRAY; txtColorButton[2] = LCD_COLOR_GREEN; |
38domo | 10:41aff2b7acc6 | 101 | //sprintf(textButton[2],"Lampe "); |
38domo | 10:41aff2b7acc6 | 102 | //sprintf(text1Button[2],"Sejours"); |
38domo | 0:48863a0964f5 | 103 | sprintf(statusButton[2],"off"); |
38domo | 10:41aff2b7acc6 | 104 | // bouton 3 |
38domo | 0:48863a0964f5 | 105 | xButton[3]=250;yButton[3]=185;dxButton[3]=100;dyButton[3]=80;xTxtButton[3]=252;yTxtButton[3]=190; |
38domo | 0:48863a0964f5 | 106 | backColorButton[3] = LCD_COLOR_GRAY; txtColorButton[3] = LCD_COLOR_GREEN; |
38domo | 10:41aff2b7acc6 | 107 | //sprintf(textButton[3],"Lampe "); |
38domo | 10:41aff2b7acc6 | 108 | //sprintf(text1Button[3],"Sejour"); |
38domo | 0:48863a0964f5 | 109 | sprintf(statusButton[3],"off"); |
38domo | 10:41aff2b7acc6 | 110 | // bouton 4 en bas a ddroite |
38domo | 0:48863a0964f5 | 111 | xButton[4]=370;yButton[4]=185;dxButton[4]=100;dyButton[4]=80;xTxtButton[4]=372;yTxtButton[4]=190; |
38domo | 0:48863a0964f5 | 112 | backColorButton[4] = LCD_COLOR_GRAY; txtColorButton[4] = LCD_COLOR_GREEN; |
38domo | 10:41aff2b7acc6 | 113 | //sprintf(textButton[4],"Lampe "); |
38domo | 10:41aff2b7acc6 | 114 | //sprintf(text1Button[4],"Sejour"); |
38domo | 0:48863a0964f5 | 115 | sprintf(statusButton[4],"off"); |
38domo | 0:48863a0964f5 | 116 | |
38domo | 0:48863a0964f5 | 117 | touchButtonJPA1(1); |
38domo | 0:48863a0964f5 | 118 | touchButtonJPA1(2); |
38domo | 0:48863a0964f5 | 119 | touchButtonJPA1(3); |
38domo | 0:48863a0964f5 | 120 | touchButtonJPA1(4); |
38domo | 0:48863a0964f5 | 121 | |
38domo | 0:48863a0964f5 | 122 | BSP_LCD_SetFont(&FontFreeMono64); |
38domo | 0:48863a0964f5 | 123 | //BSP_LCD_DisplayStringAt(20, 30, (uint8_t *)"0123456789", LEFT_MODE); |
38domo | 0:48863a0964f5 | 124 | //BSP_LCD_DisplayCharJPA(20, 90, '8'); |
38domo | 0:48863a0964f5 | 125 | BSP_LCD_SetFont(&Font12); |
38domo | 0:48863a0964f5 | 126 | return 0; |
38domo | 0:48863a0964f5 | 127 | } |
38domo | 10:41aff2b7acc6 | 128 | |
38domo | 10:41aff2b7acc6 | 129 | // -------------------------------------------------------------------------- |
38domo | 0:48863a0964f5 | 130 | int touchJPA1() |
38domo | 0:48863a0964f5 | 131 | { |
38domo | 0:48863a0964f5 | 132 | //touch screen |
38domo | 0:48863a0964f5 | 133 | TS_StateTypeDef TS_State; |
38domo | 0:48863a0964f5 | 134 | uint16_t x, y; |
38domo | 0:48863a0964f5 | 135 | uint8_t text[30]; |
38domo | 0:48863a0964f5 | 136 | uint8_t status = 0; |
38domo | 0:48863a0964f5 | 137 | uint8_t idx; |
38domo | 0:48863a0964f5 | 138 | static uint8_t cleared = 0; |
38domo | 0:48863a0964f5 | 139 | uint8_t prev_nb_touches = 0; |
38domo | 0:48863a0964f5 | 140 | |
jeanpierreaulas | 5:ceefd0cfa233 | 141 | int tt = 0; |
jeanpierreaulas | 5:ceefd0cfa233 | 142 | for (tt=0;tt<16;tt++) |
jeanpierreaulas | 5:ceefd0cfa233 | 143 | {if(timer_touch[tt].read_ms() > 200) |
jeanpierreaulas | 5:ceefd0cfa233 | 144 | {timer_touch[tt].stop();timer_touch[tt].reset();}} |
38domo | 0:48863a0964f5 | 145 | //touch screen |
38domo | 0:48863a0964f5 | 146 | BSP_TS_GetState(&TS_State); |
38domo | 0:48863a0964f5 | 147 | if (TS_State.touchDetected) { |
38domo | 0:48863a0964f5 | 148 | // Clear lines corresponding to old touches coordinates |
38domo | 0:48863a0964f5 | 149 | if (TS_State.touchDetected < prev_nb_touches) { |
38domo | 0:48863a0964f5 | 150 | for (idx = (TS_State.touchDetected + 1); idx <= 5; idx++) { |
38domo | 0:48863a0964f5 | 151 | //BSP_LCD_ClearStringLine(idx); |
38domo | 0:48863a0964f5 | 152 | } |
38domo | 0:48863a0964f5 | 153 | } |
38domo | 0:48863a0964f5 | 154 | prev_nb_touches = TS_State.touchDetected; |
38domo | 0:48863a0964f5 | 155 | |
38domo | 0:48863a0964f5 | 156 | cleared = 0; |
38domo | 0:48863a0964f5 | 157 | |
38domo | 0:48863a0964f5 | 158 | //sprintf((char*)text, "Touches: %d", TS_State.touchDetected); |
38domo | 0:48863a0964f5 | 159 | //BSP_LCD_DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE); |
38domo | 0:48863a0964f5 | 160 | |
38domo | 0:48863a0964f5 | 161 | for (idx = 0; idx < TS_State.touchDetected; idx++) { |
38domo | 0:48863a0964f5 | 162 | x = TS_State.touchX[idx]; |
38domo | 0:48863a0964f5 | 163 | y = TS_State.touchY[idx]; |
38domo | 0:48863a0964f5 | 164 | //sprintf((char*)text, "Touch %d: x=%d y=%d ", idx+1, x, y); |
38domo | 0:48863a0964f5 | 165 | //BSP_LCD_DisplayStringAt(0, LINE(idx+1), (uint8_t *)&text, LEFT_MODE); |
38domo | 0:48863a0964f5 | 166 | } |
38domo | 0:48863a0964f5 | 167 | |
38domo | 0:48863a0964f5 | 168 | //BSP_LCD_DrawPixel(TS_State.touchX[0], TS_State.touchY[0], LCD_COLOR_ORANGE); |
38domo | 0:48863a0964f5 | 169 | |
38domo | 0:48863a0964f5 | 170 | if ((TS_State.touchY[0] > 160) && (TS_State.touchY[0] < (160+80))) |
38domo | 0:48863a0964f5 | 171 | { |
38domo | 0:48863a0964f5 | 172 | int numTouche = 0; |
jeanpierreaulas | 5:ceefd0cfa233 | 173 | if ((TS_State.touchX[0] > 10) && (TS_State.touchX[0] < (10+100))) |
jeanpierreaulas | 5:ceefd0cfa233 | 174 | {if(timer_touch[0].read_ms() == 0) {numTouche = 1;timer_touch[0].start();}} |
jeanpierreaulas | 5:ceefd0cfa233 | 175 | if ((TS_State.touchX[0] > 130) && (TS_State.touchX[0] < (130+100))) |
jeanpierreaulas | 5:ceefd0cfa233 | 176 | {if(timer_touch[1].read_ms() == 0) {numTouche = 2;timer_touch[1].start();}} |
jeanpierreaulas | 5:ceefd0cfa233 | 177 | if ((TS_State.touchX[0] > 250) && (TS_State.touchX[0] < (250+100))) |
jeanpierreaulas | 5:ceefd0cfa233 | 178 | {if(timer_touch[2].read_ms() == 0) {numTouche = 3;timer_touch[2].start();}} |
jeanpierreaulas | 5:ceefd0cfa233 | 179 | if ((TS_State.touchX[0] > 370) && (TS_State.touchX[0] < (370+100))) |
jeanpierreaulas | 5:ceefd0cfa233 | 180 | {if(timer_touch[3].read_ms() == 0) {numTouche = 4;timer_touch[3].start();}} |
38domo | 0:48863a0964f5 | 181 | if (numTouche >0) |
38domo | 0:48863a0964f5 | 182 | { |
38domo | 0:48863a0964f5 | 183 | printf("Touche : %d", numTouche); |
38domo | 0:48863a0964f5 | 184 | sprintf((char*)text, "Touche : %d", numTouche); |
38domo | 0:48863a0964f5 | 185 | //BSP_LCD_DisplayStringAt(200,0, (uint8_t *)&text, LEFT_MODE); |
38domo | 0:48863a0964f5 | 186 | status = numTouche; |
38domo | 0:48863a0964f5 | 187 | } |
38domo | 0:48863a0964f5 | 188 | else {lastToucheTime = 0;} |
38domo | 0:48863a0964f5 | 189 | } |
38domo | 0:48863a0964f5 | 190 | } else { |
38domo | 0:48863a0964f5 | 191 | lastToucheTime = 0; |
38domo | 0:48863a0964f5 | 192 | if (!cleared) { |
38domo | 0:48863a0964f5 | 193 | //BSP_LCD_Clear(LCD_COLOR_DARKBLUE); |
38domo | 0:48863a0964f5 | 194 | //sprintf((char*)text, "Touches: 0"); |
38domo | 0:48863a0964f5 | 195 | //BSP_LCD_DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE); |
38domo | 0:48863a0964f5 | 196 | //cleared = 1; |
38domo | 0:48863a0964f5 | 197 | //int ss = touchInitGuiJPA1(); |
38domo | 0:48863a0964f5 | 198 | //ss=initDisplayTemp(); |
38domo | 0:48863a0964f5 | 199 | } |
38domo | 0:48863a0964f5 | 200 | } |
38domo | 0:48863a0964f5 | 201 | //touch screen |
38domo | 0:48863a0964f5 | 202 | return status; |
38domo | 0:48863a0964f5 | 203 | } |
38domo | 10:41aff2b7acc6 | 204 | |
38domo | 10:41aff2b7acc6 | 205 | // ----------------------------------------------------------------------- |
38domo | 0:48863a0964f5 | 206 | int sendTouchJPA(int xx) |
38domo | 12:15ae35cfb03f | 207 | { uint8_t status = 0; |
38domo | 12:15ae35cfb03f | 208 | seconds = time(NULL); |
38domo | 12:15ae35cfb03f | 209 | if((seconds - lastToucheTime) > 1) |
38domo | 12:15ae35cfb03f | 210 | { char samples[64] = {0};char resultBuffer[2000]= {0}; |
38domo | 12:15ae35cfb03f | 211 | sprintf(samples,"&Touche=%i",xx); |
38domo | 12:15ae35cfb03f | 212 | printf("\nSend Touche=%i\n",xx); |
38domo | 12:15ae35cfb03f | 213 | // modifier pour rajouter test ethernet / wifi et action en fonction |
38domo | 12:15ae35cfb03f | 214 | if (ethernet_actif == 1 ) // ethernet actif |
38domo | 12:15ae35cfb03f | 215 | { printf("\ntraitement Ethernet\n",xx); |
38domo | 12:15ae35cfb03f | 216 | int sendResult = groveStreams.sendJPA(myMac, samples, gsCompName, gsCompTmplId, resultBuffer, sizeof resultBuffer); |
38domo | 12:15ae35cfb03f | 217 | if (sendResult == 0) |
38domo | 12:15ae35cfb03f | 218 | { ////lcd.printf("Send Successful"); |
38domo | 0:48863a0964f5 | 219 | printf("Send Successful\n"); |
38domo | 12:15ae35cfb03f | 220 | if (strlen(resultBuffer) > 0) |
38domo | 12:15ae35cfb03f | 221 | { //printf("HTTP string : %s\n", resultBuffer); |
38domo | 0:48863a0964f5 | 222 | MbedJSONValue mbedJson; |
38domo | 12:15ae35cfb03f | 223 | parse(mbedJson, resultBuffer); |
38domo | 0:48863a0964f5 | 224 | int displayOn = 0; |
38domo | 0:48863a0964f5 | 225 | string s; |
38domo | 12:15ae35cfb03f | 226 | if (mbedJson.hasMember("Touche1")) |
38domo | 12:15ae35cfb03f | 227 | { s = mbedJson["Touche1"]["BackColor"].get<std::string>(); |
38domo | 0:48863a0964f5 | 228 | backColorButton[1] = (uint32_t)strtoul(s.c_str(), NULL,16); |
38domo | 0:48863a0964f5 | 229 | s = mbedJson["Touche1"]["TextColor"].get<std::string>(); |
38domo | 0:48863a0964f5 | 230 | txtColorButton[1] = (uint32_t)strtoul(s.c_str(), NULL,16); |
38domo | 0:48863a0964f5 | 231 | s = mbedJson["Touche1"]["Status"].get<std::string>(); |
38domo | 0:48863a0964f5 | 232 | sprintf(statusButton[1],s.c_str()); |
38domo | 12:15ae35cfb03f | 233 | displayOn = (0x02 | displayOn); |
38domo | 12:15ae35cfb03f | 234 | } |
38domo | 12:15ae35cfb03f | 235 | if (mbedJson.hasMember("Touche2")) |
38domo | 12:15ae35cfb03f | 236 | { s = mbedJson["Touche2"]["BackColor"].get<std::string>(); |
38domo | 0:48863a0964f5 | 237 | backColorButton[2] = (uint32_t)strtoul(s.c_str(), NULL,16); |
38domo | 0:48863a0964f5 | 238 | s = mbedJson["Touche2"]["TextColor"].get<std::string>(); |
38domo | 0:48863a0964f5 | 239 | txtColorButton[2] = (uint32_t)strtoul(s.c_str(), NULL,16); |
38domo | 0:48863a0964f5 | 240 | s = mbedJson["Touche2"]["Status"].get<std::string>(); |
38domo | 0:48863a0964f5 | 241 | sprintf(statusButton[2],s.c_str()); |
38domo | 12:15ae35cfb03f | 242 | displayOn = (0x04 | displayOn); |
38domo | 12:15ae35cfb03f | 243 | } |
38domo | 12:15ae35cfb03f | 244 | if (mbedJson.hasMember("Touche3")) |
38domo | 12:15ae35cfb03f | 245 | { s = mbedJson["Touche3"]["BackColor"].get<std::string>(); |
38domo | 0:48863a0964f5 | 246 | backColorButton[3] = (uint32_t)strtoul(s.c_str(), NULL,16); |
38domo | 0:48863a0964f5 | 247 | s = mbedJson["Touche3"]["TextColor"].get<std::string>(); |
38domo | 0:48863a0964f5 | 248 | txtColorButton[3] = (uint32_t)strtoul(s.c_str(), NULL,16); |
38domo | 0:48863a0964f5 | 249 | s = mbedJson["Touche3"]["Status"].get<std::string>(); |
38domo | 0:48863a0964f5 | 250 | sprintf(statusButton[3],s.c_str()); |
38domo | 12:15ae35cfb03f | 251 | displayOn = (0x08 | displayOn); |
38domo | 12:15ae35cfb03f | 252 | } |
38domo | 12:15ae35cfb03f | 253 | if (mbedJson.hasMember("Touche4")) |
38domo | 12:15ae35cfb03f | 254 | { s = mbedJson["Touche4"]["BackColor"].get<std::string>(); |
38domo | 0:48863a0964f5 | 255 | backColorButton[4] = (uint32_t)strtoul(s.c_str(), NULL,16); |
38domo | 0:48863a0964f5 | 256 | s = mbedJson["Touche4"]["TextColor"].get<std::string>(); |
38domo | 0:48863a0964f5 | 257 | txtColorButton[4] = (uint32_t)strtoul(s.c_str(), NULL,16); |
38domo | 0:48863a0964f5 | 258 | s = mbedJson["Touche4"]["Status"].get<std::string>(); |
38domo | 0:48863a0964f5 | 259 | sprintf(statusButton[4],s.c_str()); |
38domo | 12:15ae35cfb03f | 260 | displayOn = (0x10 | displayOn); |
38domo | 12:15ae35cfb03f | 261 | } |
38domo | 0:48863a0964f5 | 262 | if ((displayOn & 0x02) > 0) {touchButtonJPA1(1);} |
38domo | 0:48863a0964f5 | 263 | if ((displayOn & 0x04) > 0) {touchButtonJPA1(2);} |
38domo | 0:48863a0964f5 | 264 | if ((displayOn & 0x08) > 0) {touchButtonJPA1(3);} |
38domo | 0:48863a0964f5 | 265 | if ((displayOn & 0x10) > 0) {touchButtonJPA1(4);} |
38domo | 12:15ae35cfb03f | 266 | }// fin test result buffer |
38domo | 12:15ae35cfb03f | 267 | } // fin test send result |
38domo | 12:15ae35cfb03f | 268 | } // fin test ethernet actif |
38domo | 12:15ae35cfb03f | 269 | else if (wifi_actif == 1) // wifi actif -------------------------------- |
38domo | 12:15ae35cfb03f | 270 | { // send trame to wifi to inform touch pressed |
38domo | 12:15ae35cfb03f | 271 | printf("\nSend Touche=%i status=%s \n ",xx,statusButton[4] ); |
38domo | 12:15ae35cfb03f | 272 | // {"Touche":{ "No":"4","Statusl":"Off"}} |
38domo | 12:15ae35cfb03f | 273 | sprintf(samples,"{\"Touche\":{\"No\":\"%i\",\"Status\":\"%s\"}}",xx,statusButton[xx]); |
38domo | 12:15ae35cfb03f | 274 | printf(samples); |
38domo | 12:15ae35cfb03f | 275 | printf ("\n"); |
38domo | 12:15ae35cfb03f | 276 | sendSerial2(samples); |
38domo | 12:15ae35cfb03f | 277 | } |
38domo | 12:15ae35cfb03f | 278 | else // traitement en local |
38domo | 12:15ae35cfb03f | 279 | { printf("\nTraitement local\n"); |
38domo | 12:15ae35cfb03f | 280 | } |
38domo | 12:15ae35cfb03f | 281 | } |
38domo | 0:48863a0964f5 | 282 | return status; |
38domo | 0:48863a0964f5 | 283 | } |