diff --git a/vulpes/src/main.cpp b/vulpes/src/main.cpp index 8de70ea..9d019fc 100644 --- a/vulpes/src/main.cpp +++ b/vulpes/src/main.cpp @@ -38,10 +38,10 @@ const int alarmPin = 4; // pin to monitor for RTC alarms const char* ssid = WIFI_SSID; const char* password = WIFI_PASSWORD; -const char* PARAM_STRING = "inputString"; const char* PARAM_SEND = "inputSend"; const char* PARAM_WPM = "inputWPM"; const char* PARAM_MSG = "inputMsg"; +const char* PARAM_CMSG = "inputCustomMsg"; const char* PARAM_FLOAT = "inputFloat"; const char* PARAM_TIME = "inputTimeUnix"; const char* PARAM_START = "inputStartTimeUnix"; @@ -51,11 +51,11 @@ const char* PARAM_CYCLEID = "inputCycleID"; const char* PARAM_NTRANS = "inputNtransmitters"; // Global variables -String yourInputString; int yourInputSend; int yourInputWPM; int yourInputMsg; int yourInputMsg_old; // to save previous state and check changes +String yourInputCustomMsg; float yourInputFloat; uint32_t yourInputTime; //to keep time uint32_t yourInputStartTimeUnix; @@ -68,7 +68,7 @@ long start_millis = 0; long stop_millis = 0; long pause_until_millis = 0; -// HTML web page to handle 3 input fields (inputString, inputSend, inputFloat) +// HTML web page to handle input fields const char index_html[] PROGMEM = R"rawliteral( @@ -130,13 +130,15 @@ const char index_html[] PROGMEM = R"rawliteral( Message:
+ + Custom message:
Speed: WPM

@@ -160,7 +162,6 @@ const char index_html[] PROGMEM = R"rawliteral( - @@ -211,8 +212,8 @@ void writeFile(fs::FS &fs, const char * path, const char * message){ // Replaces placeholder in web UI with stored values String processor(const String& var){ //Serial.println(var); - if(var == "inputString"){ - return readFile(SPIFFS, "/inputString.txt"); + if(var == "inputCustomMsg"){ + return readFile(SPIFFS, "/inputCustomMsg.txt"); } else if(var == "inputSend"){ return readFile(SPIFFS, "/inputSend.txt"); @@ -308,7 +309,7 @@ void setup() { } // Read in existing data - yourInputString = readFile(SPIFFS, "/inputString.txt"); + yourInputCustomMsg = readFile(SPIFFS, "/inputCustomMsg.txt"); yourInputSend = readFile(SPIFFS, "/inputSend.txt").toInt(); yourInputWPM = readFile(SPIFFS, "/inputWPM.txt").toFloat(); yourInputMsg = readFile(SPIFFS, "/inputMsg.txt").toInt(); @@ -324,8 +325,8 @@ void setup() { // On restart, keep doing what you were doing before yourInputMsg_old = yourInputMsg; if(yourInputMsg == 0){ - sender_blink.setMessage(String("test test test de w1cdn ")); - sender_key.setMessage(String("test test test de w1cdn ")); + sender_blink.setMessage(yourInputCustomMsg); + sender_key.setMessage(yourInputCustomMsg); } else if(yourInputMsg == 1){ sender_blink.setMessage(String("moe ")); sender_key.setMessage(String("moe ")); @@ -358,14 +359,17 @@ void setup() { request->send_P(200, "text/html", index_html, processor); }); - // Send a GET request to /get?inputString= + // Send a GET request to /get?inputCustomMsg= server.on("/get", HTTP_GET, [] (AsyncWebServerRequest *request) { String inputMessage; - // GET inputString value on /get?inputString= - if (request->hasParam(PARAM_STRING)) { - inputMessage = request->getParam(PARAM_STRING)->value(); - writeFile(SPIFFS, "/inputString.txt", inputMessage.c_str()); - yourInputString = inputMessage; + // GET inputCustomMsg value on /get?inputCustomMsg= + if (request->hasParam(PARAM_CMSG)) { + inputMessage = request->getParam(PARAM_CMSG)->value(); + // arduinomorse needs lowercase characters + std::transform(inputMessage.begin(), inputMessage.end(), inputMessage.begin(), ::tolower); + writeFile(SPIFFS, "/inputCustomMsg.txt", inputMessage.c_str()); + yourInputCustomMsg = inputMessage; + } // GET inputSend value on /get?inputSend= if (request->hasParam(PARAM_SEND)) { @@ -397,8 +401,8 @@ void setup() { // Check the message every time the form is submitted. if(yourInputMsg == 0){ - sender_blink.setMessage(String("test test test de w1cdn ")); - sender_key.setMessage(String("test test test de w1cdn ")); + sender_blink.setMessage(yourInputCustomMsg); + sender_key.setMessage(yourInputCustomMsg); } else if(yourInputMsg == 1){ sender_blink.setMessage(String("moe ")); sender_key.setMessage(String("moe "));