Set up scheduled program cycles #24

Merged
W1CDN merged 41 commits from program-cycle into main 2023-09-15 16:51:45 -05:00
Showing only changes of commit 90b3137165 - Show all commits

View File

@ -61,32 +61,31 @@ int yourProgramRunning;
// HTML web page to handle 3 input fields (inputString, inputSend, inputFloat)
const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE HTML><html><head>
<link rel="icon" href="data:,">
<title>ESP Input Form</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript">
console.log("JS");
// Submit timestamps as unix seconds
var putDate = function(form) {
console.log("putDate");
form.inputTimeUnix.value = Math.floor(Date.now() / 1000) - new Date().getTimezoneOffset()*60;
document.getElementById("js_start_time_unix").value = ((Date.parse(js_start_time_unix_entry.value))/1000);
form.inputStartTimeUnix.value = ((Date.parse(js_start_time_unix_entry.value))/1000);
//document.getElementById("js_start_time_unix").value = ((Date.parse(js_start_time_unix_entry.value))/1000);
}
// Refresh page after submit so values are right https://stackoverflow.com/a/1860732/2152245
window.onload = function() {
document.getElementById("hidden-form").onload = function() {
top.location.reload();
console.log("Reloading");
}
// Current start date to string
s = %inputStartTimeUnix%;
//s = "1694019170";
console.log(s);
current_start = new Date(s * 1000);
//current_start_utc = current_start.toUTCString();
document.getElementById('current-start').innerHTML = current_start.toString();
// Show the local time
local_time_unix = new Date().toString();
document.getElementById('local-time-unix').innerHTML = local_time_unix.toString();
// fill in the start time field
document.getElementById('js_start_time_unix_entry').value = current_start.toISOString().slice(0,16);
}
</script></head><body>
@ -118,7 +117,6 @@ const char index_html[] PROGMEM = R"rawliteral(
to this hidden field so the user doesn't have to see it. -->
<input type="hidden" name="inputStartTimeUnix" id="js_start_time_unix" /></p>
<!-- This field is hidden so people don't change the submit time (it will be wrong).
The value is automatically filled in with JS. -->
<input type="hidden" name="inputTimeUnix" id="js_time_unix">
@ -131,6 +129,9 @@ const char index_html[] PROGMEM = R"rawliteral(
<input type="submit" value="Submit"">
</form>
<iframe style="display:none" name="hidden-form" id="hidden-form"></iframe>
<script type="text/javascript">
</script>
</body></html>)rawliteral";
// Auxiliary variables to store the current output state
@ -218,6 +219,7 @@ String processor(const String& var){
else if(var == "inputFloat"){
return readFile(SPIFFS, "/inputFloat.txt");
} else if(var == "inputStartTimeUnix"){
// Webform breaks if this value is empty.
String temp = readFile(SPIFFS, "/inputStartTimeUnix.txt");
if(temp == ""){
temp = "0";