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: mbed
Revision 9:e458213a7afd, committed 2020-08-03
- Comitter:
- molberry
- Date:
- Mon Aug 03 06:49:33 2020 +0000
- Parent:
- 8:d8e164130860
- Commit message:
- change
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Jul 30 07:11:33 2020 +0000
+++ b/main.cpp Mon Aug 03 06:49:33 2020 +0000
@@ -4,9 +4,9 @@
//#include "DS18B20.h"
Serial pc(USBTX, USBRX);
-Serial esp(p28, p27); // tx, rx
+Serial esp(p13, p14); // tx, rx
//Serial esp(p9, p10); // tx, rx
-
+//Resetpin使用せず
//DS18B20 thermom(A0, DS18B20::RES_12_BIT);
// Standard Mbed LED definitions
@@ -15,22 +15,7 @@
DigitalOut led3(LED3); // (PTD1)
// Digital Out and In pins, can be configured to any suitable pin depending on Platform
-DigitalOut Out1(p6);
-DigitalOut Out2(p7);
-DigitalOut Out3(p8);
-DigitalOut reset(p26);
-
-
-DigitalOut ledR(p17);
-DigitalOut ledG(p16);
-
-DigitalIn In1(p9);
-DigitalIn In2(p10);
-DigitalIn In3(p11);
-
-PwmOut speaker(p21);
-AnalogIn Ain1(p18);
-AnalogIn Ain2(p19);
+AnalogIn Ain1(p18);//battery
Timer t1;
Timer t2;
@@ -59,7 +44,6 @@
//char webdata[4096]; // This may need to be bigger depending on WEB browser used
//char webbuff[4096*4]; // Currently using 1986 characters, Increase this if more web page data added
-
void SendCMD(),getreply(),ReadWebData(),startserver(),sendpage(),SendWEB(),sendcheck(),touchuan();
void gettime(),gettemp(),getbattery(),setRTC(),beep();
@@ -73,6 +57,9 @@
int port =80; // set server port
int SERVtimeout =5; // set server timeout in seconds in case link breaks.
+char ssid[32] = "mbed02"; // enter WiFi router ssid inside the quotes
+char pwd [32] = "0123456789a"; // enter WiFi router password inside the quotes
+
// Serial Interrupt read ESP data
void callback()
{
@@ -107,15 +94,15 @@
}
beep();
startserver();
-
+
while(1) {
if(DataRX==1) {
pc.printf("\f\n\r------------ main while > if --------------\n\r");
-
+
ReadWebData();
beep();
if (servreq == 1 && weberror == 0) {
- pc.printf("\f\n\r------------ befor send page --------------\n\r");
+ pc.printf("\f\n\r------------ befor send page --------------\n\r");
sendpage();
}
esp.attach(&callback);
@@ -137,87 +124,209 @@
// WEB page data
-strcpy(webbuff, "<!DOCTYPE html>");
-strcat(webbuff, "<html><head><title>RobotCar</title><meta name='viewport' content='width=device-width'/>");
-strcat(webbuff, "</head><body><center><p><strong>Robot Car Remot 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, "</td></p><tr ><strong>Now speed : </strong></tr><nobr id=\"speprint\">ready");
-strcat(webbuff, "</nobr><br><tr ><strong>Now action : </strong></tr>");
-strcat(webbuff, "<nobr id=\"funprint\">ready</nobr><table><tr><td></td><td>");
-
-strcat(webbuff, "<button id='gobtn' type='button' style='width:100px;height:60px' value=\"GO\" onClick='send_mes(this.id,this.value)'>GO");
-strcat(webbuff, "</button></td><td></td></tr><tr><td>");
-strcat(webbuff, "<button id='leftbtn' type='button' style='width:100px;height:60px' value=\"LEFT\" onClick='send_mes(this.id,this.value)' >LEFT");
-strcat(webbuff, "</button></td><td>");
-
-strcat(webbuff, "<button id='stopbtn' type='button' style='width:100px;height:60px' value=\"STOP\" onClick='send_mes(this.id,this.value)' >STOP");
-strcat(webbuff, "</button></td><td>");
-strcat(webbuff, "<button id='rightbtn' type='button' style='width:100px;height:60px' value=\"RIGHT\" onClick='send_mes(this.id,this.value)' >RIGHT");
-strcat(webbuff, "</button></td></tr><td></td><td>");
-strcat(webbuff, "<button id='backbtn' type='button' style='width:100px;height:60px' value=\"BACK\" onClick='send_mes(this.id,this.value)' >BACK");
-strcat(webbuff, "</button></td><td style='vertical-align:top; text-align:right;'></td></tr></table>");
-
-
+ strcpy(webbuff, "<!DOCTYPE html>");
+ strcat(webbuff, "<html><head><title>RobotCar</title><meta name='viewport' content='width=device-width'/>");
+ strcat(webbuff, "<style type=\"text/css\">.noselect{ width:100px;height:60px;}.light{ width:100px;height:60px;background-color:00ff66;}</style>");
+ strcat(webbuff, "</head><body><center><p><strong>Robot Car Remot 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, "</td></p>");
+ strcat(webbuff, "<br>");
+ strcat(webbuff, "<table><tr><td></td><td>");
-//begin
-strcat(webbuff, "<strong>Addition functions:</strong><table>");
-strcat(webbuff, "<td>");//ok
-strcat(webbuff, "<button id='avoidbtn' type='button' style='width:100px;height:60px' value=\"AVOIDANCE\" onClick='send_mes_fun(this.id,this.value)' >");
-strcat(webbuff, "AVOIDANCE</button></td><td>");
-strcat(webbuff, "<button id='tracebtn' type='button' style='width:100px;height:60px' value=\"LINE TRACE\" onClick='send_mes_fun(this.id,this.value)' >LINE TRACE");
-strcat(webbuff, "</button></td><td>");
-strcat(webbuff, "<button id='defbtn' type='button' style='width:100px;height:60px' value=\"DEFAULT\" onClick='send_mes_fun(this.id,this.value)' >DEFAULT");
-strcat(webbuff, "</button></td></table><table><td>");
-strcat(webbuff, "</td><strong>Speed level:</strong>");
-strcat(webbuff, "</table><td>");
-strcat(webbuff, "<button id='sp1btn' type='button' style='width:100px;height:60px' value=\"SLOW\" onClick='send_mes_spe(this.id,this.value)' >SLOW");
-strcat(webbuff, "</button></td><td>");
-strcat(webbuff, "<button id='sp2btn' type='button' style='width:100px;height:60px' value=\"FAST\" onClick='send_mes_spe(this.id,this.value)' >FAST");
-strcat(webbuff, "</button>");
-strcat(webbuff, "</td>");
-strcat(webbuff, "<td>");
-strcat(webbuff, "<button id='sp3btn' type='button' style='width:100px;height:60px' value=\"FLY\" onClick='send_mes_spe(this.id,this.value)' >FLY");
-strcat(webbuff, "</button>");
-strcat(webbuff, "</td>");
-strcat(webbuff, "<table>");
-strcat(webbuff, "<td>");
-strcat(webbuff, "</td>");
-strcat(webbuff, "</table>"); //end
-
-
+ 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></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></td><td>");
+ strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,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></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></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_fun(this.id,this.value)' >");
+ strcat(webbuff, "AVOIDANCE</button></td><td>");
+ strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE TRACE\" onClick='send_mes_fun(this.id,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></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></td><td>");
+ strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,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></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></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_fun(this.id,this.value)' >");
+ strcat(webbuff, "AVOIDANCE</button></td><td>");
+ strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE TRACE\" onClick='send_mes_fun(this.id,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></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></td><td>");
+ strcat(webbuff, "<button id='stopbtn' type='button' class=\"light\" value=\"STOP\" onClick='send_mes(this.id,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></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></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_fun(this.id,this.value)' >");
+ strcat(webbuff, "AVOIDANCE</button></td><td>");
+ strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE TRACE\" onClick='send_mes_fun(this.id,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></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></td><td>");
+ strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,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></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></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_fun(this.id,this.value)' >");
+ strcat(webbuff, "AVOIDANCE</button></td><td>");
+ strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE TRACE\" onClick='send_mes_fun(this.id,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></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></td><td>");
+ strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,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></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></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_fun(this.id,this.value)' >");
+ strcat(webbuff, "AVOIDANCE</button></td><td>");
+ strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE TRACE\" onClick='send_mes_fun(this.id,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></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></td><td>");
+ strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,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></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></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_fun(this.id,this.value)' >");
+ strcat(webbuff, "AVOIDANCE</button></td><td>");
+ strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE TRACE\" onClick='send_mes_fun(this.id,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></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></td><td>");
+ strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,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></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></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_fun(this.id,this.value)' >");
+ strcat(webbuff, "AVOIDANCE</button></td><td>");
+ strcat(webbuff, "<button id='tracebtn' type='button' class=\"light\" value=\"LINE TRACE\" onClick='send_mes_fun(this.id,this.value)' >LINE TRACE");
+ break;
+ case default:
+ strcat(webbuff, "<button id='gobtn' type='button' class=\"noselect\" value=\"GO\" onClick='send_mes(this.id,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></td><td>");
+ strcat(webbuff, "<button id='stopbtn' type='button' class=\"noselect\" value=\"STOP\" onClick='send_mes(this.id,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></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></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_fun(this.id,this.value)' >");
+ strcat(webbuff, "AVOIDANCE</button></td><td>");
+ strcat(webbuff, "<button id='tracebtn' type='button' class=\"noselect\" value=\"LINE TRACE\" onClick='send_mes_fun(this.id,this.value)' >LINE TRACE");
+ break;
+ }
+ strcat(webbuff, "</button></td></tr></table>");
+ strcat(webbuff, "<strong>Speed</strong>");
+ strcat(webbuff, "<table><tr><td>");
+//ready示速度だけ点灯
+ switch (flag_sp%3) {
+ case 0:
+ strcat(webbuff, "<button id='sp1btn' type='button' class=\"light\" value=\"SLOW\" onClick='send_mes_spe(this.id,this.value)' >SLOW");
+ 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></td><td>");
+ strcat(webbuff, "<button id='sp3btn' type='button' class=\"noselect\" value=\"FLY\" onClick='send_mes_spe(this.id,this.value)' >FLY");
+ case 1:
+ strcat(webbuff, "<button id='sp1btn' type='button' class=\"noselect\" value=\"SLOW\" onClick='send_mes_spe(this.id,this.value)' >SLOW");
+ 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></td><td>");
+ strcat(webbuff, "<button id='sp3btn' type='button' class=\"noselect\" value=\"FLY\" onClick='send_mes_spe(this.id,this.value)' >FLY");
+ case 2:
+ strcat(webbuff, "<button id='sp1btn' type='button' class=\"noselect\" value=\"SLOW\" onClick='send_mes_spe(this.id,this.value)' >SLOW");
+ 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></td><td>");
+ strcat(webbuff, "<button id='sp3btn' type='button' class=\"light\" value=\"FLY\" onClick='send_mes_spe(this.id,this.value)' >FLY");
+ default:
+ strcat(webbuff, "<button id='sp1btn' type='button' class=\"noselect\" value=\"SLOW\" onClick='send_mes_spe(this.id,this.value)' >SLOW");
+ 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></td><td>");
+ strcat(webbuff, "<button id='sp3btn' type='button' class=\"noselect\" value=\"FLY\" onClick='send_mes_spe(this.id,this.value)' >FLY");
+ }
+ 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 send_mes(btnmes,btnval){");
-strcat(webbuff, "var url = \"http://\" + window.location.hostname + \"/cargo?a=\" + btnval;");
-strcat(webbuff, "htmlacs(url);");
-strcat(webbuff, "console.log(url);");
-strcat(webbuff, "}");
-strcat(webbuff, "function htmlacs(url) {");
-strcat(webbuff, "var xhr = new XMLHttpRequest();");
-strcat(webbuff, "xhr.open(\"GET\", url);");
-strcat(webbuff, "xhr.send(\"\");");
-strcat(webbuff, "}");
-strcat(webbuff, "function send_mes_spe(btnmes,btnval){");
-strcat(webbuff, "console.log(btnmes);");
-strcat(webbuff, "if(document.getElementById(\"speprint\")){");
-strcat(webbuff, "document.getElementById(\"speprint\").innerHTML=btnval;");
-strcat(webbuff, "}");
-strcat(webbuff, "}");
-strcat(webbuff, "function send_mes_fun(btnmes,btnval){");
-strcat(webbuff, "console.log(btnmes);");
-strcat(webbuff, "if(document.getElementById(\"funprint\")){");
-strcat(webbuff, "document.getElementById(\"funprint\").innerHTML=btnval;");
-strcat(webbuff, "}");
-strcat(webbuff, "}");
-strcat(webbuff, "</script>");
+ strcat(webbuff, "</center>");
+ strcat(webbuff, "</body>");
+ strcat(webbuff, "</html>");
+ strcat(webbuff, "<script language=\"javascript\" type=\"text/javascript\">");
+ strcat(webbuff, "function htmlacs(url) {");
+ strcat(webbuff, "var xhr = new XMLHttpRequest();");
+ strcat(webbuff, "xhr.open(\"GET\", url);");
+ strcat(webbuff, "xhr.send(\"\");");
+ strcat(webbuff, "}");
+ strcat(webbuff, "function send_mes(btnmes,btnval){");
+ strcat(webbuff, "var url = \"http://\" + window.location.hostname + \"/cargo?a=\" + btnval;");
+ strcat(webbuff, "htmlacs(url);");
+ strcat(webbuff, "console.log(url);");
+ strcat(webbuff, "}");
+ strcat(webbuff, "function send_mes_spe(btnmes,btnval){");
+ strcat(webbuff, "var url = \"http://\" + window.location.hostname + \"/cargo?a=\" + btnval;");
+ strcat(webbuff, "htmlacs(url);");
+ strcat(webbuff, "console.log(url);");
+ strcat(webbuff, "}");
+ strcat(webbuff, "}");
+ strcat(webbuff, "function send_mes_fun(btnmes,btnval){");
+ strcat(webbuff, "var url = \"http://\" + window.location.hostname + \"/cargo?a=\" + btnval;");
+ strcat(webbuff, "htmlacs(url);");
+ strcat(webbuff, "console.log(url);");
+ 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, 1500); // send IPD link channel and buffer character length.
timeout=500;
getcount=40;
@@ -225,12 +334,12 @@
getreply();
pc.printf(replybuff);
pc.printf("\n++++++++++ AT+CIPSENDBUF=%d,%d+++++++++\r\n", linkID, 1500);
-
+
pc.printf("\n++++++++++ bufl is %d ++++++++++\r\n",bufl);
-
+
//pastthrough mode
SendWEB(); // send web page
-
+
memset(webbuff, '\0', sizeof(webbuff));
sendcheck();
}
@@ -242,44 +351,45 @@
if(esp.writeable()) {
while(webbuff[i]!='\0') {
esp.putc(webbuff[i]);
-
- //****
- //output at command when 2000
- if(i==1499){
- wait_ms(10);
- sprintf(cmdbuff,"AT+CIPSENDBUF=%d,%d\r\n", linkID, bufl-1500); // send IPD link channel and buffer character length.
- pc.printf("\r\n++++++++++ AT+CIPSENDBUF=%d,%d ++++++++++\r\n", linkID, bufl-1500);
- timeout=600;
- getcount=50;
- SendCMD();
- getreply();
- pc.printf(replybuff);
- pc.printf("\r\n+++++++++++++++++++\r\n");
-
- }
-
- //****
- i++;
+
+ //****
+ //output at command when 2000
+ if(i==1499) {
+ wait_ms(10);
+ sprintf(cmdbuff,"AT+CIPSENDBUF=%d,%d\r\n", linkID, bufl-1500); // send IPD link channel and buffer character length.
+ pc.printf("\r\n++++++++++ AT+CIPSENDBUF=%d,%d ++++++++++\r\n", linkID, bufl-1500);
+ timeout=600;
+ getcount=50;
+ SendCMD();
+ getreply();
+ pc.printf(replybuff);
+ pc.printf("\r\n+++++++++++++++++++\r\n");
+
+ }
+
+ //****
+ i++;
pc.printf("%c",webbuff[i]);
}
}
-
-
+
+
//****
/*
- sprintf(cmdbuff,"AT+CIPCLOSE\r\n"); // send IPD link channel and buffer character length.
+ sprintf(cmdbuff,"AT+CIPCLOSE\r\n"); // send IPD link channel and buffer character length.
SendCMD();
*/
//*****
-
- pc.printf("\n++++++++++ send web i= %dinfo ++++++++++\r\n",i);
+
+ pc.printf("\n++++++++++ send web i= %dinfo ++++++++++\r\n",i);
}
// wait for ESP "SEND OK" reply, then close IP to load web page
//touchuan mode
-void touchuan(){
+void touchuan()
+{
strcpy(cmdbuff, "AT+CIPMUX=0\r\n");
pc.printf("\n++++++++++ AT+CIPMUX=0\r\n+++++++++");
timeout=500;
@@ -309,7 +419,7 @@
getreply();
pc.printf(replybuff);
}
-
+
void sendcheck()
{
weberror=1;
@@ -362,50 +472,108 @@
//int i=0;
pc.printf("+++++++++++++++++succed+++++++++++++++++++++");
pc.printf("%s",webdata);
-
-
-
+
+
+
+ if( strstr(webdata, "GO") != NULL ) {
+ pc.printf("+++++++++++++++++前進+++++++++++++++++++++\r\n");
+ avoi_thread.stop(); // avoidanceスレッド停止
+ trace_thread.stop(); // traceスレッド停止
+ run = ADVANCE; // 前進
+ mode = READY; // モードs変更
+ motor_thread.start(); // motorスレッド再開
+ display(); // ディスプレイ表示
+
+ }
+
if( strstr(webdata, "LEFT") != NULL ) {
- //ledR=!ledR;
- led1=!led1;
- pc.printf("+++++++++++++++++ledR+++++++++++++++++++++\r\n");
-
+ pc.printf("+++++++++++++++++左折+++++++++++++++++++++\r\n");
+ avoi_thread.stop(); // avoidanceスレッド停止
+ trace_thread.stop(); // traceスレッド停止
+ run = LEFT;
+ mode = READY;
+ motor_thread.start(); // motorスレッド再開
+ display(); // ディスプレイ表示
+ }
+
+ if( strstr(webdata, "STOP") != NULL ) {
+ pc.printf("+++++++++++++++++停止+++++++++++++++++++++\r\n");
+ avoi_thread.stop(); // avoidanceスレッド停止
+ trace_thread.stop(); // traceスレッド停止
+ run = STOP;
+ mode = READY;
+ motor_thread.start(); // motorスレッド再開
+ display(); // ディスプレイ表示
}
-
+
if( strstr(webdata, "RIGHT") != NULL ) {
- ledG=!ledG;
- pc.printf("+++++++++++++++++ledG+++++++++++++++++++++\r\n");
+ pc.printf("+++++++++++++++++右折+++++++++++++++++++++\r\n");
+ avoi_thread.stop(); // avoidanceスレッド停止
+ trace_thread.stop(); // traceスレッド停止
+ run = RIGHT;
+ mode = READY;
+ motor_thread.start(); // motorスレッド再開
+ display(); // ディスプレイ表示
+ }
+
+ if( strstr(webdata, "BACK") != NULL ) {
+ pc.printf("+++++++++++++++++後進+++++++++++++++++++++\r\n");
+ avoi_thread.stop(); // avoidanceスレッド停止
+ trace_thread.stop(); // traceスレッド停止
+ run = BACK;
+ mode = READY;
+ motor_thread.start(); // motorスレッド再開
+ display(); // ディスプレイ表示
}
pc.printf("+++++++++++++++++succed+++++++++++++++++++++");
-
-
- if( strstr(webdata, "sp3btn=0") != NULL ) {
- led1=!led1;
-
+
+ if( strstr(webdata, "AVOIDANCE") != NULL ) {
+ pc.printf("+++++++++++++++++AVOIDANCE+++++++++++++++++++++");
+ trace_thread.stop(); // traceスレッド停止
+ avoi_thread.start(); // avoidanceスレッド再開
+ motor_thread.start(); // motorスレッド再開
+ mode=AVOIDANCE;
+ run = ADVANCE;
+ display(); // ディスプレイ表示
}
- if( strstr(webdata, "led1=1") != NULL ) {
- led1=1;
- }
- if( strstr(webdata, "led1=0") != NULL ) {
- led1=0;
- }
- if( strstr(webdata, "Out1=1") != NULL ) {
- Out1=1;
+ if( strstr(webdata, "LINE TRACE") != NULL ) {
+ pc.printf("+++++++++++++++++LINET RACE+++++++++++++++++++++");
+ avoi_thread.stop(); // avoidanceスレッド再開
+ trace_thread.start(); // traceスレッド停止
+ motor_thread.start(); // motorスレッド再開
+ mode=LINE_TRACE;
+ display(); // ディスプレイ表示
}
- if( strstr(webdata, "Out1=0") != NULL ) {
- Out1=0;
- }
- if( strstr(webdata, "Out2=1") != NULL ) {
- Out2=1;
+ if( strstr(webdata, "DEFAULT") != NULL ) {//プログラムなくね
+ pc.printf("+++++++++++++++++DEFAULT+++++++++++++++++++++");
+ avoi_thread.stop(); // avoidanceスレッド再開
+ trace_thread.stop(); // traceスレッド停止
+ run = STOP;
+ mode = READY;
+ motor_thread.start(); // motorスレッド再開
+ display(); // ディスプレイ表示
+
}
- if( strstr(webdata, "Out2=0") != NULL ) {
- Out2=0;
+ if( strstr(webdata, "SLOW") != NULL ) {
+ pc.printf("++++++++++++++++++SLOW++++++++++++++++++++");
+ mode = SPEED; // スピードモード
+ flag_sp = 0;
+ display(); // ディスプレイ表示
+ mode = beforeMode; // 現在のモードに前回のモードを設定
}
- if( strstr(webdata, "Out3=1") != NULL ) {
- Out3=1;
+ if( strstr(webdata, "FAST") != NULL ) {
+ pc.printf("++++++++++++++++++++FAST++++++++++++++++++");
+ mode = SPEED; // スピードモード
+ flag_sp = 1;
+ display(); // ディスプレイ表示
+ mode = beforeMode; // 現在のモードに前回のモードを設定
}
- if( strstr(webdata, "Out3=0") != NULL ) {
- Out3=0;
+ if( strstr(webdata, "FLY") != NULL ) {
+ pc.printf("+++++++++++++++++++BERYFAST+++++++++++++++++++");
+ mode = SPEED; // スピードモード d
+ flag_sp = 2;
+ display(); // ディスプレイ表示
+ mode = beforeMode; // 現在のモードに前回のモードを設定
}
sprintf(channel, "%d",linkID);
if (strstr(webdata, "GET") != NULL) {
@@ -515,14 +683,7 @@
Ht = (AdcIn*3.3); // set the numeric to the exact MCU analog reference voltage for greater accuracy
sprintf(Vcc,"%2.3f",Ht);
}
-// Temperature example
-void gettemp()
-{
-
- AdcIn=Ain2.read();
- Ht = (AdcIn*3.3); // set the numeric to the exact MCU analog reference voltage for greater accuracy
- sprintf(Temp,"%2.3f",Ht);
-}
+
// Get RTC time
void gettime()
{
@@ -530,14 +691,6 @@
strftime(timebuf,50,"%H:%M:%S %a %d %b %y", localtime(&seconds));
}
-void beep()
-{
- speaker.period(1.0/2000); // 2000hz period
- speaker = 0.5; //50% duty cycle - max volume
- wait_ms(60);
- speaker=0.0; // turn off audio
-}
-
void setRTC()
{
t.tm_sec = (0); // 0-59