diff --git a/vulpes/src/main.cpp b/vulpes/src/main.cpp index 46c2ae7..f4c06c1 100644 --- a/vulpes/src/main.cpp +++ b/vulpes/src/main.cpp @@ -25,7 +25,7 @@ #include // for DS3231 #include // for DS3231 //#include //for DS3231 -//#include +#include // download zip from https://github.com/me-no-dev/ESPAsyncWebServer and install. #include @@ -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(
- Sending program (cycle doesn't work yet) (current value: %inputSend%): +

Sending program (cycle doesn't work yet) (current value: %inputSend%):
Message (current value %inputMsg%): @@ -98,19 +100,24 @@ const char index_html[] PROGMEM = R"rawliteral( -
+

- Program start time (current value ):
- +

Current time (UTC): %inputTimeUnix%
+ + Program start time (current value ): + +

- Current time (UTC): %inputTimeUnix% - -
+ + + -
-
-
+ + +
@@ -205,7 +212,7 @@ String processor(const String& var){ return rtc.now().timestamp(); } else if(var == "inputStartTimeUnix"){ return readFile(SPIFFS, "/inputStartTimeUnix.txt"); - } + } return String(); } @@ -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 /get?inputWPM= if (request->hasParam(PARAM_WPM)) { @@ -503,7 +523,6 @@ void setup() { // GET inputTimeUnix value on /get?inputTimeUnix= 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 /get?inputStartTimeUnix= 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 {