From e68a0b4d3e49a0308910ce1fb63333fc5883b74f Mon Sep 17 00:00:00 2001
From: Marcel Peterkau
Date: Tue, 8 Mar 2022 21:23:52 +0100
Subject: [PATCH] more progress on webUI
---
Software/ChainLube/data/index.htm | 53 +++++++++++++++++++++++--------
Software/ChainLube/data/post.htm | 31 ++++++++++++++----
Software/ChainLube/src/webui.cpp | 52 +++++++++++++++++++++++++++---
3 files changed, 113 insertions(+), 23 deletions(-)
diff --git a/Software/ChainLube/data/index.htm b/Software/ChainLube/data/index.htm
index bef0bdc..a60db98 100644
--- a/Software/ChainLube/data/index.htm
+++ b/Software/ChainLube/data/index.htm
@@ -89,10 +89,15 @@
+
+ Achtung!
+ Bei Änderung der Wegstrecken-Quelle wird der CAN-Oiler neu gestartet.
+ Dadurch wird die WiFi-Verbindung getrennt und muss neu aufgebaut werden.
+
@@ -163,7 +168,7 @@
@@ -185,7 +190,7 @@
@@ -210,17 +215,36 @@
+
+
+
@@ -237,7 +261,8 @@
Tankkapazität
@@ -246,8 +271,9 @@
Leer-Warnung
@@ -255,14 +281,15 @@
Menge pro Puls
diff --git a/Software/ChainLube/data/post.htm b/Software/ChainLube/data/post.htm
index 17a7795..a9c73c6 100644
--- a/Software/ChainLube/data/post.htm
+++ b/Software/ChainLube/data/post.htm
@@ -1,9 +1,28 @@
-
-
-
-
- Processing...
-
+
+
+
+ KTM CAN Chain Oiler
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Bitte warten! Änderungen werden übernommen.
+
+
+
+
\ No newline at end of file
diff --git a/Software/ChainLube/src/webui.cpp b/Software/ChainLube/src/webui.cpp
index 2126035..6cf16c2 100644
--- a/Software/ChainLube/src/webui.cpp
+++ b/Software/ChainLube/src/webui.cpp
@@ -66,7 +66,11 @@ String processor(const String &var)
return String(CANSourceString[LubeConfig.CANSource]);
#endif
if (var == "CONFIG_CHECKSUM")
- return String(LubeConfig.checksum, 16);
+ {
+ char buffer[7];
+ sprintf(buffer, "0x%04X", LubeConfig.checksum);
+ return String(buffer);
+ }
if (var == "WRITE_CYCLE_COUNT")
return String(PersistenceData.writeCycleCounter);
if (var == "TANK_REMAIN_UL")
@@ -74,8 +78,11 @@ String processor(const String &var)
if (var == "TRAVEL_DISTANCE_HIGHRES")
return String(PersistenceData.TravelDistance_highRes);
if (var == "PERSISTANCE_CHECKSUM")
- return String(PersistenceData.checksum, 16);
-
+ {
+ char buffer[7];
+ sprintf(buffer, "0x%04X", PersistenceData.checksum);
+ return String(buffer);
+ }
if (var == "SHOW_IMPULSE_SETTINGS")
return LubeConfig.SpeedSource == SOURCE_IMPULSE ? "" : "hidden";
if (var == "SHOW_CAN_SETTINGS")
@@ -137,8 +144,45 @@ void WebserverPOST_Callback(AsyncWebServerRequest *request)
{
AsyncWebParameter *p = request->getParam(i);
Serial.printf("%s : %s\n", p->name().c_str(), p->value().c_str());
- }
+ // begin: POST Form Source Changed
+ if (p->name() == "sourceselect")
+ {
+ SpeedSource_t temp = (SpeedSource_t)p->value().toInt();
+ Serial.printf("temp: %d", temp);
+ Serial.printf("SpeedSource: %d", LubeConfig.SpeedSource);
+ if (LubeConfig.SpeedSource != temp)
+ {
+ LubeConfig.SpeedSource = temp;
+ globals.systemStatus = sysStat_Shutdown;
+ }
+ }
+ // end: POST Form Source Changed
+ // begin: POST Form Source Pulse Settings
+ if (p->name() == "tirewidth")
+ LubeConfig.TireWidth_mm = p->value().toInt();
+ if (p->name() == "tireratio")
+ LubeConfig.TireWidthHeight_Ratio = p->value().toInt();
+ if (p->name() == "tiredia")
+ LubeConfig.RimDiameter_Inch = p->value().toInt();
+ if (p->name() == "pulserev")
+ LubeConfig.PulsePerRevolution = p->value().toInt();
+ if (p->name() == "pulsesave")
+ globals.requestEEAction = EE_CFG_SAVE;
+ // end: POST Form Source Pulse Settings
+ // begin: POST Form Source GPS Settings
+ if (p->name() == "gpsbaud")
+ LubeConfig.GPSBaudRate = (GPSBaudRate_t)p->value().toInt();
+ if (p->name() == "gpssave")
+ globals.requestEEAction = EE_CFG_SAVE;
+ // end: POST Form Source GPS Settings
+ // begin: POST Form Source CAN Settings
+ if (p->name() == "cansource")
+ LubeConfig.CANSource = (CANSource_t)p->value().toInt();
+ if (p->name() == "cansave")
+ globals.requestEEAction = EE_CFG_SAVE;
+ // end: POST Form Source CAN Settings
+ }
request->send(LittleFS, "/post.htm", String(), false, processor);
}