Webserver GSOE Slider PWM ESP01 STM32Nucleo L152RE
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 lcd myLCD; 00022 ESP8266Webserver myWebserver; 00023 PwmOut Motor(PC_7); 00024 int wert=5; 00025 string slider="50"; 00026 00027 string getRootPage() 00028 { 00029 string webpage; 00030 webpage="<!DOCTYPE html>"; 00031 //HTML 00032 webpage+="<html>"; 00033 webpage+="<head>"; 00034 webpage+="<title>STM32 HTTP</title>"; 00035 webpage+="</head>"; 00036 webpage+="<body>"; 00037 webpage+="<h1>WIFI mit STM32 ESP01</h1><br>"; 00038 webpage+="<form>\n"; 00039 webpage+="<input type=\"range\" name=\"points\" min=\"0\" max=\"100\" value="+slider+">"; 00040 webpage+="<button>senden</button>\n"; 00041 webpage+="</form>\n"; 00042 webpage+="</body>"; 00043 webpage+="</html>"; 00044 return webpage; 00045 } 00046 00047 void testfunc() 00048 { 00049 myWebserver.send(200,"text/html",getRootPage()); 00050 } 00051 00052 void testfunc2() 00053 { 00054 slider=myWebserver.gibWert("points"); 00055 Motor=stof(slider,NULL)/100; 00056 myLCD.clear(); 00057 myLCD.cursorpos(0); 00058 myLCD.printf("%s",slider.c_str()); 00059 myWebserver.send(200,"text/html",getRootPage()); 00060 } 00061 00062 00063 int main() { 00064 myWebserver.on("points",&testfunc2); 00065 myWebserver.on("/",&testfunc); 00066 myWebserver.begin(); 00067 myLCD.clear(); 00068 myLCD.cursorpos(0); 00069 myLCD.printf("%s",myWebserver.gibIP()); 00070 while(1) { 00071 myWebserver.handleClient(); 00072 } 00073 }
Generated on Sat Oct 15 2022 00:04:16 by
1.7.2