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: LCD_i2c_GSOE ESP8266WebserverGSOE
main.cpp
00001 /* ATCmdParser usage example 00002 * Copyright (c) 2016 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #include "mbed.h" 00018 #include "ESP8266Webserver.h" 00019 #include "LCD.h" 00020 00021 #define VOR 0b1010 00022 #define RUECK 0b0101 00023 #define LINKS 0b1001 00024 #define RECHTS 0b0110 00025 #define STOP 0b0000 00026 00027 lcd myLCD; 00028 ESP8266Webserver myWebserver; 00029 AnalogIn poti(PA_0); 00030 PortOut roboter(PortC,0xFF); 00031 string getRootPage() 00032 { 00033 string webpage; 00034 webpage="<!DOCTYPE html>"; 00035 //HTML 00036 webpage+="<html>"; 00037 webpage+="<head>"; 00038 webpage+="<title>STM32 HTTP</title>"; 00039 webpage+="</head>"; 00040 webpage+="<body>"; 00041 webpage+="<h1>WIFI mit STM32 ESP01</h1>\n"; 00042 webpage+="<table>"; 00043 webpage+="<tr> <td></td> <td><a href=\"vor\"><button>VOR</button></a></td> <td></td> </tr>"; 00044 webpage+="<tr> <td><a href=\"links\"><button>LINKS</button></a></td> <td><a href=\"stop\"><button>STOP</button></a></td> <td><a href=\"rechts\"><button>RECHTS</button></a></td></tr>"; 00045 webpage+="<tr> <td></td> <td><a href=\"rueck\"><button>RUECK</button></a></td> <td></td> </tr> "; 00046 webpage+="</table>"; 00047 webpage+="</body>"; 00048 webpage+="</html>"; 00049 return webpage; 00050 } 00051 00052 00053 void testfunc() 00054 { 00055 myWebserver.send(200,"text/html",getRootPage()); 00056 } 00057 00058 void vor() 00059 { 00060 roboter=VOR; 00061 myWebserver.send(200,"text/html",getRootPage()); 00062 } 00063 00064 void rueck() 00065 { 00066 roboter=RUECK; 00067 myWebserver.send(200,"text/html",getRootPage()); 00068 } 00069 00070 void links() 00071 { 00072 roboter=LINKS; 00073 myWebserver.send(200,"text/html",getRootPage()); 00074 } 00075 00076 void rechts() 00077 { 00078 roboter=RECHTS; 00079 myWebserver.send(200,"text/html",getRootPage()); 00080 } 00081 00082 void stop() 00083 { 00084 roboter=STOP; 00085 myWebserver.send(200,"text/html",getRootPage()); 00086 } 00087 00088 int main() { 00089 myWebserver.on("vor",&vor); 00090 myWebserver.on("rueck",&rueck); 00091 myWebserver.on("links",&links); 00092 myWebserver.on("rechts",&rechts); 00093 myWebserver.on("stop",&stop); 00094 00095 myWebserver.on("/",&testfunc); 00096 myWebserver.begin(); 00097 myLCD.clear(); 00098 myLCD.cursorpos(0); 00099 myLCD.printf("%s",myWebserver.gibIP()); 00100 while(1) { 00101 myWebserver.handleClient(); 00102 } 00103 }
Generated on Thu Jul 28 2022 08:43:40 by
1.7.2