more webui
This commit is contained in:
@@ -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
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user