From f4287eba7b0edb88ade4340c13993f62ea46d31a Mon Sep 17 00:00:00 2001 From: mattbk Date: Fri, 15 Sep 2023 21:44:19 -0500 Subject: [PATCH 1/2] Control WPM from webform. --- vulpes/src/main.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/vulpes/src/main.cpp b/vulpes/src/main.cpp index 2fdae51..54d7474 100644 --- a/vulpes/src/main.cpp +++ b/vulpes/src/main.cpp @@ -67,6 +67,8 @@ int yourInputNtransmitters; long start_millis = 0; long stop_millis = 0; long pause_until_millis = 0; +float wpm = 10; +float ms_per_dit = 1000 * (60 / (50 * wpm)); // HTML web page to handle 3 input fields (inputString, inputSend, inputFloat) const char index_html[] PROGMEM = R"rawliteral( @@ -136,7 +138,10 @@ const char index_html[] PROGMEM = R"rawliteral( -

+
+ + Speed: WPM +

Cycle Settings

Only applies when Sending Program is set to "2 - Cycle". You cannot set a cycle start date more than a month in advance.

@@ -157,7 +162,6 @@ const char index_html[] PROGMEM = R"rawliteral( - @@ -245,15 +249,8 @@ String processor(const String& var){ // Set up arduinomorse pin and default WPM -LEDMorseSender sender_blink(blinker, 10.0f) ; // the 'f' makes sure this is a float -LEDMorseSender sender_key(keyer, 10.0f) ; // the 'f' makes sure this is a float - -// 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 -float wpm = 10; -float ms_per_dit = 1000 * (60 / (50 * wpm)); -int word_space_ms = ms_per_dit * 7; +LEDMorseSender sender_blink(blinker, wpm); +LEDMorseSender sender_key(keyer, wpm); //================================================================================ // setup(): stuff that only gets done once, after power up (KB1OIQ's description) @@ -322,6 +319,9 @@ void setup() { yourInputStepLength = readFile(SPIFFS, "/inputStepLength.txt").toInt(); yourInputCycleID = readFile(SPIFFS, "/inputCycleID.txt").toInt(); yourInputNtransmitters = readFile(SPIFFS, "/inputNtransmitters.txt").toInt(); + // Set WPM from saved value + sender_blink.setWPM(yourInputWPM); + sender_key.setWPM(yourInputWPM); // On restart, keep doing what you were doing before yourInputMsg_old = yourInputMsg; @@ -385,7 +385,9 @@ void setup() { if (request->hasParam(PARAM_WPM)) { inputMessage = request->getParam(PARAM_WPM)->value(); writeFile(SPIFFS, "/inputWPM.txt", inputMessage.c_str()); - yourInputWPM = inputMessage.toInt(); + yourInputWPM = inputMessage.toFloat(); + sender_blink.setWPM(yourInputWPM); + sender_key.setWPM(yourInputWPM); } // GET inputMsg value on /get?inputMsg= if (request->hasParam(PARAM_MSG)) { -- 2.30.2 From d973bbf19ad60f7d293be79a0d0f0340b85c860c Mon Sep 17 00:00:00 2001 From: mattbk Date: Sat, 16 Sep 2023 09:16:35 -0500 Subject: [PATCH 2/2] Clean up. --- vulpes/src/main.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/vulpes/src/main.cpp b/vulpes/src/main.cpp index 54d7474..8de70ea 100644 --- a/vulpes/src/main.cpp +++ b/vulpes/src/main.cpp @@ -67,8 +67,6 @@ int yourInputNtransmitters; long start_millis = 0; long stop_millis = 0; long pause_until_millis = 0; -float wpm = 10; -float ms_per_dit = 1000 * (60 / (50 * wpm)); // HTML web page to handle 3 input fields (inputString, inputSend, inputFloat) const char index_html[] PROGMEM = R"rawliteral( @@ -249,8 +247,8 @@ String processor(const String& var){ // Set up arduinomorse pin and default WPM -LEDMorseSender sender_blink(blinker, wpm); -LEDMorseSender sender_key(keyer, wpm); +LEDMorseSender sender_blink(blinker, 10.0f); //f makes it a float +LEDMorseSender sender_key(keyer, 10.0f); //================================================================================ // setup(): stuff that only gets done once, after power up (KB1OIQ's description) @@ -312,7 +310,7 @@ void setup() { // Read in existing data yourInputString = readFile(SPIFFS, "/inputString.txt"); yourInputSend = readFile(SPIFFS, "/inputSend.txt").toInt(); - yourInputWPM = readFile(SPIFFS, "/inputWPM.txt").toInt(); + yourInputWPM = readFile(SPIFFS, "/inputWPM.txt").toFloat(); yourInputMsg = readFile(SPIFFS, "/inputMsg.txt").toInt(); yourInputFloat = readFile(SPIFFS, "/inputFloat.txt").toFloat(); yourInputStartTimeUnix = readFile(SPIFFS, "/inputStartTimeUnix.txt").toInt(); -- 2.30.2