Set up scheduled program cycles #24
|
@ -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(
|
|||
};
|
||||
</script></head><body>
|
||||
<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>):
|
||||
<select name="inputSend" id="send-program">
|
||||
<option value="0">0 -Off</option>
|
||||
|
@ -83,16 +84,25 @@ const char index_html[] PROGMEM = R"rawliteral(
|
|||
<option value="4">4 - MOH</option>
|
||||
<option value="5">5 - MO5</option>
|
||||
</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%
|
||||
<!-- This field is hidden so people don't change it (it will be wrong) -->
|
||||
<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"">
|
||||
</form>
|
||||
<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";
|
||||
|
||||
// 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 <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 {
|
||||
// inputMessage = "No message sent";
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue
Block a user