
linetrace
Dependencies: RemoteIR TextLCD
Revision 50:8843bee40df5, committed 2020-09-01
- Comitter:
- mori2020
- Date:
- Tue Sep 01 05:38:46 2020 +0000
- Parent:
- 49:178dcafb4f0e
- Child:
- 51:2d35f207d217
- Commit message:
- komennto kehita
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Sep 01 01:43:17 2020 +0000 +++ b/main.cpp Tue Sep 01 05:38:46 2020 +0000 @@ -216,14 +216,14 @@ } switch(code){ case 0x40bf27d8: // クイック - //pc.printf("mode = SPEED\r\n"); + ////*-*-*-5("mode = SPEED\r\n"); mode = SPEED; // スピードモード changeSpeed(); // 速度変更 display(); // ディスプレイ表示 mode = beforeMode; // 現在のモードに前回のモードを設定 break; case 0x40be34cb: // レグザリンク - //pc.printf("mode = LINE_TRACE\r\n"); + ////*-*-*-5("mode = LINE_TRACE\r\n"); if(trace_thread->get_state() == Thread::Deleted){ delete trace_thread; trace_thread = new Thread(trace); @@ -233,7 +233,7 @@ display(); // ディスプレイ表示 break; case 0x40bf6e91: // 番組表 - //pc.printf("mode = AVOIDANCE\r\n"); + ////*-*-*-5("mode = AVOIDANCE\r\n"); if(avoi_thread->get_state() == Thread::Deleted){ delete avoi_thread; avoi_thread = new Thread(avoidance); @@ -245,31 +245,31 @@ display(); // ディスプレイ表示 break; case 0x40bf3ec1: // ↑ - //pc.printf("mode = ADVANCE\r\n"); + ////*-*-*-5("mode = ADVANCE\r\n"); mode = ADVANCE; // 前進モード run = ADVANCE; // 前進 display(); // ディスプレイ表示 break; case 0x40bf3fc0: // ↓ - //pc.printf("mode = BACK\r\n"); + ////*-*-*-5("mode = BACK\r\n"); mode = BACK; // 後退モード run = BACK; // 後退 display(); // ディスプレイ表示 break; case 0x40bf5fa0: // ← - //pc.printf("mode = LEFT\r\n"); + ////*-*-*-5("mode = LEFT\r\n"); mode = LEFT; // 左折モード run = LEFT; // 左折 display(); // ディスプレイ表示 break; case 0x40bf5ba4: // → - //pc.printf("mode = RIGHT\r\n"); + ////*-*-*-5("mode = RIGHT\r\n"); mode = RIGHT; // 右折モード run = RIGHT; // 右折 display(); // ディスプレイ表示 break; case 0x40bf3dc2: // 決定 - //pc.printf("mode = STOP\r\n"); + ////*-*-*-5("mode = STOP\r\n"); mode = STOP; // 停止モード run = STOP; // 停止 display(); // ディスプレイ表示 @@ -361,7 +361,7 @@ int sensor3 = ss3; int sensor4 = ss4; int sensor5 = ss5; - //pc.printf("%d %d %d %d %d \r\n",sensor1,sensor2,sensor3,sensor4,sensor5); + ////*-*-*-5("%d %d %d %d %d \r\n",sensor1,sensor2,sensor3,sensor4,sensor5); int sensD = 0; /* センサー値の決定 */ @@ -421,7 +421,7 @@ int i; while(1){ watchsurrounding3(); -// pc.printf("%d %d %d %d %d \r\n",SL,SLD,SC,SRD,SR); +// //*-*-*-5("%d %d %d %d %d \r\n",SL,SLD,SC,SRD,SR); if(flag_a == 0){ // 障害物がない場合 run = ADVANCE; // 前進 }else{ // 障害物がある場合 @@ -722,7 +722,7 @@ /* バッテリー残量更新関数 */ void bChange(){ - //pc.printf(" bChange1\r\n"); + ////*-*-*-5(" bChange1\r\n"); b = (int)(((battery.read() * 3.3 - MIN_V)/0.67)*10+0.5)*10; if(b <= 0){ // バッテリー残量0%なら全ての機能停止 b = 0; @@ -752,14 +752,14 @@ // Serial Interrupt read ESP data void callback() { - //pc.printf("\n\r------------ callback is being called --------------\n\r"); + ////*-*-*-5("\n\r------------ callback is being called --------------\n\r"); led3=1; while (esp.readable()) { webbuff[ount] = esp.getc(); ount++; } if(strlen(webbuff)>bufflen) { -// pc.printf("\f\n\r------------ webbuff over bufflen --------------\n\r"); +// //*-*-*-5("\f\n\r------------ webbuff over bufflen --------------\n\r"); DataRX=1; led3=0; } @@ -767,7 +767,7 @@ void wifi(/*void const *argument*/) { - pc.printf("\f\n\r------------ ESP8266 Hardware Reset psq --------------\n\r"); + //*-*-*-5("\f\n\r------------ ESP8266 Hardware Reset psq --------------\n\r"); ThisThread::sleep_for(100); led1=1,led2=0,led3=0; timeout=6000; @@ -778,25 +778,25 @@ while(1) { if(DataRX==1) { - pc.printf("\f\n\r------------ main while > if --------------\n\r"); + //*-*-*-5("\f\n\r------------ main while > if --------------\n\r"); click_flag = 1; ReadWebData(); - pc.printf("\f\n\r------------ click_flag=%d --------------\n\r",click_flag); + //*-*-*-5("\f\n\r------------ click_flag=%d --------------\n\r",click_flag); //if ((servreq == 1 && weberror == 0) && click_flag == 1) { if (servreq == 1 && weberror == 0) { - pc.printf("\f\n\r------------ befor send page --------------\n\r"); + //*-*-*-5("\f\n\r------------ befor send page --------------\n\r"); sendpage(); } - pc.printf("\f\n\r------------ send_check begin --------------\n\r"); + //*-*-*-5("\f\n\r------------ send_check begin --------------\n\r"); //sendcheck(); - pc.printf("\f\n\r------------ ssend_check end--------------\n\r"); + //*-*-*-5("\f\n\r------------ ssend_check end--------------\n\r"); esp.attach(&callback); - pc.printf(" IPD Data:\r\n\n Link ID = %d,\r\n IPD Header Length = %d \r\n IPD Type = %s\r\n", linkID, ipdLen, type); - pc.printf("\n\n HTTP Packet: \n\n%s\n", webdata); - pc.printf(" Web Characters sent : %d\n\n", bufl); - pc.printf(" -------------------------------------\n\n"); + //*-*-*-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); + //*-*-*-5(" Web Characters sent : %d\n\n", bufl); + //*-*-*-5(" -------------------------------------\n\n"); servreq=0; } ThisThread::sleep_for(100); @@ -821,139 +821,139 @@ strcat(webbuff, "</font>"); } strcat(webbuff, "%</strong>"); - strcat(webbuff, "<button id=\"reloadbtn\" type=\"button\" class=\"load\" onclick=\"rel()\">RELOAD</button>"); + strcat(webbuff, "<button id=\"reloadbtn\" type=\"button\" class=\"load\" onclick=\"location.reload()\">RELOAD</button>"); strcat(webbuff, "</td></p>"); strcat(webbuff, "<br>"); strcat(webbuff, "<table><tr><td></td><td>"); switch(mode) { //ブラウザ更新時の現在の車の状態からボタンの点灯判定 case ADVANCE: //前進 - strcat(webbuff, "<button id='gobtn' type='button' class=\"light\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); + strcat(webbuff, "<button id='gobtn' type='button' class=\"light\" value=\"GO\" onClick='send_mes(this.value)'>GO"); strcat(webbuff, "</button></td><td></td></tr><tr><td>"); - strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); + strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.value)' >LEFT"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); + strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.value)' >STOP"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); + strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.value)' >RIGHT"); strcat(webbuff, "</button></td></tr><td></td><td>"); - strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); + strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.value)' >BACK"); strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); strcat(webbuff, "<strong>Mode</strong>"); - strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); + strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.value)' >"); strcat(webbuff, "AVOIDANCE</button></td><td>"); - strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); + strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.value)' >LINE_TRACE"); break; case LEFT: //左折 - strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); + strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.value)'>GO"); strcat(webbuff, "</button></td><td></td></tr><tr><td>"); - strcat(webbuff, "<button id='leftbtn' type='button' class=\"light\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); + strcat(webbuff, "<button id='leftbtn' type='button' class=\"light\" value=\"LEFT\" onClick='send_mes(this.value)' >LEFT"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); + strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.value)' >STOP"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); + strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.value)' >RIGHT"); strcat(webbuff, "</button></td></tr><td></td><td>"); - strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); + strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.value)' >BACK"); strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); strcat(webbuff, "<strong>Mode</strong>"); - strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); + strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.value)' >"); strcat(webbuff, "AVOIDANCE</button></td><td>"); - strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); + strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.value)' >LINE_TRACE"); break; case STOP: //停止 - strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); + strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.value)'>GO"); strcat(webbuff, "</button></td><td></td></tr><tr><td>"); - strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); + strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.value)' >LEFT"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='stopbtn' type='button' class=\"light\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); + strcat(webbuff, "<button id='stopbtn' type='button' class=\"light\" value=\"STOP\" onClick='send_mes(this.value)' >STOP"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); + strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.value)' >RIGHT"); strcat(webbuff, "</button></td></tr><td></td><td>"); - strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); + strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.value)' >BACK"); strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); strcat(webbuff, "<strong>Mode</strong>"); - strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); + strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.value)' >"); strcat(webbuff, "AVOIDANCE</button></td><td>"); - strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); + strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.value)' >LINE_TRACE"); break; case RIGHT: //右折 - strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); + strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.value)'>GO"); strcat(webbuff, "</button></td><td></td></tr><tr><td>"); - strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); + strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.value)' >LEFT"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); + strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.value)' >STOP"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='rightbtn' type='button' class=\"light\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); + strcat(webbuff, "<button id='rightbtn' type='button' class=\"light\" value=\"RIGHT\" onClick='send_mes(this.value)' >RIGHT"); strcat(webbuff, "</button></td></tr><td></td><td>"); - strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); + strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.value)' >BACK"); strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); strcat(webbuff, "<strong>Mode</strong>"); - strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); + strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.value)' >"); strcat(webbuff, "AVOIDANCE</button></td><td>"); - strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); + strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.value)' >LINE_TRACE"); break; case BACK: //後進 - strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); + strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.value)'>GO"); strcat(webbuff, "</button></td><td></td></tr><tr><td>"); - strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); + strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.value)' >LEFT"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); + strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.value)' >STOP"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); + strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.value)' >RIGHT"); strcat(webbuff, "</button></td></tr><td></td><td>"); - strcat(webbuff, "<button id='backbtn' type='button' class=\"light\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); + strcat(webbuff, "<button id='backbtn' type='button' class=\"light\" value=\"BACK\" onClick='send_mes(this.value)' >BACK"); strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr><td>"); strcat(webbuff, "<strong>Mode</strong>"); - strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); + strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.value)' >"); strcat(webbuff, "AVOIDANCE</button></td><td>"); - strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); + strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.value)' >LINE_TRACE"); break; case AVOIDANCE: //障害物回避 - strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); + strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.value)'>GO"); strcat(webbuff, "</button></td><td></td></tr><tr><td>"); - strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); + strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.value)' >LEFT"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); + strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.value)' >STOP"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); + strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.value)' >RIGHT"); strcat(webbuff, "</button></td></tr><td></td><td>"); - strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); + strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.value)' >BACK"); strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); strcat(webbuff, "<strong>Mode</strong>"); - strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"light\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); + strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"light\" value=\"AVOIDANCE\" onClick='send_mes(this.value)' >"); strcat(webbuff, "AVOIDANCE</button></td><td>"); - strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); + strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.value)' >LINE_TRACE"); break; case LINE_TRACE: //ライントレース - strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); + strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.value)'>GO"); strcat(webbuff, "</button></td><td></td></tr><tr><td>"); - strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); + strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.value)' >LEFT"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); + strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.value)' >STOP"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); + strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.value)' >RIGHT"); strcat(webbuff, "</button></td></tr><td></td><td>"); - strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); + strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.value)' >BACK"); strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); strcat(webbuff, "<strong>Mode</strong>"); - strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); + strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.value)' >"); strcat(webbuff, "AVOIDANCE</button></td><td>"); - strcat(webbuff, "<button id='tracebtn' type='button' class=\"light\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); + strcat(webbuff, "<button id='tracebtn' type='button' class=\"light\" value=\"LINE_TRACE\" onClick='send_mes(this.value)' >LINE_TRACE"); break; default: //その他 - strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,this.value)'>GO"); + strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.value)'>GO"); strcat(webbuff, "</button></td><td></td></tr><tr><td>"); - strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT"); + strcat(webbuff, "<button id='leftbtn' type='button' class=\"noselect\" value=\"LEFT\" onClick='send_mes(this.value)' >LEFT"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP"); + strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.value)' >STOP"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT"); + strcat(webbuff, "<button id='rightbtn' type='button' class=\"noselect\" value=\"RIGHT\" onClick='send_mes(this.value)' >RIGHT"); strcat(webbuff, "</button></td></tr><td></td><td>"); - strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK"); + strcat(webbuff, "<button id='backbtn' type='button' class=\"noselect\" value=\"BACK\" onClick='send_mes(this.value)' >BACK"); strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>"); strcat(webbuff, "<strong>Mode</strong>"); - strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.id,this.value)' >"); + strcat(webbuff, "<table><tr><td><button id='avoidbtn' type='button' class=\"noselect\" value=\"AVOIDANCE\" onClick='send_mes(this.value)' >"); strcat(webbuff, "AVOIDANCE</button></td><td>"); - strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.id,this.value)' >LINE_TRACE"); + strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE_TRACE\" onClick='send_mes(this.value)' >LINE_TRACE"); break; } strcat(webbuff, "</button></td></tr></table>"); @@ -962,32 +962,32 @@ //ready示速度だけ点灯 switch (flag_sp) { //現在の速度のボタン表示 case 0: //ノーマル - strcat(webbuff, "<button id='sp1btn' type='button' class=\"light\" value=\"Normal\" onClick='send_mes_spe(this.id,this.value)' >Normal"); + strcat(webbuff, "<button id='sp1btn' type='button' class=\"light\" value=\"Normal\" onClick='send_mes_spe(this.value)' >Normal"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='sp2btn' type='button' class=\"noselect\" value=\"Fast\" onClick='send_mes_spe(this.id,this.value)' >Fast"); + strcat(webbuff, "<button id='sp2btn' type='button' class=\"noselect\" value=\"Fast\" onClick='send_mes_spe(this.value)' >Fast"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='sp3btn' type='button' class=\"noselect\" value=\"VeryFast\" onClick='send_mes_spe(this.id,this.value)' >VeryFast"); + strcat(webbuff, "<button id='sp3btn' type='button' class=\"noselect\" value=\"VeryFast\" onClick='send_mes_spe(this.value)' >VeryFast"); break; case 1: //ファスト - strcat(webbuff, "<button id='sp1btn' type='button' class=\"noselect\" value=\"Normal\" onClick='send_mes_spe(this.id,this.value)' >Normal"); + strcat(webbuff, "<button id='sp1btn' type='button' class=\"noselect\" value=\"Normal\" onClick='send_mes_spe(this.value)' >Normal"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='sp2btn' type='button' class=\"light\" value=\"Fast\" onClick='send_mes_spe(this.id,this.value)' >Fast"); + strcat(webbuff, "<button id='sp2btn' type='button' class=\"light\" value=\"Fast\" onClick='send_mes_spe(this.value)' >Fast"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='sp3btn' type='button' class=\"noselect\" value=\"VeryFast\" onClick='send_mes_spe(this.id,this.value)' >VeryFast"); + strcat(webbuff, "<button id='sp3btn' type='button' class=\"noselect\" value=\"VeryFast\" onClick='send_mes_spe(this.value)' >VeryFast"); break; case 2: //ベリーファスト - strcat(webbuff, "<button id='sp1btn' type='button' class=\"noselect\" value=\"Normal\" onClick='send_mes_spe(this.id,this.value)' >Normal"); + strcat(webbuff, "<button id='sp1btn' type='button' class=\"noselect\" value=\"Normal\" onClick='send_mes_spe(this.value)' >Normal"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='sp2btn' type='button' class=\"noselect\" value=\"Fast\" onClick='send_mes_spe(this.id,this.value)' >Fast"); + strcat(webbuff, "<button id='sp2btn' type='button' class=\"noselect\" value=\"Fast\" onClick='send_mes_spe(this.value)' >Fast"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='sp3btn' type='button' class=\"light\" value=\"VeryFast\" onClick='send_mes_spe(this.id,this.value)' >VeryFast"); + strcat(webbuff, "<button id='sp3btn' type='button' class=\"light\" value=\"VeryFast\" onClick='send_mes_spe(this.value)' >VeryFast"); break; default: //その他 - strcat(webbuff, "<button id='sp1btn' type='button' class=\"noselect\" value=\"Normal\" onClick='send_mes_spe(this.id,this.value)' >Normal"); + strcat(webbuff, "<button id='sp1btn' type='button' class=\"noselect\" value=\"Normal\" onClick='send_mes_spe(this.value)' >Normal"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='sp2btn' type='button' class=\"noselect\" value=\"Fast\" onClick='send_mes_spe(this.id,this.value)' >Fast"); + strcat(webbuff, "<button id='sp2btn' type='button' class=\"noselect\" value=\"Fast\" onClick='send_mes_spe(this.value)' >Fast"); strcat(webbuff, "</button></td><td>"); - strcat(webbuff, "<button id='sp3btn' type='button' class=\"noselect\" value=\"VeryFast\" onClick='send_mes_spe(this.id,this.value)' >VeryFast"); + strcat(webbuff, "<button id='sp3btn' type='button' class=\"noselect\" value=\"VeryFast\" onClick='send_mes_spe(this.value)' >VeryFast"); break; } strcat(webbuff, "</button></td></tr></table>"); @@ -998,10 +998,6 @@ strcat(webbuff, "<script language=\"javascript\" type=\"text/javascript\">"); //機能 - strcat(webbuff, "function rel(){"); - strcat(webbuff, "location.reload();"); - strcat(webbuff, "}"); - strcat(webbuff, "var button_9 = document.getElementsByTagName(\"button\");"); //ボタン入力時それぞれの関数から呼び出されサーバーとの通信を行う @@ -1012,14 +1008,14 @@ strcat(webbuff, "xhr.onreadystatechange = function(){"); //strcat(webbuff, "if(this.readyState == 4 && this.status == 200){"); strcat(webbuff, "if(this.readyState == 4){"); - strcat(webbuff, "for(var m=0;m<10;m++){button_9[m].disabled=false;}"); + strcat(webbuff, "for(var m=0;m<11;m++){button_9[m].disabled=false;}"); strcat(webbuff, "}"); strcat(webbuff, "};"); strcat(webbuff, "xhr.send(\"\");"); strcat(webbuff, "}"); -//mode変更ボタン入力時動作 - strcat(webbuff, "function send_mes(btnmes,btnval){"); //mode変更ボタン入力時の点灯消灯判定 +//mode変更ボタン入力時動作 //sendmes + strcat(webbuff, "function send_mes(btnval){"); //mode変更ボタン入力時の点灯消灯判定 strcat(webbuff, "console.log(btnval);"); strcat(webbuff, "var url = \"http://\" + window.location.hostname + \"/cargo?a=\" + btnval;"); strcat(webbuff, "htmlacs(url);"); @@ -1034,7 +1030,7 @@ strcat(webbuff, "}"); strcat(webbuff, "}"); - strcat(webbuff, "function send_mes_spe(btnmes,btnval){"); //speed変更ボタン入力時の点灯消灯判定 + strcat(webbuff, "function send_mes_spe(btnval){"); //speed変更ボタン入力時の点灯消灯判定 strcat(webbuff, "var url = \"http://\" + window.location.hostname + \"/cargo?a=\" + btnval;"); strcat(webbuff, "htmlacs(url);"); strcat(webbuff, "console.log(url);"); @@ -1059,14 +1055,14 @@ getcount=40; SendCMD(); getreply(); - pc.printf(replybuff); - //pc.printf("\n++++++++++ AT+CIPSENDBUF=%d,%d+++++++++\r\n", linkID, (bufl>2048?2048:bufl)); + //*-*-*-5(replybuff); + ////*-*-*-5("\n++++++++++ AT+CIPSENDBUF=%d,%d+++++++++\r\n", linkID, (bufl>2048?2048:bufl)); - pc.printf("\n++++++++++ bufl is %d ++++++++++\r\n",bufl); + //*-*-*-5("\n++++++++++ bufl is %d ++++++++++\r\n",bufl); //pastthrough mode SendWEB(); // send web page - pc.printf("\n++++++++++ webbuff clear ++++++++++\r\n"); + //*-*-*-5("\n++++++++++ webbuff clear ++++++++++\r\n"); memset(webbuff, '\0', sizeof(webbuff)); sendcheck(); @@ -1086,20 +1082,20 @@ //wait_ms(10); ThisThread::sleep_for(100); sprintf(cmdbuff,"AT+CIPSENDBUF=%d,%d\r\n", linkID, (bufl-2048)>2048?2048:(bufl-2048)); // send IPD link channel and buffer character length. - //pc.printf("\r\n++++++++++ AT+CIPSENDBUF=%d,%d ++++++++++\r\n", linkID, (bufl-2048)>2048?2048:(bufl-2048)); + ////*-*-*-5("\r\n++++++++++ AT+CIPSENDBUF=%d,%d ++++++++++\r\n", linkID, (bufl-2048)>2048?2048:(bufl-2048)); timeout=600; getcount=50; SendCMD(); getreply(); - //pc.printf(replybuff); - //pc.printf("\r\n+++++++++++++++++++\r\n"); + ////*-*-*-5(replybuff); + ////*-*-*-5("\r\n+++++++++++++++++++\r\n"); } //**** i++; - //pc.printf("%c",webbuff[i]); + ////*-*-*-5("%c",webbuff[i]); } } - pc.printf("\n++++++++++ send web i= %dinfo ++++++++++\r\n",i); + //*-*-*-5("\n++++++++++ send web i= %dinfo ++++++++++\r\n",i); } @@ -1125,18 +1121,18 @@ getcount=10; SendCMD(); getreply(); - pc.printf(replybuff); + //*-*-*-5(replybuff); sprintf(cmdbuff,"AT+CIPSERVER=1,%d\r\n", port); timeout=500; getcount=10; SendCMD(); getreply(); - pc.printf(replybuff); + //*-*-*-5(replybuff); } else { sprintf(cmdbuff, "AT+CIPCLOSE=%s\r\n",channel); // close current connection SendCMD(); getreply(); - pc.printf(replybuff); + //*-*-*-5(replybuff); } time2.reset(); } @@ -1144,7 +1140,7 @@ // Reads and processes GET and POST web data void ReadWebData() { - pc.printf("+++++++++++++++++Read Web Data+++++++++++++++++++++\r\n"); + //*-*-*-5("+++++++++++++++++Read Web Data+++++++++++++++++++++\r\n"); ThisThread::sleep_for(200); esp.attach(NULL); ount=0; @@ -1157,23 +1153,23 @@ weberror=0; int numMatched = sscanf(webdata,"+IPD,%d,%d:%s", &linkID, &ipdLen, type); //int i=0; - pc.printf("+++++++++++++++++succed rec begin+++++++++++++++++++++\r\n"); - pc.printf("%s",webdata); - pc.printf("+++++++++++++++++succed rec end+++++++++++++++++++++\r\n"); + //*-*-*-5("+++++++++++++++++succed rec begin+++++++++++++++++++++\r\n"); + //*-*-*-5("%s",webdata); + //*-*-*-5("+++++++++++++++++succed rec end+++++++++++++++++++++\r\n"); if( strstr(webdata, "Normal") != NULL ) { - pc.printf("++++++++++++++++++Normal++++++++++++++++++++"); + //*-*-*-5("++++++++++++++++++Normal++++++++++++++++++++"); mode = SPEED; // スピードモード flag_sp = 0; display(); // ディスプレイ表示 mode = beforeMode; // 現在のモードに前回のモードを設定 }else if( strstr(webdata, "VeryFast") != NULL ) { - pc.printf("+++++++++++++++++++VeryFast+++++++++++++++++++"); + //*-*-*-5("+++++++++++++++++++VeryFast+++++++++++++++++++"); mode = SPEED; // スピードモード flag_sp = 2; display(); // ディスプレイ表示 mode = beforeMode; // 現在のモードに前回のモードを設定 }else if( strstr(webdata, "Fast") != NULL ) { - pc.printf("++++++++++++++++++++Fast++++++++++++++++++"); + //*-*-*-5("++++++++++++++++++++Fast++++++++++++++++++"); mode = SPEED; // スピードモード flag_sp = 1; display(); // ディスプレイ表示 @@ -1182,7 +1178,7 @@ beforeMode = mode; } if( strstr(webdata, "GO") != NULL ) { - pc.printf("+++++++++++++++++前進+++++++++++++++++++++\r\n"); + //*-*-*-5("+++++++++++++++++前進+++++++++++++++++++++\r\n"); //delete avoi_thread; //障害物回避スレッド停止 //delete trace_thread; //ライントレーススレッド停止 run = ADVANCE; // 前進 @@ -1191,7 +1187,7 @@ } if( strstr(webdata, "LEFT") != NULL ) { - pc.printf("+++++++++++++++++左折+++++++++++++++++++++\r\n"); + //*-*-*-5("+++++++++++++++++左折+++++++++++++++++++++\r\n"); //delete avoi_thread; //障害物回避スレッド停止 //delete trace_thread; //ライントレーススレッド停止 run = LEFT; // 左折 @@ -1200,7 +1196,7 @@ } if( strstr(webdata, "STOP") != NULL ) { - pc.printf("+++++++++++++++++停止+++++++++++++++++++++\r\n"); + //*-*-*-5("+++++++++++++++++停止+++++++++++++++++++++\r\n"); //delete avoi_thread; //障害物回避スレッド停止 //delete trace_thread; //ライントレーススレッド停止 run = STOP; // 停止 @@ -1209,7 +1205,7 @@ } if( strstr(webdata, "RIGHT") != NULL ) { - pc.printf("+++++++++++++++++右折+++++++++++++++++++++\r\n"); + //*-*-*-5("+++++++++++++++++右折+++++++++++++++++++++\r\n"); //delete avoi_thread; //障害物回避スレッド停止 //delete trace_thread; //ライントレーススレッド停止 run = RIGHT; // 右折 @@ -1218,17 +1214,17 @@ } if( strstr(webdata, "BACK") != NULL ) { - pc.printf("+++++++++++++++++後進+++++++++++++++++++++\r\n"); + //*-*-*-5("+++++++++++++++++後進+++++++++++++++++++++\r\n"); //delete avoi_thread; //障害物回避スレッド停止 //delete trace_thread; //ライントレーススレッド停止 run = BACK; // 後進 mode = BACK; // モード変更 display(); // ディスプレイ表示 } - pc.printf("+++++++++++++++++succed+++++++++++++++++++++"); + //*-*-*-5("+++++++++++++++++succed+++++++++++++++++++++"); if( strstr(webdata, "AVOIDANCE") != NULL ) { - pc.printf("+++++++++++++++++AVOIDANCE+++++++++++++++++++++"); + //*-*-*-5("+++++++++++++++++AVOIDANCE+++++++++++++++++++++"); if(avoi_thread->get_state() == Thread::Deleted) { delete avoi_thread; //障害物回避スレッド停止 avoi_thread = new Thread(avoidance); @@ -1239,8 +1235,8 @@ display(); // ディスプレイ表示 } if( strstr(webdata, "LINE_TRACE") != NULL ) { - pc.printf("+++++++++++++++++LINET RACE+++++++++++++++++++++"); - pc.printf("mode = LINE_TRACE\r\n"); + //*-*-*-5("+++++++++++++++++LINET RACE+++++++++++++++++++++"); + //*-*-*-5("mode = LINE_TRACE\r\n"); if(trace_thread->get_state() == Thread::Deleted) { delete trace_thread; //ライントレーススレッド停止 trace_thread = new Thread(trace); @@ -1274,37 +1270,37 @@ // Starts and restarts webserver if errors detected. void startserver() { - pc.printf("++++++++++ Resetting ESP ++++++++++\r\n"); + //*-*-*-5("++++++++++ Resetting ESP ++++++++++\r\n"); strcpy(cmdbuff,"AT+RST\r\n"); timeout=8000; getcount=1000; SendCMD(); getreply(); - pc.printf(replybuff); - pc.printf("%d",ount); + //*-*-*-5(replybuff); + //*-*-*-5("%d",ount); if (strstr(replybuff, "OK") != NULL) { - pc.printf("\n++++++++++ Starting Server ++++++++++\r\n"); + //*-*-*-5("\n++++++++++ Starting Server ++++++++++\r\n"); strcpy(cmdbuff, "AT+CIPMUX=1\r\n"); // set multiple connections. timeout=500; getcount=20; SendCMD(); getreply(); - pc.printf(replybuff); + //*-*-*-5(replybuff); sprintf(cmdbuff,"AT+CIPSERVER=1,%d\r\n", port); timeout=500; getcount=20; SendCMD(); getreply(); - pc.printf(replybuff); + //*-*-*-5(replybuff); ThisThread::sleep_for(500); sprintf(cmdbuff,"AT+CIPSTO=%d\r\n",SERVtimeout); timeout=500; getcount=50; SendCMD(); getreply(); - pc.printf(replybuff); + //*-*-*-5(replybuff); ThisThread::sleep_for(5000); - pc.printf("\n Getting Server IP \r\n"); + //*-*-*-5("\n Getting Server IP \r\n"); strcpy(cmdbuff, "AT+CIFSR\r\n"); timeout=2500; getcount=200; @@ -1315,21 +1311,21 @@ weberror=1; // wait for valid IP } } - pc.printf("\n Enter WEB address (IP) found below in your browser \r\n\n"); - pc.printf("\n The MAC address is also shown below,if it is needed \r\n\n"); + //*-*-*-5("\n Enter WEB address (IP) found below in your browser \r\n\n"); + //*-*-*-5("\n The MAC address is also shown below,if it is needed \r\n\n"); replybuff[strlen(replybuff)-1] = '\0'; //char* IP = replybuff + 5; sprintf(webdata,"%s", replybuff); - pc.printf(webdata); + //*-*-*-5(webdata); led2=1; bufflen=200; //bufflen=100; ount=0; - pc.printf("\n\n++++++++++ Ready ++++++++++\r\n\n"); + //*-*-*-5("\n\n++++++++++ Ready ++++++++++\r\n\n"); setup(); esp.attach(&callback); } else { - pc.printf("\n++++++++++ ESP8266 error, check power/connections ++++++++++\r\n"); + //*-*-*-5("\n++++++++++ ESP8266 error, check power/connections ++++++++++\r\n"); led1=1; led2=1; led3=1; @@ -1345,6 +1341,7 @@ time2.reset(); time2.start(); } + // ESP Command data send void SendCMD() {