2

Dependencies:   RemoteIR TextLCD

Revision:
57:65dd71a6ce72
Parent:
56:d02c62149a19
Child:
58:cdfbedad5df6
--- a/main.cpp	Thu Sep 03 02:30:29 2020 +0000
+++ b/main.cpp	Thu Sep 03 06:03:01 2020 +0000
@@ -192,6 +192,9 @@
 int SERVtimeout =5;    // set server timeout in seconds in case link breaks.
 char ssid[32] = "mbed05"; // enter WiFi router ssid inside the quotes
 char pwd [32] = "0123456789a"; // enter WiFi router password inside the quotes
+bool click_log = false; 
+DigitalOut  pred(p16);
+DigitalOut  pblue(p19);
 
 /* プロトタイプ宣言 */
 void decodeIR(/*void const *argument*/);
@@ -732,6 +735,7 @@
 
 /* ディスプレイ表示関数 */
 void display(){
+   //     pblue=!pblue;
         mutex.lock();         // ミューテックスロック
         lcd.setAddress(0,1);
         
@@ -794,6 +798,8 @@
                 break;
         }
         mutex.unlock();     // ミューテックスアンロック
+    //    pblue=!pblue;
+
 }
 
 /* バックライト点滅 */
@@ -869,19 +875,19 @@
     while(1) {
         if(DataRX==1) {
             //*-*-*-5("\f\n\r------------ main while > if --------------\n\r");
-            click_flag = 1;
+//            click_flag = 1;
+            click_log=false;
             ReadWebData();
             //*-*-*-5("\f\n\r------------ click_flag=%d --------------\n\r",click_flag);
             //if ((servreq == 1 && weberror == 0) && click_flag == 1) {
-            if (servreq == 1 && weberror == 0) {
+            if (servreq == 1 && weberror == 0 && click_log == false) {
                 //*-*-*-5("\f\n\r------------ befor send page --------------\n\r");
-                sendpage();
-            }
+                sendpage();            }
             //*-*-*-5("\f\n\r------------ send_check begin --------------\n\r");
  
             //sendcheck();
             //*-*-*-5("\f\n\r------------ ssend_check end--------------\n\r");
- 
+            memset(webbuff, '\0', sizeof(webbuff));
             esp.attach(&callback);
             //*-*-*-5(" IPD Data:\r\n\n Link ID = %d,\r\n IPD Header Length = %d \r\n IPD Type = %s\r\n", linkID, ipdLen, type);
             //*-*-*-5("\n\n  HTTP Packet: \n\n%s\n", webdata);
@@ -1094,20 +1100,13 @@
     strcat(webbuff, "</html>");
     
     strcat(webbuff, "<script language=\"javascript\" type=\"text/javascript\">");       //機能
-    
-    strcat(webbuff, "var button_9 = document.getElementsByTagName(\"button\");");
-    
+        
 //ボタン入力時それぞれの関数から呼び出されサーバーとの通信を行う
-    strcat(webbuff, "function htmlacs(url) {");
-        strcat(webbuff, "for(var m=0;m<11;m++){button_9[m].disabled=true;}");  
-        strcat(webbuff, "var xhr = new XMLHttpRequest();");
-        strcat(webbuff, "xhr.open(\"GET\", url);");
-        strcat(webbuff, "xhr.onreadystatechange = function(){");
-            strcat(webbuff, "if(this.readyState == 4 || this.status == 200){");
-                strcat(webbuff, "for(var m=0;m<11;m++){button_9[m].disabled=false;}");
-            strcat(webbuff, "}");
-        strcat(webbuff, "};");
-        strcat(webbuff, "xhr.send(\"\");");
+    strcat(webbuff, "function htmlacs(url) {"); 
+    strcat(webbuff, "var xhr = new XMLHttpRequest();");
+    strcat(webbuff, "xhr.open(\"GET\", url, true);");
+    strcat(webbuff, "xhr.send();");
+    strcat(webbuff, "setTimeout(function(){xhr.abort();},100);");
     strcat(webbuff, "}");
     
 //mode変更ボタン入力時動作 //sendmes
@@ -1254,18 +1253,21 @@
         //*-*-*-5("+++++++++++++++++succed rec end+++++++++++++++++++++\r\n");
         beforeMode = mode;
         if( strstr(webdata, "Normal") != NULL ) {
+            click_log=true;
             //*-*-*-5("++++++++++++++++++Normal++++++++++++++++++++");
             mode = SPEED;       // スピードモード
             flag_sp = 0;
             display();          // ディスプレイ表示
             mode = beforeMode;  // 現在のモードに前回のモードを設定
         }else if( strstr(webdata, "VeryFast") != NULL ) {
+            click_log=true;
             //*-*-*-5("+++++++++++++++++++VeryFast+++++++++++++++++++");
             mode = SPEED;       // スピードモード 
             flag_sp = 2;
             display();          // ディスプレイ表示
             mode = beforeMode;  // 現在のモードに前回のモードを設定
         }else if( strstr(webdata, "Fast") != NULL ) {
+            click_log=true;
             //*-*-*-5("++++++++++++++++++++Fast++++++++++++++++++");
             mode = SPEED;       // スピードモード
             flag_sp = 1;
@@ -1273,6 +1275,8 @@
             mode = beforeMode;  // 現在のモードに前回のモードを設定
         }
         if( strstr(webdata, "GO") != NULL ) {
+            pred=!pred;
+            click_log=true;
             //*-*-*-5("+++++++++++++++++前進+++++++++++++++++++++\r\n");
             run = ADVANCE;          // 前進
             mode = ADVANCE;         // モード変更
@@ -1280,6 +1284,7 @@
         }
  
         if( strstr(webdata, "LEFT") != NULL ) {
+            click_log=true;
             //*-*-*-5("+++++++++++++++++左折+++++++++++++++++++++\r\n");
             run = LEFT;             // 左折
             mode = LEFT;            // モード変更
@@ -1287,6 +1292,7 @@
         }
  
         if( strstr(webdata, "STOP") != NULL ) {
+            click_log=true;
             //*-*-*-5("+++++++++++++++++停止+++++++++++++++++++++\r\n");
             run = STOP;             // 停止
             mode = STOP;            // モード変更
@@ -1294,6 +1300,7 @@
         }
  
         if( strstr(webdata, "RIGHT") != NULL ) {
+            click_log=true;
             //*-*-*-5("+++++++++++++++++右折+++++++++++++++++++++\r\n");
             run = RIGHT;            // 右折
             mode = RIGHT;           // モード変更
@@ -1301,6 +1308,7 @@
         }
  
         if( strstr(webdata, "BACK") != NULL ) {
+            click_log=true;
             //*-*-*-5("+++++++++++++++++後進+++++++++++++++++++++\r\n");
             run = BACK;             // 後進
             mode = BACK;            // モード変更
@@ -1309,6 +1317,7 @@
         //*-*-*-5("+++++++++++++++++succed+++++++++++++++++++++");
  
         if( strstr(webdata, "AVOIDANCE") != NULL ) {
+            click_log=true;
             //*-*-*-5("+++++++++++++++++AVOIDANCE+++++++++++++++++++++");
             if(avoi_thread->get_state() == Thread::Deleted) {
                 delete avoi_thread;     //障害物回避スレッド停止
@@ -1320,6 +1329,7 @@
             display();          // ディスプレイ表示
         }
         if( strstr(webdata, "LINE_TRACE") != NULL ) {
+            click_log=true;
             //*-*-*-5("+++++++++++++++++LINET RACE+++++++++++++++++++++");
             //*-*-*-5("mode = LINE_TRACE\r\n");
             if(trace_thread->get_state() == Thread::Deleted) {