diff --git a/vulpes/src/main.cpp b/vulpes/src/main.cpp index 3aba681..7c48b99 100644 --- a/vulpes/src/main.cpp +++ b/vulpes/src/main.cpp @@ -35,11 +35,15 @@ 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_FLOAT = "inputFloat"; // Global variables String yourInputString; int yourInputSend; +int yourInputWPM; +int yourInputMsg; float yourInputFloat; // HTML web page to handle 3 input fields (inputString, inputSend, inputFloat) @@ -56,13 +60,25 @@ const char index_html[] PROGMEM = R"rawliteral(
@@ -100,11 +116,6 @@ bool toggle_gpio_26(void *) { return true; // keep timer active? true } -// defaults -// String yourInputString; -// int yourInputSend; -// float yourInputFloat; - void notFound(AsyncWebServerRequest *request) { request->send(404, "text/plain", "Not found"); } @@ -150,6 +161,12 @@ String processor(const String& var){ else if(var == "inputSend"){ return readFile(SPIFFS, "/inputSend.txt"); } + else if(var == "inputWPM"){ + return readFile(SPIFFS, "/inputWPM.txt"); + } + else if(var == "inputMsg"){ + return readFile(SPIFFS, "/inputMsg.txt"); + } else if(var == "inputFloat"){ return readFile(SPIFFS, "/inputFloat.txt"); } @@ -244,9 +261,29 @@ class MorseEffect : public jled::BrightnessEvaluator { // Speed is milliseconds per dit, which is 1000 * (60 / (50 * WPM)) // 60 is 20 wpm, 120 is 10 wpm, 90 is 15 wpm, etc. // https://morsecode.world/international/timing.html -MorseEffect morseEffect("CQ CQ CQ DE W1CDN", 120); -auto morseLed = - JLed(output26).UserFunc(&morseEffect).DelayAfter(2000).Forever(); +int wpm = 10; +int ms_per_dit = 120; //1000 * (60 / (50 * wpm)); +int word_space_ms = ms_per_dit * 7; +// Hardcoding these for now, will come back and make it more flexible. +MorseEffect morseEffect("CQ CQ CQ DE W1CDN", ms_per_dit); +MorseEffect morseEffectMOE("MOE", ms_per_dit); +MorseEffect morseEffectMOI("MOI", ms_per_dit); +MorseEffect morseEffectMOS("MOS", ms_per_dit); +MorseEffect morseEffectMOH("MOH", ms_per_dit); +MorseEffect morseEffectMO5("MO5", ms_per_dit); + +auto morseCQ = + JLed(output26).UserFunc(&morseEffect).DelayAfter(word_space_ms).Forever(); +auto morseMOE = + JLed(output26).UserFunc(&morseEffectMOE).DelayAfter(word_space_ms).Forever(); +auto morseMOI = + JLed(output26).UserFunc(&morseEffectMOI).DelayAfter(word_space_ms).Forever(); +auto morseMOS = + JLed(output26).UserFunc(&morseEffectMOS).DelayAfter(word_space_ms).Forever(); +auto morseMOH = + JLed(output26).UserFunc(&morseEffectMOH).DelayAfter(word_space_ms).Forever(); +auto morseMO5 = + JLed(output26).UserFunc(&morseEffectMO5).DelayAfter(word_space_ms).Forever(); //================================================================================ // setup(): stuff that only gets done once, after power up (KB1OIQ's description) @@ -282,9 +319,29 @@ void setup() { } //#endif + // Make sure files exist, maybe with defaults here + // if(SPIFFS.exists("/inputString.txt") == 0){ + // writeFile(SPIFFS, "/inputString.txt", "CQ"); + // } + // if(SPIFFS.exists("/inputSend.txt") == 0){ + // writeFile(SPIFFS, "/inputSend.txt", "0"); + // } + // if(SPIFFS.exists("/inputWPM.txt") == 0){ + // writeFile(SPIFFS, "/inputWPM.txt", "10"); + // } + // if(SPIFFS.exists("/inputMsg.txt") == 0){ + // writeFile(SPIFFS, "/inputMsg.txt", "0"); + // } + // if(SPIFFS.exists("/inputFloat.txt") == 0){ + // writeFile(SPIFFS, "/inputFloat.txt", "1.1"); + // } + + // Read in existing data yourInputString = readFile(SPIFFS, "/inputString.txt"); yourInputSend = readFile(SPIFFS, "/inputSend.txt").toInt(); + yourInputWPM = readFile(SPIFFS, "/inputWPM.txt").toInt(); + yourInputMsg = readFile(SPIFFS, "/inputMsg.txt").toInt(); yourInputFloat = readFile(SPIFFS, "/inputFloat.txt").toFloat(); WiFi.mode(WIFI_STA); @@ -317,6 +374,18 @@ void setup() { writeFile(SPIFFS, "/inputSend.txt", inputMessage.c_str()); yourInputSend = inputMessage.toInt(); } + // GET inputWPM value on