From c65bc22028f5edaf36046c7c92256cbcb2fbb0fb Mon Sep 17 00:00:00 2001 From: mattbk Date: Mon, 4 Sep 2023 21:53:09 -0500 Subject: [PATCH] Shelve. Collect unix time from webform, but need to make sure it is UTC. --- vulpes/src/main.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/vulpes/src/main.cpp b/vulpes/src/main.cpp index 09210a8..9c2b0f4 100644 --- a/vulpes/src/main.cpp +++ b/vulpes/src/main.cpp @@ -44,6 +44,7 @@ const char* PARAM_WPM = "inputWPM"; const char* PARAM_MSG = "inputMsg"; const char* PARAM_FLOAT = "inputFloat"; const char* PARAM_TIME = "inputTimeUnix"; +const char* PARAM_START = "inputStartTimeUnix"; // Global variables String yourInputString; @@ -53,6 +54,7 @@ int yourInputMsg; int yourInputMsg_old; // to save previous state and check changes float yourInputFloat; uint32_t yourInputTime; //to keep time +uint32_t yourInputStartTimeUnix; // HTML web page to handle 3 input fields (inputString, inputSend, inputFloat) const char index_html[] PROGMEM = R"rawliteral( @@ -65,8 +67,7 @@ const char index_html[] PROGMEM = R"rawliteral( };
- inputString (current value %inputString%):
- + Sending program (cycle doesn't work yet) (current value: %inputSend%):
- - WPM (current value %inputWPM%): (doesn't work yet)
+ Program start time (current value %inputStartTimeUnix%):
+ + Current time (UTC): %inputTimeUnix% +
- inputFloat (current value %inputFloat%):
+ +
+
+
+
+ )rawliteral"; // Auxiliary variables to store the current output state @@ -181,6 +191,8 @@ String processor(const String& var){ return readFile(SPIFFS, "/inputFloat.txt"); } else if(var == "inputTimeUnix"){ return rtc.now().timestamp(); + } else if(var == "inputStartTimeUnix"){ + return readFile(SPIFFS, "/inputStartTimeUnix.txt"); } return String(); } @@ -508,6 +520,14 @@ void setup() { writeFile(SPIFFS, "/inputFloat.txt", inputMessage.c_str()); yourInputFloat = inputMessage.toFloat(); } + // GET inputStartTimeUnix value on /get?inputStartTimeUnix= + if (request->hasParam(PARAM_START)) { + inputMessage = request->getParam(PARAM_START)->value(); + Serial.println(inputMessage); + writeFile(SPIFFS, "/inputStartTimeUnix.txt", inputMessage.c_str()); + yourInputStartTimeUnix = atol(inputMessage.c_str()); + Serial.println(yourInputStartTimeUnix); + } // else { // inputMessage = "No message sent"; // }