Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: RemoteIR TextLCD
Diff: main.cpp
- Revision:
- 50:ee78382fd399
- Parent:
- 49:7224132f4b0e
- Child:
- 51:1baf4407f384
--- a/main.cpp Wed Sep 02 05:35:17 2020 +0000
+++ b/main.cpp Wed Sep 02 06:14:47 2020 +0000
@@ -81,7 +81,9 @@
AVOIDANCE, // 7:障害物回避
SPEED, // 8:スピード制御
LT_R, // 9:低速右折(ライントレース時)
- LT_L // 10:低速左折(ライントレース時)
+ LT_L, // 10:低速左折(ライントレース時)
+ ARIGHT,
+ ALEFT,
};
/* ピン配置 */
@@ -206,7 +208,6 @@
void wifi(/*void const *argument*/);
Thread *deco_thread; // decodeIRをスレッド化 :+3
Thread *wifi_thread;
-//wifi_thread(wifi,NULL,osPriorityHigh); // wifiをスレッド化
Thread *motor_thread; // motorをスレッド化 :+2
RtosTimer bTimer(lcdBacklight, osTimerPeriodic); // lcdBacklightをタイマー割り込みで設定
Thread *avoi_thread; // avoidanceをスレッド化:+2
@@ -222,7 +223,7 @@
deco_thread -> set_priority(osPriorityRealtime);
motor_thread = new Thread(motor);
motor_thread -> set_priority(osPriorityHigh);
-// wifi_thread -> set_priority(osPriorityRealtime);
+ wifi_thread -> set_priority(osPriorityRealtime);
display();
}
@@ -329,29 +330,29 @@
/* 前進 */
case ADVANCE:
motorR1 = motorSpeedR1[flag_sp]; // 右前進モーターON
- motorR2 = LOW; // 右後退モーターOFF
+ motorR2 = LOW; // 右後退モーターOFF
motorL1 = motorSpeedL1[flag_sp]; // 左前進モーターON
- motorL2 = LOW; // 左後退モーターOFF
+ motorL2 = LOW; // 左後退モーターOFF
break;
/* 右折 */
case RIGHT:
- motorR1 = LOW; // 右前進モーターOFF
+ motorR1 = LOW; // 右前進モーターOFF
motorR2 = motorSpeedR2[flag_sp]; // 右後退モーターON
motorL1 = motorSpeedL1[flag_sp]; // 左前進モーターON
- motorL2 = LOW; // 左後退モーターOFF
+ motorL2 = LOW; // 左後退モーターOFF
break;
/* 左折 */
case LEFT:
motorR1 = motorSpeedR1[flag_sp]; // 右前進モーターON
- motorR2 = LOW; // 右後退モーターOFF
- motorL1 = LOW; // 左前進モーターOFF
+ motorR2 = LOW; // 右後退モーターOFF
+ motorL1 = LOW; // 左前進モーターOFF
motorL2 = motorSpeedL2[flag_sp]; // 左後退モーターON
break;
/* 後退 */
case BACK:
- motorR1 = LOW; // 右前進モーターOFF
- motorR2 = motorSpeedR2[flag_sp]; // 右後退モーターON
- motorL1 = LOW; // 左前進モーターOFF
+ motorR1 = LOW; // 右前進モーターOFF
+ motorR2 = motorSpeedR2[flag_sp] + 0.02; // 右後退モーターON
+ motorL1 = LOW; // 左前進モーターOFF
motorL2 = motorSpeedL2[flag_sp]; // 左後退モーターON
break;
/* 停止 */
@@ -361,19 +362,17 @@
motorL1 = LOW; // 左前進モーターOFF
motorL2 = LOW; // 左後退モーターOFF
break;
- /* 低速右折 */
- case LT_R:
- motorR1 = motorSpeedR2[flag_sp]; // 右前進モーターON
- motorR2 = LOW; // 右後退モーターOFF
- motorL1 = motorSpeedL1[flag_sp]; // 左前進モーターON
- motorL2 = LOW; // 左後退モーターOFF
+ case ARIGHT:
+ motorR1 = LOW;
+ motorR2 = 0.38;
+ motorL1 = 0.36;
+ motorL2 = LOW;
break;
- /* 低速左折 */
- case LT_L:
- motorR1 = motorSpeedR1[flag_sp]; // 右前進モーターON
- motorR2 = LOW; // 右後退モーターOFF
- motorL1 = motorSpeedL2[flag_sp]; // 左前進モーターON
- motorL2 = LOW; // 左後退モーターOFF
+ case ALEFT:
+ motorR1 = 0.38;
+ motorR2 = LOW;
+ motorL1 = LOW;
+ motorL2 = 0.36;
break;
}
if(flag_sp > VERYFAST){ // スピード変更フラグが2より大きいなら
@@ -468,229 +467,242 @@
int i;
while(1){
watchsurrounding3();
-// pc.printf("%d %d %d %d %d \r\n",SL,SLD,SC,SRD,SR);
- if(flag_a == 0){ // 障害物がない場合
- run = ADVANCE; // 前進
- }else{ // 障害物がある場合
+ if(flag_a == 0){ // 障害物がない場合
+ run = ADVANCE; // 前進
+// if(SLD < 25){ // 正面15cm以内に障害物が現れた場合
+// run = RIGHT; // 右折
+// ThisThread::sleep_for(100); // 100ms待つ
+// run = STOP; // 停止
+// }else if(SRD < 25){
+// run = LEFT; // 左折
+// ThisThread::sleep_for(100); // 100ms待つ
+// run = STOP; // 停止
+// }
+ }else{ // 障害物がある場合
i = 0;
- if(SC < 15){ // 正面15cm以内に障害物が現れた場合
- servo.pulsewidth_us(1450); // サーボを中央位置に戻す
+ int cnt_kyori;
+ int kyori;
+ if(SC < 15){
+ servo.pulsewidth_us(1425); // サーボを中央位置に戻す
ThisThread::sleep_for(100); // 100ms待つ
- run = BACK; // 後退
- int cnt_kyori=0;
- int kyori = watch();
- while(kyori < limit){ // 正面20cm以内に障害物がある間
- if(kyori==-1){
+ run = STOP;
+ ThisThread::sleep_for(80);
+ run = BACK;
+// switch(flag_sp){
+// case 0:
+// ThisThread::sleep_for(200);
+// break;
+// case 1:
+// ThisThread::sleep_for(150);
+// break;
+// case 2:
+// ThisThread::sleep_for(120);
+// break;
+// default:
+// break;
+// }
+ cnt_kyori = 0;
+ kyori = watch();
+ while(kyori < limit){ // 正面20cm以内に障害物がある間
+ if(kyori == -1){
cnt_kyori++;
- if(cnt_kyori>15){
- cnt_kyori=0;
+ if(cnt_kyori > 15){
+ cnt_kyori = 0;
break;
}
}
kyori = watch();
}
- /*while(i < 30){ // 正面20cm以内に障害物がある間
- if(watch() < limit){
- break;
- }
- i++;
- }
- i = 0;*/
- run = STOP; // 停止
- }
+ run = STOP;
+ }
watchsurrounding5();
if(SC < limit && SLD < limit && SL < limit && SRD < limit && SR < limit){ // 全方向に障害物がある場合
- run = LEFT; // 左折
- while(i < 1){ // 進行方向確認
+ run = ALEFT; // 左折
+ while(i < 20){ // 進行方向確認
if(watch() > limit){
- i++;
+ break;
}else{
- i = 0;
+ i++;
}
}
run = STOP; // 停止
- }else { // 全方向以外
+ }else { // 全方向以外
far = SC; // 正面を最も遠い距離に設定
houkou = 1; // 進行方向を前に設定
- if(far < SLD || far < SL){ // 左または左前がより遠い場合
- if(SL < SLD){ // 左前が左より遠い場合
- far = SLD; // 左前を最も遠い距離に設定
- }else{ // 左が左前より遠い場合
- far = SL; // 左を最も遠い距離に設定
+ if(SC < limit){
+ if(far < SLD || far < SL){ // 左または左前がより遠い場合
+ if(SL < SLD){ // 左前が左より遠い場合
+ far = SLD; // 左前を最も遠い距離に設定
+ }else{ // 左が左前より遠い場合
+ far = SL; // 左を最も遠い距離に設定
+ }
+ houkou = 2; // 進行方向を左に設定
}
- houkou = 2; // 進行方向を左に設定
- }
- if(far < SRD || far < SR){ // 右または右前がより遠い場合
- if(SR < SRD){ // 右前が右より遠い場合
- far = SRD; // 右前を最も遠い距離に設定
- }else{ // 右が右前よりも遠い場合
- far = SR; // 右を最も遠い距離に設定
+ if(far < SRD || far < SR){ // 右または右前がより遠い場合
+ if(SR < SRD){ // 右前が右より遠い場合
+ far = SRD; // 右前を最も遠い距離に設定
+ }else{ // 右が右前よりも遠い場合
+ far = SR; // 右を最も遠い距離に設定
+ }
+ houkou = 3; // 進行方向を右に設定
}
- houkou = 3; // 進行方向を右に設定
}
switch(houkou){ // 進行方向の場合分け
case 1: // 前の場合
run = ADVANCE; // 前進
- ThisThread::sleep_for(500); // 0.5秒待つ
+ switch(flag_sp){
+ case 0:
+ ThisThread::sleep_for(300); // 0.5秒待つ
+ break;
+ case 1:
+ ThisThread::sleep_for(200);
+ break;
+ case 2:
+ ThisThread::sleep_for(100);
+ break;
+ }
break;
- case 2: // 左の場合
- run = LEFT; // 左折
- //int kyori = watch();
- //int kyori_f=0;
- while(i < 20){ // 進行方向確認
- /*if(kyori > (far - 2) || kyori_f == 2){ // 正面の計測距離と最も遠い距離が一致したら(誤差-2cm)
- break; // ループ+
- }else if(kyori==-1){
- kyori_f++;
- }else{
- kyori_f = 0;
- i++;
- }*/
+ case 2: // 左の場合
+ run = ALEFT; // 左折
+ while(i < 15){ // 進行方向確認
if(watch() > (far - 2)){ // 正面の計測距離と最も遠い距離が一致したら(誤差-2cm)
- break; // ループ+
+ break; // ループ+
}else{
i++;
}
}
- run = STOP; // 停止
+ run = ADVANCE; // 停止
break;
- case 3: // 右の場合
- run = RIGHT; // 右折
- //int kyori = watch();
- //int kyori_f=0;
- while(i < 20){ // 進行方向確認
- /*if(kyori > (far - 2) || kyori_f == 2){ // 正面の計測距離と最も遠い距離が一致したら(誤差-2cm)
+ case 3: // 右の場合
+ run = ARIGHT; // 右折
+ while(i < 15){ // 進行方向確認
+ if(watch() > (far - 2)){ // 正面の計測距離と最も遠い距離が一致したら(誤差-2cm)
break; // ループ+
- }else if(kyori==-1){
- kyori_f++;
- }else{
- kyori_f = 0;
- i++;
- }*/
- if(watch() > (far - 2)){ // 正面の計測距離と最も遠い距離が一致したら(誤差-2cm)
- break; // ループ+
}else{
i++;
}
}
- run = STOP; // 停止
+ run = ADVANCE; // 停止
break;
}
}
}
flag_a = 0; // 障害物有無フラグを0にセット
- if(SLD < 29){ // 正面15cm以内に障害物が現れた場合
- run = RIGHT; // 右折
- ThisThread::sleep_for(200); // 100ms待つ
- run = STOP; // 停止
- }else if(SRD < 29){
- run = LEFT; // 左折
- ThisThread::sleep_for(200); // 100ms待つ
- run = STOP; // 停止
- }
- }
-}
-
+ if(SLD < 30 && SRD > 30){ // 正面15cm以内に障害物が現れた場合
+ run = ARIGHT; // 右折
+ ThisThread::sleep_for(110);
+ run = ADVANCE;
+ }else if(SRD < 30 && SLD > 30){
+ run = ALEFT; // 左折
+ ThisThread::sleep_for(110);
+ run = ADVANCE;
+ }
+ }
+}
+
/* 距離計測関数 */
int watch(){
- do{
- trig = 0;
- ThisThread::sleep_for(5); // 5ms待つ
- trig = 1;
- ThisThread::sleep_for(15); // 15ms待つ
- trig = 0;
- timer.start();
- t1=timer.read_ms();
- while(echo.read() == 0 && t1<10){
+ do{
+ do{
+ trig = 0;
+ ThisThread::sleep_for(5); // 5ms待つ
+ trig = 1;
+ ThisThread::sleep_for(15); // 15ms待つ
+ trig = 0;
+ timer.start();
t1=timer.read_ms();
- led1 = 1;
+ while(echo.read() == 0 && t1<10){
+ t1=timer.read_ms();
+ led1 = 1;
+ }
+ timer.stop();
+ timer.reset();
+ }while(t1 >= 10);
+ timer.start(); // 距離計測タイマースタート
+ while(echo.read() == 1){
}
- timer.stop();
+ timer.stop(); // 距離計測タイマーストップ
+ DT = (int)(timer.read_us()*0.01657); // 距離計算
+ if(timer.read_ms() > 1000){
+ DT = -1;
+ break;
+ }
+ }while(DT > 1000);
+ if(DT > 400){
+ DT = 400;
+ }
timer.reset();
- /*if((t1-t2) >= 10){
- run = STOP;*/
- }while(t1 >= 10);
- timer.start(); // 距離計測タイマースタート
- while(echo.read() == 1){
- }
- timer.stop(); // 距離計測タイマーストップ
- DT = (int)(timer.read_us()*0.01657); // 距離計算
- if(DT > 1000){
- DT = -1;
- }else if(DT > 150){ // 検知範囲外なら100cmに設定
- DT = 150;
- }
- timer.reset(); // 距離計測タイマーリセット
- led1 = 0;
- return DT;
+ led1 = 0;
+ return DT;
}
-
+
/* 障害物検知関数 */
void watchsurrounding3(){
- //servo.pulsewidth_us(1450); // サーボを中央位置に戻す
- //ThisThread::sleep_for(200); // 100ms待つ
SC = watch();
if(SC < limit){ // 正面20cm以内に障害物がある場合
- if(SC!=-1){
+ if(SC!=-1){
run = STOP; // 停止
flag_a = 1;
return;
}
}
- servo.pulsewidth_us(1925); // サーボを左に40度回転
+ servo.pulsewidth_us(1927); // サーボを左に40度回転
ThisThread::sleep_for(100); // 250ms待つ
SLD = watch();
- if(SLD < limit){ // 左前20cm以内に障害物がある場合
- run = STOP; // 停止
- flag_a = 1;
- return;
+ if(SLD < 18){ // 左前20cm以内に障害物がある場合
+ run = STOP;
+ ThisThread::sleep_for(90);
+ run = BACK;
+ ThisThread::sleep_for(150);
+ run = ARIGHT;
+ ThisThread::sleep_for(120);
+ return;
}
- servo.pulsewidth_us(1450);
- ThisThread::sleep_for(150);
+ servo.pulsewidth_us(1425);
+ ThisThread::sleep_for(100);
SC = watch();
if(SC < limit){
- if(SC!=-1){
- run = STOP; // 停止
+ if(SC != -1){
+ run = STOP; // 停止
flag_a = 1;
return;
- }
+ }
}
- servo.pulsewidth_us(925); // サーボを右に40度回転
+ servo.pulsewidth_us(923); // サーボを右に40度回転
ThisThread::sleep_for(100); // 250ms待つ
SRD = watch();
- if(SRD < limit){ // 右前20cm以内に障害物がある場合
+ if(SRD < 18){ // 右前20cm以内に障害物がある場合
run = STOP; // 停止
- flag_a = 1;
- return;
+ ThisThread::sleep_for(90);
+ run = BACK;
+ ThisThread::sleep_for(150);
+ run = ALEFT;
+ ThisThread::sleep_for(120);
+ return;
}
- servo.pulsewidth_us(1450); // サーボを中央位置に戻す
+ servo.pulsewidth_us(1425); // サーボを中央位置に戻す
ThisThread::sleep_for(100); // 100ms待つ
- /*if(SC < limit || SLD < limit || SL < limit || SRD < limit || SR < limit){ // 20cm以内に障害物を検知した場合
- flag_a = 1; // 障害物有無フラグに1をセット
- }*/
}
-
+
/* 障害物検知関数 */
void watchsurrounding5(){
- //servo.pulsewidth_us(1450); // サーボを中央位置に戻す
- //ThisThread::sleep_for(200); // 100ms待つ
SC = watch();
- servo.pulsewidth_us(1925); // サーボを左に40度回転
+ servo.pulsewidth_us(1927); // サーボを左に40度回転
ThisThread::sleep_for(100); // 250ms待つ
SLD = watch();
servo.pulsewidth_us(2400); // サーボを左に90度回転
ThisThread::sleep_for(100); // 250ms待つ
SL = watch();
- servo.pulsewidth_us(1450);
+ servo.pulsewidth_us(1425);
ThisThread::sleep_for(250);
SC = watch();
- servo.pulsewidth_us(925); // サーボを右に40度回転
+ servo.pulsewidth_us(923); // サーボを右に40度回転
ThisThread::sleep_for(100); // 250ms待つ
SRD = watch();
servo.pulsewidth_us(500); // サーボを右に90度回転
ThisThread::sleep_for(100); // 250ms待つ
SR = watch();
- servo.pulsewidth_us(1450); // サーボを中央位置に戻す
+ servo.pulsewidth_us(1425); // サーボを中央位置に戻す
ThisThread::sleep_for(250); // 100ms待つ
}
@@ -796,25 +808,27 @@
}
}
}
+
+
// 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;
}
}
-
+
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;
@@ -822,15 +836,28 @@
getreply();
esp.baud(115200); // ESP8266 baudrate. Maximum on KLxx' is 115200, 230400 works on K20 and K22F
startserver();
-
+
while(1) {
if(DataRX==1) {
+ //*-*-*-5("\f\n\r------------ main while > if --------------\n\r");
click_flag = 1;
ReadWebData();
- if (servreq == 1 && weberror == 0) { // ページ表示のリクエストがあったとき
+ //*-*-*-5("\f\n\r------------ click_flag=%d --------------\n\r",click_flag);
+ //if ((servreq == 1 && weberror == 0) && click_flag == 1) {
+ if (servreq == 1 && weberror == 0) {
+ //*-*-*-5("\f\n\r------------ befor send page --------------\n\r");
sendpage();
}
+ //*-*-*-5("\f\n\r------------ send_check begin --------------\n\r");
+
+ //sendcheck();
+ //*-*-*-5("\f\n\r------------ ssend_check end--------------\n\r");
+
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);
+ //*-*-*-5(" Web Characters sent : %d\n\n", bufl);
+ //*-*-*-5(" -------------------------------------\n\n");
servreq=0;
}
ThisThread::sleep_for(100);
@@ -840,145 +867,154 @@
void sendpage()
{
// WEB page data
+
strcpy(webbuff, "<!DOCTYPE html>");
strcat(webbuff, "<html><head><title>RobotCar</title><meta name='viewport' content='width=device-width'/>");
+ //strcat(webbuff, "<meta http-equiv=\"refresh\" content=\"5\"; >");
strcat(webbuff, "<style type=\"text/css\">.noselect{ width:100px;height:60px;}.light{ width:100px;height:60px;background-color:#00ff66;}.load{ width: 50px; height: 30px;font-size:10px}</style>");
strcat(webbuff, "</head><body><center><p><strong>Robot Car Remote Controller");
strcat(webbuff, "</strong></p><td style='vertical-align:top;'><strong>Battery level ");
- strcat(webbuff, "<input type=\"text\" id=\"leftms\" size=4 value=250>%</strong>");
- strcat(webbuff, "<button id=\"reloadbtn\" type=\"button\" class=\"load\" onclick=\"rel()\">RELOAD</button>");
+ if(b > 30) { //残電量表示
+ sprintf(webbuff, "%s%3d", webbuff, b);
+ } else { //30%より下の場合残電量を赤文字
+ strcat(webbuff, "<font color=\"red\">");
+ sprintf(webbuff, "%s%3d", webbuff, b);
+ strcat(webbuff, "</font>");
+ }
+ strcat(webbuff, "%</strong>");
+ 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>");
@@ -987,77 +1023,59 @@
//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>");
+
strcat(webbuff, "</center>");
strcat(webbuff, "</body>");
strcat(webbuff, "</html>");
+
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\");");
+
+//ボタン入力時それぞれの関数から呼び出されサーバーとの通信を行う
strcat(webbuff, "function htmlacs(url) {");
- strcat(webbuff, "var xhr = new XMLHttpRequest();");
- strcat(webbuff, "xhr.open(\"GET\", url);");
- strcat(webbuff, "xhr.send(\"\");");
+ 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, "}");
-//0825
-//0824 battery update auto
- strcat(webbuff, "function battery_update() {");
- strcat(webbuff, "var url1 = \"http://\" + window.location.hostname+ \"/cargo?a=responseBattery\";");
- strcat(webbuff, "var xhr1 = new XMLHttpRequest();");
- strcat(webbuff, "xhr1.open(\"GET\", url1);");
-//0820
- strcat(webbuff, "xhr1.onreadystatechange = function(){");
- strcat(webbuff, "if(this.readyState == 4 && this.status == 200){");
- strcat(webbuff, "var res1 = xhr1.responseText;");
-//color
- strcat(webbuff, "var battery_num=res1;");
- strcat(webbuff, "if(battery_num>0 && battery_num<31){");
- strcat(webbuff, "document.getElementById('leftms').style.color=\"red\";");
- strcat(webbuff, "}");
- strcat(webbuff, "if(battery_num>39 && battery_num<61){");
- strcat(webbuff, "document.getElementById('leftms').style.color=\"orange\";");
- strcat(webbuff, "}");
- strcat(webbuff, "if(battery_num>69 && battery_num<101){");
- strcat(webbuff, "document.getElementById('leftms').style.color=\"blue\";");
- strcat(webbuff, "}");
-//color
- strcat(webbuff, "document.getElementById('leftms').value=res1;}};");
-//0820
- strcat(webbuff, "xhr1.send();");
- strcat(webbuff, "}");
- strcat(webbuff, "setInterval(battery_update,15000);");
-//0824 battery update auto
-//0825
- 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);");
@@ -1071,7 +1089,8 @@
strcat(webbuff, "}");
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);");
@@ -1085,16 +1104,26 @@
strcat(webbuff, "}");
strcat(webbuff, "}");
strcat(webbuff, "</script>");
+
+
// end of WEB page data
bufl = strlen(webbuff); // get total page buffer length
+ //sprintf(cmdbuff,"AT+CIPSEND=%d,%d\r\n", linkID, bufl); // send IPD link channel and buffer character length.
sprintf(cmdbuff,"AT+CIPSENDBUF=%d,%d\r\n", linkID, (bufl>2048?2048:bufl)); // send IPD link channel and buffer character length.
timeout=500;
getcount=40;
SendCMD();
getreply();
+ //*-*-*-5(replybuff);
+ ////*-*-*-5("\n++++++++++ AT+CIPSENDBUF=%d,%d+++++++++\r\n", linkID, (bufl>2048?2048:bufl));
+
+ //*-*-*-5("\n++++++++++ bufl is %d ++++++++++\r\n",bufl);
+
//pastthrough mode
SendWEB(); // send web page
+ //*-*-*-5("\n++++++++++ webbuff clear ++++++++++\r\n");
+
memset(webbuff, '\0', sizeof(webbuff));
sendcheck();
}
@@ -1106,42 +1135,30 @@
if(esp.writeable()) {
while(webbuff[i]!='\0') {
esp.putc(webbuff[i]);
+
//****
//output at command when 2000
if(((i%2047)==0) && (i>0)) {
+ //wait_ms(10);
ThisThread::sleep_for(100);
- sprintf(cmdbuff,"AT+CIPSENDBUF=%d,%d\r\n", linkID, (bufl-2048*(i/2047))>2048?2048:(bufl-2048*(i/2047))); // send IPD link channel and buffer character length.
+ sprintf(cmdbuff,"AT+CIPSENDBUF=%d,%d\r\n", linkID, (bufl-2048)>2048?2048:(bufl-2048)); // send IPD link channel and buffer character length.
+ ////*-*-*-5("\r\n++++++++++ AT+CIPSENDBUF=%d,%d ++++++++++\r\n", linkID, (bufl-2048)>2048?2048:(bufl-2048));
timeout=600;
getcount=50;
SendCMD();
getreply();
+ ////*-*-*-5(replybuff);
+ ////*-*-*-5("\r\n+++++++++++++++++++\r\n");
}
//****
i++;
+ ////*-*-*-5("%c",webbuff[i]);
}
}
+ //*-*-*-5("\n++++++++++ send web i= %dinfo ++++++++++\r\n",i);
}
-void sendpage2()
-{
-// WEB page data
- sprintf(battery_ch,"%d",b);
- strcpy(webbuff, battery_ch);
-// end of WEB page data
- bufl = strlen(webbuff); // get total page buffer length
-
- sprintf(cmdbuff,"AT+CIPSENDBUF=%d,%d\r\n", linkID, (bufl>2048?2048:bufl)); // send IPD link channel and buffer character length.
- timeout=500;
- getcount=40;
- SendCMD();
- getreply();
- //pastthrough mode
- SendWEB(); // send web page
- memset(webbuff, '\0', sizeof(webbuff));
- sendcheck();
-}
-
void sendcheck()
{
weberror=1;
@@ -1150,21 +1167,32 @@
time2.reset();
time2.start();
+ /*
+ while(weberror==1 && time2.read() <5) {
+ getreply();
+ if (strstr(replybuff, "SEND OK") != NULL) {
+ weberror=0; // wait for valid SEND OK
+ }
+ }
+ */
if(weberror==1) { // restart connection
strcpy(cmdbuff, "AT+CIPMUX=1\r\n");
timeout=500;
getcount=10;
SendCMD();
getreply();
+ //*-*-*-5(replybuff);
sprintf(cmdbuff,"AT+CIPSERVER=1,%d\r\n", port);
timeout=500;
getcount=10;
SendCMD();
getreply();
+ //*-*-*-5(replybuff);
} else {
sprintf(cmdbuff, "AT+CIPCLOSE=%s\r\n",channel); // close current connection
SendCMD();
getreply();
+ //*-*-*-5(replybuff);
}
time2.reset();
}
@@ -1172,6 +1200,7 @@
// Reads and processes GET and POST web data
void ReadWebData()
{
+ //*-*-*-5("+++++++++++++++++Read Web Data+++++++++++++++++++++\r\n");
ThisThread::sleep_for(200);
esp.attach(NULL);
ount=0;
@@ -1183,22 +1212,24 @@
strcpy(webdata, webbuff + x);
weberror=0;
int numMatched = sscanf(webdata,"+IPD,%d,%d:%s", &linkID, &ipdLen, type);
- if( strstr(webdata, "responseBattery") != NULL ) {
- click_flag = 0;
- led4=!led4;
- sendpage2();
- }
+ //int i=0;
+ //*-*-*-5("+++++++++++++++++succed rec begin+++++++++++++++++++++\r\n");
+ //*-*-*-5("%s",webdata);
+ //*-*-*-5("+++++++++++++++++succed rec end+++++++++++++++++++++\r\n");
if( strstr(webdata, "Normal") != NULL ) {
+ //*-*-*-5("++++++++++++++++++Normal++++++++++++++++++++");
mode = SPEED; // スピードモード
flag_sp = 0;
display(); // ディスプレイ表示
mode = beforeMode; // 現在のモードに前回のモードを設定
}else if( strstr(webdata, "VeryFast") != NULL ) {
+ //*-*-*-5("+++++++++++++++++++VeryFast+++++++++++++++++++");
mode = SPEED; // スピードモード
flag_sp = 2;
display(); // ディスプレイ表示
mode = beforeMode; // 現在のモードに前回のモードを設定
}else if( strstr(webdata, "Fast") != NULL ) {
+ //*-*-*-5("++++++++++++++++++++Fast++++++++++++++++++");
mode = SPEED; // スピードモード
flag_sp = 1;
display(); // ディスプレイ表示
@@ -1207,6 +1238,7 @@
beforeMode = mode;
}
if( strstr(webdata, "GO") != NULL ) {
+ //*-*-*-5("+++++++++++++++++前進+++++++++++++++++++++\r\n");
//delete avoi_thread; //障害物回避スレッド停止
//delete trace_thread; //ライントレーススレッド停止
run = ADVANCE; // 前進
@@ -1215,6 +1247,7 @@
}
if( strstr(webdata, "LEFT") != NULL ) {
+ //*-*-*-5("+++++++++++++++++左折+++++++++++++++++++++\r\n");
//delete avoi_thread; //障害物回避スレッド停止
//delete trace_thread; //ライントレーススレッド停止
run = LEFT; // 左折
@@ -1223,6 +1256,7 @@
}
if( strstr(webdata, "STOP") != NULL ) {
+ //*-*-*-5("+++++++++++++++++停止+++++++++++++++++++++\r\n");
//delete avoi_thread; //障害物回避スレッド停止
//delete trace_thread; //ライントレーススレッド停止
run = STOP; // 停止
@@ -1231,6 +1265,7 @@
}
if( strstr(webdata, "RIGHT") != NULL ) {
+ //*-*-*-5("+++++++++++++++++右折+++++++++++++++++++++\r\n");
//delete avoi_thread; //障害物回避スレッド停止
//delete trace_thread; //ライントレーススレッド停止
run = RIGHT; // 右折
@@ -1239,14 +1274,17 @@
}
if( strstr(webdata, "BACK") != NULL ) {
+ //*-*-*-5("+++++++++++++++++後進+++++++++++++++++++++\r\n");
//delete avoi_thread; //障害物回避スレッド停止
//delete trace_thread; //ライントレーススレッド停止
run = BACK; // 後進
mode = BACK; // モード変更
display(); // ディスプレイ表示
}
+ //*-*-*-5("+++++++++++++++++succed+++++++++++++++++++++");
if( strstr(webdata, "AVOIDANCE") != NULL ) {
+ //*-*-*-5("+++++++++++++++++AVOIDANCE+++++++++++++++++++++");
if(avoi_thread->get_state() == Thread::Deleted) {
delete avoi_thread; //障害物回避スレッド停止
avoi_thread = new Thread(avoidance);
@@ -1257,6 +1295,8 @@
display(); // ディスプレイ表示
}
if( strstr(webdata, "LINE_TRACE") != NULL ) {
+ //*-*-*-5("+++++++++++++++++LINET RACE+++++++++++++++++++++");
+ //*-*-*-5("mode = LINE_TRACE\r\n");
if(trace_thread->get_state() == Thread::Deleted) {
delete trace_thread; //ライントレーススレッド停止
trace_thread = new Thread(trace);
@@ -1290,37 +1330,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;
@@ -1331,19 +1371,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;
@@ -1359,6 +1401,7 @@
time2.reset();
time2.start();
}
+
// ESP Command data send
void SendCMD()
{
@@ -1383,9 +1426,9 @@
/* mainスレッド */
int main() {
/* 初期設定 */
-// wifi_thread = new Thread(wifi);
-// wifi_thread -> set_priority(osPriorityHigh);
- setup();
+ wifi_thread = new Thread(wifi);
+ wifi_thread -> set_priority(osPriorityHigh);
+// setup();
avoi_thread = new Thread(avoidance);
avoi_thread->terminate();
trace_thread = new Thread(trace);