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
Revision 49:14b3dba5bd56, committed 2020-08-26
- Comitter:
- faker_71
- Date:
- Wed Aug 26 08:29:31 2020 +0000
- Parent:
- 48:7be823ac7eb8
- Commit message:
- 0826
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Aug 25 05:15:48 2020 +0000
+++ b/main.cpp Wed Aug 26 08:29:31 2020 +0000
@@ -37,6 +37,9 @@
/* ピン配置 */
ReceiverIR ir(p5); // リモコン操作
DigitalOut trig(p6); // 超音波センサtrigger
+DigitalOut pred(p16);
+DigitalOut pblue(p19);
+
DigitalIn echo(p7); // 超音波センサecho
DigitalIn ss1(p8); // ライントレースセンサ(左)
DigitalIn ss2(p9); // ライントレースセンサ
@@ -950,8 +953,23 @@
strcat(webbuff, "}");
strcat(webbuff, "function htmlacs(url) {");
+ strcat(webbuff, "clearInterval(si);");
strcat(webbuff, "var xhr = new XMLHttpRequest();");
strcat(webbuff, "xhr.open(\"GET\", url);");
+
+//0826
+ strcat(webbuff, "xhr.onreadystatechange = function(){");
+ strcat(webbuff, "if(this.readyState == 4 && this.status == 200){");
+ strcat(webbuff, "console.log(\"apologize for\");");
+ strcat(webbuff, "var si = setInterval(battery_update,15000);");
+
+ strcat(webbuff, "}");
+ strcat(webbuff, "};");
+
+
+//0826
+
+
strcat(webbuff, "xhr.send(\"\");");
strcat(webbuff, "}");
@@ -990,7 +1008,7 @@
strcat(webbuff, "xhr1.send();");
strcat(webbuff, "}");
-strcat(webbuff, "setInterval(battery_update,15000);");
+strcat(webbuff, "var si = setInterval(battery_update,15000);");
//0824 battery update auto
//0825
@@ -1078,11 +1096,10 @@
pc.printf("\n++++++++++ send web i= %dinfo ++++++++++\r\n",i);
}
-
void sendpage2()
{
// WEB page data
-
+pred=!pred;
//strcpy(webbuff, "<script language=\"javascript\" type=\"text/javascript\">");
//strcat(webbuff, "document.getElementById('leftms').value=\"100\";");
@@ -1114,6 +1131,44 @@
memset(webbuff, '\0', sizeof(webbuff));
sendcheck();
}
+
+
+void sendpage3()
+{
+// WEB page data
+pblue=!pblue;
+//strcpy(webbuff, "<script language=\"javascript\" type=\"text/javascript\">");
+//strcat(webbuff, "document.getElementById('leftms').value=\"100\";");
+
+sprintf(battery_ch,"%d",b);
+//sprintf(battery_ch,"%d",30);
+strcpy(webbuff, battery_ch);
+
+//strcpy(webbuff, "document.getElementById('leftms').value=\"100\";");
+
+//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();
+ pc.printf(replybuff);
+ pc.printf("\n++++++++++ AT+CIPSENDBUF=%d,%d+++++++++\r\n", linkID, (bufl>2048?2048:bufl));
+
+ pc.printf("\n++++++++++ bufl is %d ++++++++++\r\n",bufl);
+
+ //pastthrough mode
+ SendWEB(); // send web page
+ pc.printf("\n++++++++++ webbuff clear ++++++++++\r\n");
+
+ memset(webbuff, '\0', sizeof(webbuff));
+ sendcheck();
+}
+
void sendcheck()
{
@@ -1179,6 +1234,24 @@
pc.printf("\r\n++++++++++++++mode = LEFT++++++++++++++\r\n");
sendpage2();
}
+
+ if( strstr(webdata, "GO") != NULL ) {
+ sendpage3();
+
+ pc.printf("+++++++++++++++++前進+++++++++++++++++++++\r\n");
+ //delete avoi_thread; //障害物回避スレッド停止
+ //delete trace_thread; //ライントレーススレッド停止
+ run = ADVANCE; // 前進
+ mode = ADVANCE; // モード変更
+ display(); // ディスプレイ表示
+ //0826
+ led1=!led1;
+ led2=!led2;
+ led3=!led3;
+ click_flag = 0;
+//0826
+ }
+
if( strstr(webdata, "Normal") != NULL ) {
pc.printf("++++++++++++++++++Normal++++++++++++++++++++");
@@ -1201,15 +1274,24 @@
}else{
beforeMode = mode;
}
+ /*
if( strstr(webdata, "GO") != NULL ) {
+ sendpage3();
+
pc.printf("+++++++++++++++++前進+++++++++++++++++++++\r\n");
//delete avoi_thread; //障害物回避スレッド停止
//delete trace_thread; //ライントレーススレッド停止
run = ADVANCE; // 前進
mode = ADVANCE; // モード変更
display(); // ディスプレイ表示
+ //0826
+ led1=!led1;
+ led2=!led2;
+ led3=!led3;
+ click_flag = 0;
+//0826
}
-
+*/
if( strstr(webdata, "LEFT") != NULL ) {
pc.printf("+++++++++++++++++左折+++++++++++++++++++++\r\n");
//delete avoi_thread; //障害物回避スレッド停止