Set up scheduled program cycles #24
|
@ -44,6 +44,7 @@ const char* PARAM_WPM = "inputWPM";
|
||||||
const char* PARAM_MSG = "inputMsg";
|
const char* PARAM_MSG = "inputMsg";
|
||||||
const char* PARAM_FLOAT = "inputFloat";
|
const char* PARAM_FLOAT = "inputFloat";
|
||||||
const char* PARAM_TIME = "inputTimeUnix";
|
const char* PARAM_TIME = "inputTimeUnix";
|
||||||
|
const char* PARAM_START = "inputStartTimeUnix";
|
||||||
|
|
||||||
// Global variables
|
// Global variables
|
||||||
String yourInputString;
|
String yourInputString;
|
||||||
|
@ -53,6 +54,7 @@ int yourInputMsg;
|
||||||
int yourInputMsg_old; // to save previous state and check changes
|
int yourInputMsg_old; // to save previous state and check changes
|
||||||
float yourInputFloat;
|
float yourInputFloat;
|
||||||
uint32_t yourInputTime; //to keep time
|
uint32_t yourInputTime; //to keep time
|
||||||
|
uint32_t yourInputStartTimeUnix;
|
||||||
|
|
||||||
// HTML web page to handle 3 input fields (inputString, inputSend, inputFloat)
|
// HTML web page to handle 3 input fields (inputString, inputSend, inputFloat)
|
||||||
const char index_html[] PROGMEM = R"rawliteral(
|
const char index_html[] PROGMEM = R"rawliteral(
|
||||||
|
@ -65,7 +67,6 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||||
};
|
};
|
||||||
</script></head><body>
|
</script></head><body>
|
||||||
<form action="/get" target="hidden-form" onsubmit="putDate(this);">
|
<form action="/get" target="hidden-form" onsubmit="putDate(this);">
|
||||||
inputString (current value %inputString%): <input type="text" name="inputString" value=%inputString%><br>
|
|
||||||
|
|
||||||
Sending program (cycle doesn't work yet) (current value: <b>%inputSend%</b>):
|
Sending program (cycle doesn't work yet) (current value: <b>%inputSend%</b>):
|
||||||
<select name="inputSend" id="send-program">
|
<select name="inputSend" id="send-program">
|
||||||
|
@ -84,15 +85,24 @@ const char index_html[] PROGMEM = R"rawliteral(
|
||||||
<option value="5">5 - MO5</option>
|
<option value="5">5 - MO5</option>
|
||||||
</select><br>
|
</select><br>
|
||||||
|
|
||||||
WPM (current value %inputWPM%): <input type="number " name="inputWPM" value = %inputWPM%> (doesn't work yet)<br>
|
Program start time (current value <b>%inputStartTimeUnix%</b>): <input type="datetime-local" id="js_start_time_unix_entry" /><br>
|
||||||
|
<input type="hidden" name="inputStartTimeUnix" id="js_start_time_unix" />
|
||||||
|
|
||||||
Current time (UTC): %inputTimeUnix%
|
Current time (UTC): %inputTimeUnix%
|
||||||
|
<!-- This field is hidden so people don't change it (it will be wrong) -->
|
||||||
<input type="hidden" name="inputTimeUnix" id="js_time_unix"><br>
|
<input type="hidden" name="inputTimeUnix" id="js_time_unix"><br>
|
||||||
|
|
||||||
inputFloat (current value %inputFloat%): <input type="number " name="inputFloat" value = %inputFloat%><br>
|
<!-- Extra fields just in case I need them -->
|
||||||
|
<input type="hidden" name="inputWPM" value = %inputWPM%><br>
|
||||||
|
<input type="hidden" name="inputString" value=%inputString%><br>
|
||||||
|
<input type="hidden" name="inputFloat" value = %inputFloat%><br>
|
||||||
|
|
||||||
<input type="submit" value="Submit"">
|
<input type="submit" value="Submit"">
|
||||||
</form>
|
</form>
|
||||||
<iframe style="display:none" name="hidden-form"></iframe>
|
<iframe style="display:none" name="hidden-form"></iframe>
|
||||||
|
<script>
|
||||||
|
document.getElementById("js_start_time_unix").value = (Date.parse(js_start_time_unix_entry.value))/1000;
|
||||||
|
</script>
|
||||||
</body></html>)rawliteral";
|
</body></html>)rawliteral";
|
||||||
|
|
||||||
// Auxiliary variables to store the current output state
|
// Auxiliary variables to store the current output state
|
||||||
|
@ -181,6 +191,8 @@ String processor(const String& var){
|
||||||
return readFile(SPIFFS, "/inputFloat.txt");
|
return readFile(SPIFFS, "/inputFloat.txt");
|
||||||
} else if(var == "inputTimeUnix"){
|
} else if(var == "inputTimeUnix"){
|
||||||
return rtc.now().timestamp();
|
return rtc.now().timestamp();
|
||||||
|
} else if(var == "inputStartTimeUnix"){
|
||||||
|
return readFile(SPIFFS, "/inputStartTimeUnix.txt");
|
||||||
}
|
}
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
@ -508,6 +520,14 @@ void setup() {
|
||||||
writeFile(SPIFFS, "/inputFloat.txt", inputMessage.c_str());
|
writeFile(SPIFFS, "/inputFloat.txt", inputMessage.c_str());
|
||||||
yourInputFloat = inputMessage.toFloat();
|
yourInputFloat = inputMessage.toFloat();
|
||||||
}
|
}
|
||||||
|
// GET inputStartTimeUnix value on <ESP_IP>/get?inputStartTimeUnix=<inputMessage>
|
||||||
|
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 {
|
// else {
|
||||||
// inputMessage = "No message sent";
|
// inputMessage = "No message sent";
|
||||||
// }
|
// }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user