Snapshot.
This commit is contained in:
parent
458232f08f
commit
8a95413224
|
@ -25,7 +25,7 @@
|
|||
#include <Adafruit_BusIO_Register.h> // for DS3231
|
||||
#include <RTClib.h> // for DS3231
|
||||
//#include <DS3232RTC.h> //for DS3231
|
||||
//#include <sstream>
|
||||
#include <string>
|
||||
|
||||
// download zip from https://github.com/me-no-dev/ESPAsyncWebServer and install.
|
||||
#include <ESPAsyncWebServer.h>
|
||||
|
@ -45,6 +45,7 @@ const char* PARAM_MSG = "inputMsg";
|
|||
const char* PARAM_FLOAT = "inputFloat";
|
||||
const char* PARAM_TIME = "inputTimeUnix";
|
||||
const char* PARAM_START = "inputStartTimeUnix";
|
||||
const char* PARAM_RUNNING = "programRunning";
|
||||
|
||||
// Global variables
|
||||
String yourInputString;
|
||||
|
@ -55,6 +56,7 @@ int yourInputMsg_old; // to save previous state and check changes
|
|||
float yourInputFloat;
|
||||
uint32_t yourInputTime; //to keep time
|
||||
uint32_t yourInputStartTimeUnix;
|
||||
int yourProgramRunning;
|
||||
|
||||
// HTML web page to handle 3 input fields (inputString, inputSend, inputFloat)
|
||||
const char index_html[] PROGMEM = R"rawliteral(
|
||||
|
@ -83,11 +85,11 @@ const char index_html[] PROGMEM = R"rawliteral(
|
|||
</script></head><body>
|
||||
<form action="/get" target="hidden-form" onsubmit="putDate(this);" accept-charset=utf-8>
|
||||
|
||||
Sending program (cycle doesn't work yet) (current value: <b>%inputSend%</b>):
|
||||
<p>Sending program (cycle doesn't work yet) (current value: <b>%inputSend%</b>):
|
||||
<select name="inputSend" id="send-program">
|
||||
<option value="0">0 -Off</option>
|
||||
<option value="1">1 - Continuous</option>
|
||||
<option value="2">2 - Cycle</option>
|
||||
<option value="2">2 - Cycle Program</option>
|
||||
</select><br>
|
||||
|
||||
Message (current value <b>%inputMsg%</b>):
|
||||
|
@ -98,19 +100,24 @@ const char index_html[] PROGMEM = R"rawliteral(
|
|||
<option value="3">3 - MOS</option>
|
||||
<option value="4">4 - MOH</option>
|
||||
<option value="5">5 - MO5</option>
|
||||
</select><br>
|
||||
</select></p>
|
||||
|
||||
Program start time (current value <b><span id = current-start></span></b>): <input type="datetime-local" id="js_start_time_unix_entry" /><br>
|
||||
<input type="hidden" name="inputStartTimeUnix" id="js_start_time_unix" />
|
||||
<p>Current time (UTC): <b>%inputTimeUnix%</b><br>
|
||||
|
||||
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>
|
||||
Program start time (current value <b><span id = current-start></span></b>): <input type="datetime-local" id="js_start_time_unix_entry" />
|
||||
<!-- JS converts the entered start time to a unix timestamp, and copies that value
|
||||
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">
|
||||
|
||||
<!-- 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="hidden" name="inputWPM" value = %inputWPM%>
|
||||
<input type="hidden" name="inputString" value=%inputString%>
|
||||
<input type="hidden" name="inputFloat" value = %inputFloat%>
|
||||
|
||||
<input type="submit" value="Submit"">
|
||||
</form>
|
||||
|
@ -350,6 +357,15 @@ auto morseToSend_blink = morseTEST_blink; // set this up to overwrite later
|
|||
// Serial.println(buf);
|
||||
// }
|
||||
|
||||
//================================================================================
|
||||
// start_program(): a function to start the planned program at the planned time
|
||||
//================================================================================
|
||||
bool start_program(){
|
||||
Serial.println("The scheduled program has started.");
|
||||
yourProgramRunning = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
// setup(): stuff that only gets done once, after power up (KB1OIQ's description)
|
||||
//================================================================================
|
||||
|
@ -485,6 +501,10 @@ void setup() {
|
|||
inputMessage = request->getParam(PARAM_SEND)->value();
|
||||
writeFile(SPIFFS, "/inputSend.txt", inputMessage.c_str());
|
||||
yourInputSend = inputMessage.toInt();
|
||||
// if not running a program, set the program running off
|
||||
if(yourInputSend != 2){
|
||||
yourProgramRunning = 0;
|
||||
}
|
||||
}
|
||||
// GET inputWPM value on <ESP_IP>/get?inputWPM=<inputMessage>
|
||||
if (request->hasParam(PARAM_WPM)) {
|
||||
|
@ -503,7 +523,6 @@ void setup() {
|
|||
// GET inputTimeUnix value on <ESP_IP>/get?inputTimeUnix=<inputMessage>
|
||||
if (request->hasParam(PARAM_TIME)) {
|
||||
inputMessage = request->getParam(PARAM_TIME)->value();
|
||||
Serial.println(inputMessage);
|
||||
//https://stackoverflow.com/a/22733127/2152245
|
||||
yourInputTime = atol(inputMessage.c_str());
|
||||
Serial.println(yourInputTime);
|
||||
|
@ -536,8 +555,12 @@ void setup() {
|
|||
// GET inputStartTimeUnix value on <ESP_IP>/get?inputStartTimeUnix=<inputMessage>
|
||||
if (request->hasParam(PARAM_START)) {
|
||||
inputMessage = request->getParam(PARAM_START)->value();
|
||||
writeFile(SPIFFS, "/inputStartTimeUnix.txt", inputMessage.c_str());
|
||||
yourInputStartTimeUnix = atol(inputMessage.c_str());
|
||||
Serial.println(inputMessage);
|
||||
// if a start time isn't entered, don't overwrite the old one
|
||||
//if(!(inputMessage != NULL && inputMessage[0] == '\0')){
|
||||
writeFile(SPIFFS, "/inputStartTimeUnix.txt", inputMessage.c_str());
|
||||
yourInputStartTimeUnix = atol(inputMessage.c_str());
|
||||
//}
|
||||
Serial.println(yourInputStartTimeUnix);
|
||||
}
|
||||
// else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user