more webui
This commit is contained in:
		| @@ -78,7 +78,7 @@ | |||||||
|         <h3>Erfassung Wegstrecke</h3> |         <h3>Erfassung Wegstrecke</h3> | ||||||
|         <hr> |         <hr> | ||||||
|         <p> |         <p> | ||||||
|         <form action="source-settings" method="POST" class="form-horizontal"> |         <form action="\post.htm" method="POST" class="form-horizontal"> | ||||||
|           <div class="form-group"> |           <div class="form-group"> | ||||||
|             <label for="sourceselect" class="control-label col-xs-5">Wegstrecke Quelle</label> |             <label for="sourceselect" class="control-label col-xs-5">Wegstrecke Quelle</label> | ||||||
|             <div class="col-xs-7"> |             <div class="col-xs-7"> | ||||||
| @@ -98,12 +98,13 @@ | |||||||
|         <div %SHOW_IMPULSE_SETTINGS%> |         <div %SHOW_IMPULSE_SETTINGS%> | ||||||
|           <h4>Einstellungen Impuls</h4> |           <h4>Einstellungen Impuls</h4> | ||||||
|           <p> |           <p> | ||||||
|           <form class="form-horizontal"> |           <form action="\post.htm" method="POST" class="form-horizontal"> | ||||||
|             <div class="form-group"> |             <div class="form-group"> | ||||||
|               <label for="tirewidth" class="control-label col-xs-5">Reifenbreite</label> |               <label for="tirewidth" class="control-label col-xs-5">Reifenbreite</label> | ||||||
|               <div class="col-xs-7"> |               <div class="col-xs-7"> | ||||||
|                 <div class="input-group"> |                 <div class="input-group"> | ||||||
|                   <input id="tirewidth" name="tirewidth" type="text" required="required" class="form-control"> |                   <input id="tirewidth" name="tirewidth" type="text" required="required" class="form-control" | ||||||
|  |                     value="%TIRE_WIDTH_MM%"> | ||||||
|                   <div class="input-group-addon">mm</div> |                   <div class="input-group-addon">mm</div> | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
| @@ -112,7 +113,8 @@ | |||||||
|               <label for="tireratio" class="control-label col-xs-5">Höhe/Breite-Verhältniss</label> |               <label for="tireratio" class="control-label col-xs-5">Höhe/Breite-Verhältniss</label> | ||||||
|               <div class="col-xs-7"> |               <div class="col-xs-7"> | ||||||
|                 <div class="input-group"> |                 <div class="input-group"> | ||||||
|                   <input id="tireratio" name="tireratio" type="text" required="required" class="form-control"> |                   <input id="tireratio" name="tireratio" type="text" required="required" class="form-control" | ||||||
|  |                     value="%TIRE_RATIO%"> | ||||||
|                   <div class="input-group-addon"></div> |                   <div class="input-group-addon"></div> | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
| @@ -121,7 +123,8 @@ | |||||||
|               <label for="tiredia" class="control-label col-xs-5">Felgendurchmesser</label> |               <label for="tiredia" class="control-label col-xs-5">Felgendurchmesser</label> | ||||||
|               <div class="col-xs-7"> |               <div class="col-xs-7"> | ||||||
|                 <div class="input-group"> |                 <div class="input-group"> | ||||||
|                   <input id="tiredia" name="tiredia" type="text" required="required" class="form-control"> |                   <input id="tiredia" name="tiredia" type="text" required="required" class="form-control" | ||||||
|  |                     value="%RIM_DIAMETER%"> | ||||||
|                   <div class="input-group-addon">"</div> |                   <div class="input-group-addon">"</div> | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
| @@ -130,7 +133,8 @@ | |||||||
|               <label for="pulserev" class="control-label col-xs-5">Pulse pro Umdrehung</label> |               <label for="pulserev" class="control-label col-xs-5">Pulse pro Umdrehung</label> | ||||||
|               <div class="col-xs-7"> |               <div class="col-xs-7"> | ||||||
|                 <div class="input-group"> |                 <div class="input-group"> | ||||||
|                   <input id="pulserev" name="pulserev" type="text" required="required" class="form-control"> |                   <input id="pulserev" name="pulserev" type="text" required="required" class="form-control" | ||||||
|  |                     value="PULSE_PER_REV"> | ||||||
|                   <div class="input-group-addon"></div> |                   <div class="input-group-addon"></div> | ||||||
|                 </div> |                 </div> | ||||||
|               </div> |               </div> | ||||||
| @@ -148,7 +152,7 @@ | |||||||
|         <div %SHOW_CAN_SETTINGS%> |         <div %SHOW_CAN_SETTINGS%> | ||||||
|           <h4>Einstellungen CAN-Bus</h4> |           <h4>Einstellungen CAN-Bus</h4> | ||||||
|           <p> |           <p> | ||||||
|           <form class="form-horizontal"> |           <form action="\post.htm" method="POST" class="form-horizontal"> | ||||||
|             <div class="form-group"> |             <div class="form-group"> | ||||||
|               <label for="cansource" class="control-label col-xs-5">Model</label> |               <label for="cansource" class="control-label col-xs-5">Model</label> | ||||||
|               <div class="col-xs-7"> |               <div class="col-xs-7"> | ||||||
| @@ -170,7 +174,7 @@ | |||||||
|         <div %SHOW_GPS_SETTINGS%> |         <div %SHOW_GPS_SETTINGS%> | ||||||
|           <h4>Einstellungen GPS</h4> |           <h4>Einstellungen GPS</h4> | ||||||
|           <p> |           <p> | ||||||
|           <form class="form-horizontal"> |           <form action="\post.htm" method="POST" class="form-horizontal"> | ||||||
|             <div class="form-group"> |             <div class="form-group"> | ||||||
|               <label for="gpsbaud" class="control-label col-xs-5">Baudrate</label> |               <label for="gpsbaud" class="control-label col-xs-5">Baudrate</label> | ||||||
|               <div class="col-xs-7"> |               <div class="col-xs-7"> | ||||||
| @@ -204,7 +208,7 @@ | |||||||
|         <h3>Wartung</h3> |         <h3>Wartung</h3> | ||||||
|         <hr> |         <hr> | ||||||
|         <p> |         <p> | ||||||
|         <form class="form-horizontal"> |         <form action="\post.htm" method="POST" class="form-horizontal"> | ||||||
|           <div class="form-group"> |           <div class="form-group"> | ||||||
|             <label for="purgepulse" class="control-label col-xs-5">Impulse</label> |             <label for="purgepulse" class="control-label col-xs-5">Impulse</label> | ||||||
|             <div class="col-xs-7"> |             <div class="col-xs-7"> | ||||||
| @@ -228,7 +232,7 @@ | |||||||
|         <h3>Öltank</h3> |         <h3>Öltank</h3> | ||||||
|         <hr> |         <hr> | ||||||
|         <p> |         <p> | ||||||
|         <form class="form-horizontal"> |         <form action="\post.htm" method="POST" class="form-horizontal"> | ||||||
|           <div class="form-group"> |           <div class="form-group"> | ||||||
|             <label for="tankcap" class="control-label col-xs-5">Tankkapazität</label> |             <label for="tankcap" class="control-label col-xs-5">Tankkapazität</label> | ||||||
|             <div class="col-xs-7"> |             <div class="col-xs-7"> | ||||||
|   | |||||||
							
								
								
									
										9
									
								
								Software/ChainLube/data/post.htm
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								Software/ChainLube/data/post.htm
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,9 @@ | |||||||
|  | <!DOCTYPE html> | ||||||
|  | <html> | ||||||
|  |   <head> | ||||||
|  |     <meta http-equiv="refresh" content="3; url='/index.htm'" /> | ||||||
|  |   </head> | ||||||
|  |   <body> | ||||||
|  |     <p>Processing...</p> | ||||||
|  |   </body> | ||||||
|  | </html> | ||||||
| @@ -80,7 +80,7 @@ typedef struct | |||||||
|   uint32_t DistancePerRevolution_mm = 2000; |   uint32_t DistancePerRevolution_mm = 2000; | ||||||
|   uint8_t BleedingPulses = 25; |   uint8_t BleedingPulses = 25; | ||||||
|   SpeedSource_t SpeedSource = SOURCE_IMPULSE; |   SpeedSource_t SpeedSource = SOURCE_IMPULSE; | ||||||
|   GPSBaudRate_t GPSBaudRate = BAUD_9600; |   GPSBaudRate_t GPSBaudRate = BAUD_115200; | ||||||
| #if PCB_REVISION == 13 | #if PCB_REVISION == 13 | ||||||
|   CANSource_t CANSource = KTM_890_ADV_R_2021; |   CANSource_t CANSource = KTM_890_ADV_R_2021; | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -18,9 +18,11 @@ void initWebUI() | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   webServer.serveStatic("/static/", LittleFS, "/static/"); |   webServer.serveStatic("/static/", LittleFS, "/static/"); | ||||||
|  |   webServer.on("/", HTTP_GET, [](AsyncWebServerRequest *request) | ||||||
|  |                { request->redirect("/index.htm"); }); | ||||||
|   webServer.onNotFound(WebserverNotFound_Callback); |   webServer.onNotFound(WebserverNotFound_Callback); | ||||||
|   webServer.on("/index.htm", HTTP_GET, Webserver_Callback); |   webServer.on("/index.htm", HTTP_GET, Webserver_Callback); | ||||||
|   webServer.on("/", HTTP_POST, WebserverPOST_Callback); |   webServer.on("/post.htm", HTTP_POST, WebserverPOST_Callback); | ||||||
|  |  | ||||||
|   webServer.begin(); |   webServer.begin(); | ||||||
| } | } | ||||||
| @@ -85,7 +87,10 @@ String processor(const String &var) | |||||||
|   { |   { | ||||||
|     String temp; |     String temp; | ||||||
|     for (uint32_t i = 0; i < SpeedSourceString_Elements; i++) |     for (uint32_t i = 0; i < SpeedSourceString_Elements; i++) | ||||||
|       temp = temp + "<option value=\"" + i + "\">" + SpeedSourceString[i] + "</option>"; |     { | ||||||
|  |       String selected = LubeConfig.SpeedSource == i ? " selected " : ""; | ||||||
|  |       temp = temp + "<option value=\"" + i + "\"" + selected + ">" + SpeedSourceString[i] + "</option>"; | ||||||
|  |     } | ||||||
|     return temp; |     return temp; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -93,14 +98,20 @@ String processor(const String &var) | |||||||
|   { |   { | ||||||
|     String temp; |     String temp; | ||||||
|     for (uint32_t i = 0; i < CANSourceString_Elements; i++) |     for (uint32_t i = 0; i < CANSourceString_Elements; i++) | ||||||
|       temp = temp + "<option value=\"" + i + "\">" + CANSourceString[i] + "</option>"; |     { | ||||||
|  |       String selected = LubeConfig.CANSource == i ? " selected " : ""; | ||||||
|  |       temp = temp + "<option value=\"" + i + "\"" + selected + ">" + CANSourceString[i] + "</option>"; | ||||||
|  |     } | ||||||
|     return temp; |     return temp; | ||||||
|   } |   } | ||||||
|   if (var == "GPSBAUD_SELECT_OPTIONS") |   if (var == "GPSBAUD_SELECT_OPTIONS") | ||||||
|   { |   { | ||||||
|     String temp; |     String temp; | ||||||
|     for (uint32_t i = 0; i < GPSBaudRateString_Elements; i++) |     for (uint32_t i = 0; i < GPSBaudRateString_Elements; i++) | ||||||
|       temp = temp + "<option value=\"" + i + "\">" + GPSBaudRateString[i] + "</option>"; |     { | ||||||
|  |       String selected = LubeConfig.GPSBaudRate == i ? " selected " : ""; | ||||||
|  |       temp = temp + "<option value=\"" + i + "\"" + selected + ">" + GPSBaudRateString[i] + "</option>"; | ||||||
|  |     } | ||||||
|     return temp; |     return temp; | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -120,12 +131,15 @@ void Webserver_Callback(AsyncWebServerRequest *request) | |||||||
|  |  | ||||||
| void WebserverPOST_Callback(AsyncWebServerRequest *request) | void WebserverPOST_Callback(AsyncWebServerRequest *request) | ||||||
| { | { | ||||||
|   String message; |   Serial.print("POST:\n"); | ||||||
|   if (request->hasParam(PARAM_MESSAGE, true)) |   int paramsNr = request->params(); | ||||||
|  |   for (int i = 0; i < paramsNr; i++) | ||||||
|   { |   { | ||||||
|     message = request->getParam(PARAM_MESSAGE, true)->value(); |     AsyncWebParameter *p = request->getParam(i); | ||||||
|     Serial.printf("POST: %s", message.c_str()); |     Serial.printf("%s : %s\n", p->name().c_str(), p->value().c_str()); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   request->send(LittleFS, "/post.htm", String(), false, processor); | ||||||
| } | } | ||||||
|  |  | ||||||
| void WebserverNotFound_Callback(AsyncWebServerRequest *request) | void WebserverNotFound_Callback(AsyncWebServerRequest *request) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user