more webui

This commit is contained in:
Marcel Peterkau 2022-02-27 22:23:58 +01:00
parent 6ba4c40166
commit 0bc6d01a5f
4 changed files with 46 additions and 19 deletions

View File

@ -78,7 +78,7 @@
<h3>Erfassung Wegstrecke</h3>
<hr>
<p>
<form action="source-settings" method="POST" class="form-horizontal">
<form action="\post.htm" method="POST" class="form-horizontal">
<div class="form-group">
<label for="sourceselect" class="control-label col-xs-5">Wegstrecke Quelle</label>
<div class="col-xs-7">
@ -98,12 +98,13 @@
<div %SHOW_IMPULSE_SETTINGS%>
<h4>Einstellungen Impuls</h4>
<p>
<form class="form-horizontal">
<form action="\post.htm" method="POST" class="form-horizontal">
<div class="form-group">
<label for="tirewidth" class="control-label col-xs-5">Reifenbreite</label>
<div class="col-xs-7">
<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>
</div>
@ -112,7 +113,8 @@
<label for="tireratio" class="control-label col-xs-5">Höhe/Breite-Verhältniss</label>
<div class="col-xs-7">
<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>
</div>
@ -121,7 +123,8 @@
<label for="tiredia" class="control-label col-xs-5">Felgendurchmesser</label>
<div class="col-xs-7">
<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>
</div>
@ -130,7 +133,8 @@
<label for="pulserev" class="control-label col-xs-5">Pulse pro Umdrehung</label>
<div class="col-xs-7">
<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>
</div>
@ -148,7 +152,7 @@
<div %SHOW_CAN_SETTINGS%>
<h4>Einstellungen CAN-Bus</h4>
<p>
<form class="form-horizontal">
<form action="\post.htm" method="POST" class="form-horizontal">
<div class="form-group">
<label for="cansource" class="control-label col-xs-5">Model</label>
<div class="col-xs-7">
@ -170,7 +174,7 @@
<div %SHOW_GPS_SETTINGS%>
<h4>Einstellungen GPS</h4>
<p>
<form class="form-horizontal">
<form action="\post.htm" method="POST" class="form-horizontal">
<div class="form-group">
<label for="gpsbaud" class="control-label col-xs-5">Baudrate</label>
<div class="col-xs-7">
@ -204,7 +208,7 @@
<h3>Wartung</h3>
<hr>
<p>
<form class="form-horizontal">
<form action="\post.htm" method="POST" class="form-horizontal">
<div class="form-group">
<label for="purgepulse" class="control-label col-xs-5">Impulse</label>
<div class="col-xs-7">
@ -228,7 +232,7 @@
<h3>Öltank</h3>
<hr>
<p>
<form class="form-horizontal">
<form action="\post.htm" method="POST" class="form-horizontal">
<div class="form-group">
<label for="tankcap" class="control-label col-xs-5">Tankkapazität</label>
<div class="col-xs-7">

View 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>

View File

@ -80,7 +80,7 @@ typedef struct
uint32_t DistancePerRevolution_mm = 2000;
uint8_t BleedingPulses = 25;
SpeedSource_t SpeedSource = SOURCE_IMPULSE;
GPSBaudRate_t GPSBaudRate = BAUD_9600;
GPSBaudRate_t GPSBaudRate = BAUD_115200;
#if PCB_REVISION == 13
CANSource_t CANSource = KTM_890_ADV_R_2021;
#endif

View File

@ -18,9 +18,11 @@ void initWebUI()
}
webServer.serveStatic("/static/", LittleFS, "/static/");
webServer.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
{ request->redirect("/index.htm"); });
webServer.onNotFound(WebserverNotFound_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();
}
@ -85,7 +87,10 @@ String processor(const String &var)
{
String temp;
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;
}
@ -93,14 +98,20 @@ String processor(const String &var)
{
String temp;
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;
}
if (var == "GPSBAUD_SELECT_OPTIONS")
{
String temp;
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;
}
@ -120,12 +131,15 @@ void Webserver_Callback(AsyncWebServerRequest *request)
void WebserverPOST_Callback(AsyncWebServerRequest *request)
{
String message;
if (request->hasParam(PARAM_MESSAGE, true))
Serial.print("POST:\n");
int paramsNr = request->params();
for (int i = 0; i < paramsNr; i++)
{
message = request->getParam(PARAM_MESSAGE, true)->value();
Serial.printf("POST: %s", message.c_str());
AsyncWebParameter *p = request->getParam(i);
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)