Roboterfahrzeug Arexx Webserver
Dependencies: LCD_i2c_GSOE ESP8266WebserverGSOE
main.cpp@14:22b43ffe4bae, 2021-08-09 (annotated)
- Committer:
- jack1930
- Date:
- Mon Aug 09 10:32:39 2021 +0000
- Revision:
- 14:22b43ffe4bae
- Parent:
- 10:54b312c82e18
Roboterfahrzeug
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jack1930 | 0:829bac853c96 | 1 | /* ATCmdParser usage example |
jack1930 | 0:829bac853c96 | 2 | * Copyright (c) 2016 ARM Limited |
jack1930 | 0:829bac853c96 | 3 | * |
jack1930 | 0:829bac853c96 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
jack1930 | 0:829bac853c96 | 5 | * you may not use this file except in compliance with the License. |
jack1930 | 0:829bac853c96 | 6 | * You may obtain a copy of the License at |
jack1930 | 0:829bac853c96 | 7 | * |
jack1930 | 0:829bac853c96 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
jack1930 | 0:829bac853c96 | 9 | * |
jack1930 | 0:829bac853c96 | 10 | * Unless required by applicable law or agreed to in writing, software |
jack1930 | 0:829bac853c96 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
jack1930 | 0:829bac853c96 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
jack1930 | 0:829bac853c96 | 13 | * See the License for the specific language governing permissions and |
jack1930 | 0:829bac853c96 | 14 | * limitations under the License. |
jack1930 | 0:829bac853c96 | 15 | */ |
jack1930 | 0:829bac853c96 | 16 | |
jack1930 | 0:829bac853c96 | 17 | #include "mbed.h" |
jack1930 | 0:829bac853c96 | 18 | #include "ESP8266Webserver.h" |
jack1930 | 0:829bac853c96 | 19 | #include "LCD.h" |
jack1930 | 0:829bac853c96 | 20 | |
jack1930 | 14:22b43ffe4bae | 21 | #define VOR 0b1010 |
jack1930 | 14:22b43ffe4bae | 22 | #define RUECK 0b0101 |
jack1930 | 14:22b43ffe4bae | 23 | #define LINKS 0b1001 |
jack1930 | 14:22b43ffe4bae | 24 | #define RECHTS 0b0110 |
jack1930 | 14:22b43ffe4bae | 25 | #define STOP 0b0000 |
jack1930 | 14:22b43ffe4bae | 26 | |
jack1930 | 0:829bac853c96 | 27 | lcd myLCD; |
jack1930 | 1:1f13f5f1fdbc | 28 | ESP8266Webserver myWebserver; |
jack1930 | 7:40e19bb6820a | 29 | AnalogIn poti(PA_0); |
jack1930 | 14:22b43ffe4bae | 30 | PortOut roboter(PortC,0xFF); |
jack1930 | 5:b4ae03006c7d | 31 | string getRootPage() |
jack1930 | 0:829bac853c96 | 32 | { |
jack1930 | 6:5353c5484d58 | 33 | string webpage; |
jack1930 | 7:40e19bb6820a | 34 | webpage="<!DOCTYPE html>"; |
jack1930 | 3:8dba70d37b7d | 35 | //HTML |
jack1930 | 7:40e19bb6820a | 36 | webpage+="<html>"; |
jack1930 | 7:40e19bb6820a | 37 | webpage+="<head>"; |
jack1930 | 7:40e19bb6820a | 38 | webpage+="<title>STM32 HTTP</title>"; |
jack1930 | 7:40e19bb6820a | 39 | webpage+="</head>"; |
jack1930 | 7:40e19bb6820a | 40 | webpage+="<body>"; |
jack1930 | 0:829bac853c96 | 41 | webpage+="<h1>WIFI mit STM32 ESP01</h1>\n"; |
jack1930 | 14:22b43ffe4bae | 42 | webpage+="<table>"; |
jack1930 | 14:22b43ffe4bae | 43 | webpage+="<tr> <td></td> <td><a href=\"vor\"><button>VOR</button></a></td> <td></td> </tr>"; |
jack1930 | 14:22b43ffe4bae | 44 | 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>"; |
jack1930 | 14:22b43ffe4bae | 45 | webpage+="<tr> <td></td> <td><a href=\"rueck\"><button>RUECK</button></a></td> <td></td> </tr> "; |
jack1930 | 14:22b43ffe4bae | 46 | webpage+="</table>"; |
jack1930 | 7:40e19bb6820a | 47 | webpage+="</body>"; |
jack1930 | 7:40e19bb6820a | 48 | webpage+="</html>"; |
jack1930 | 0:829bac853c96 | 49 | return webpage; |
jack1930 | 0:829bac853c96 | 50 | } |
jack1930 | 0:829bac853c96 | 51 | |
jack1930 | 0:829bac853c96 | 52 | |
jack1930 | 0:829bac853c96 | 53 | void testfunc() |
jack1930 | 0:829bac853c96 | 54 | { |
jack1930 | 5:b4ae03006c7d | 55 | myWebserver.send(200,"text/html",getRootPage()); |
jack1930 | 0:829bac853c96 | 56 | } |
jack1930 | 0:829bac853c96 | 57 | |
jack1930 | 14:22b43ffe4bae | 58 | void vor() |
jack1930 | 10:54b312c82e18 | 59 | { |
jack1930 | 14:22b43ffe4bae | 60 | roboter=VOR; |
jack1930 | 14:22b43ffe4bae | 61 | myWebserver.send(200,"text/html",getRootPage()); |
jack1930 | 14:22b43ffe4bae | 62 | } |
jack1930 | 14:22b43ffe4bae | 63 | |
jack1930 | 14:22b43ffe4bae | 64 | void rueck() |
jack1930 | 14:22b43ffe4bae | 65 | { |
jack1930 | 14:22b43ffe4bae | 66 | roboter=RUECK; |
jack1930 | 10:54b312c82e18 | 67 | myWebserver.send(200,"text/html",getRootPage()); |
jack1930 | 10:54b312c82e18 | 68 | } |
jack1930 | 10:54b312c82e18 | 69 | |
jack1930 | 14:22b43ffe4bae | 70 | void links() |
jack1930 | 14:22b43ffe4bae | 71 | { |
jack1930 | 14:22b43ffe4bae | 72 | roboter=LINKS; |
jack1930 | 14:22b43ffe4bae | 73 | myWebserver.send(200,"text/html",getRootPage()); |
jack1930 | 14:22b43ffe4bae | 74 | } |
jack1930 | 14:22b43ffe4bae | 75 | |
jack1930 | 14:22b43ffe4bae | 76 | void rechts() |
jack1930 | 10:54b312c82e18 | 77 | { |
jack1930 | 14:22b43ffe4bae | 78 | roboter=RECHTS; |
jack1930 | 14:22b43ffe4bae | 79 | myWebserver.send(200,"text/html",getRootPage()); |
jack1930 | 14:22b43ffe4bae | 80 | } |
jack1930 | 14:22b43ffe4bae | 81 | |
jack1930 | 14:22b43ffe4bae | 82 | void stop() |
jack1930 | 14:22b43ffe4bae | 83 | { |
jack1930 | 14:22b43ffe4bae | 84 | roboter=STOP; |
jack1930 | 10:54b312c82e18 | 85 | myWebserver.send(200,"text/html",getRootPage()); |
jack1930 | 10:54b312c82e18 | 86 | } |
jack1930 | 0:829bac853c96 | 87 | |
jack1930 | 7:40e19bb6820a | 88 | int main() { |
jack1930 | 14:22b43ffe4bae | 89 | myWebserver.on("vor",&vor); |
jack1930 | 14:22b43ffe4bae | 90 | myWebserver.on("rueck",&rueck); |
jack1930 | 14:22b43ffe4bae | 91 | myWebserver.on("links",&links); |
jack1930 | 14:22b43ffe4bae | 92 | myWebserver.on("rechts",&rechts); |
jack1930 | 14:22b43ffe4bae | 93 | myWebserver.on("stop",&stop); |
jack1930 | 14:22b43ffe4bae | 94 | |
jack1930 | 0:829bac853c96 | 95 | myWebserver.on("/",&testfunc); |
jack1930 | 7:40e19bb6820a | 96 | myWebserver.begin(); |
jack1930 | 2:c25aefe81534 | 97 | myLCD.clear(); |
jack1930 | 2:c25aefe81534 | 98 | myLCD.cursorpos(0); |
jack1930 | 2:c25aefe81534 | 99 | myLCD.printf("%s",myWebserver.gibIP()); |
jack1930 | 7:40e19bb6820a | 100 | while(1) { |
jack1930 | 0:829bac853c96 | 101 | myWebserver.handleClient(); |
jack1930 | 0:829bac853c96 | 102 | } |
jack1930 | 0:829bac853c96 | 103 | } |