Change WPM on webform #45

Merged
W1CDN merged 2 commits from wpm into main 2023-09-16 09:17:18 -05:00

View File

@ -136,7 +136,10 @@ const char index_html[] PROGMEM = R"rawliteral(
<option value="3">3 - MOS</option> <option value="3">3 - MOS</option>
<option value="4">4 - MOH</option> <option value="4">4 - MOH</option>
<option value="5">5 - MO5</option> <option value="5">5 - MO5</option>
</select></p> </select><br>
Speed: <input type="number" name="inputWPM" value = %inputWPM%> WPM
</p>
<h2>Cycle Settings</h2> <h2>Cycle Settings</h2>
<p>Only applies when <em>Sending Program</em> is set to "2 - Cycle". You cannot set a cycle start date more than a month in advance.</p> <p>Only applies when <em>Sending Program</em> is set to "2 - Cycle". You cannot set a cycle start date more than a month in advance.</p>
@ -157,7 +160,6 @@ const char index_html[] PROGMEM = R"rawliteral(
<input type="hidden" name="inputTimeUnix" id="js_time_unix"> <input type="hidden" name="inputTimeUnix" id="js_time_unix">
<!-- Extra fields just in case I need them --> <!-- Extra fields just in case I need them -->
<input type="hidden" name="inputWPM" value = %inputWPM%>
<input type="hidden" name="inputString" value = %inputString%> <input type="hidden" name="inputString" value = %inputString%>
<input type="hidden" name="inputFloat" value = %inputFloat%> <input type="hidden" name="inputFloat" value = %inputFloat%>
@ -245,15 +247,8 @@ String processor(const String& var){
// Set up arduinomorse pin and default WPM // Set up arduinomorse pin and default WPM
LEDMorseSender sender_blink(blinker, 10.0f) ; // the 'f' makes sure this is a float LEDMorseSender sender_blink(blinker, 10.0f); //f makes it a float
LEDMorseSender sender_key(keyer, 10.0f) ; // the 'f' makes sure this is a float LEDMorseSender sender_key(keyer, 10.0f);
// 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;
//================================================================================ //================================================================================
// setup(): stuff that only gets done once, after power up (KB1OIQ's description) // setup(): stuff that only gets done once, after power up (KB1OIQ's description)
@ -315,13 +310,16 @@ void setup() {
// Read in existing data // Read in existing data
yourInputString = readFile(SPIFFS, "/inputString.txt"); yourInputString = readFile(SPIFFS, "/inputString.txt");
yourInputSend = readFile(SPIFFS, "/inputSend.txt").toInt(); yourInputSend = readFile(SPIFFS, "/inputSend.txt").toInt();
yourInputWPM = readFile(SPIFFS, "/inputWPM.txt").toInt(); yourInputWPM = readFile(SPIFFS, "/inputWPM.txt").toFloat();
yourInputMsg = readFile(SPIFFS, "/inputMsg.txt").toInt(); yourInputMsg = readFile(SPIFFS, "/inputMsg.txt").toInt();
yourInputFloat = readFile(SPIFFS, "/inputFloat.txt").toFloat(); yourInputFloat = readFile(SPIFFS, "/inputFloat.txt").toFloat();
yourInputStartTimeUnix = readFile(SPIFFS, "/inputStartTimeUnix.txt").toInt(); yourInputStartTimeUnix = readFile(SPIFFS, "/inputStartTimeUnix.txt").toInt();
yourInputStepLength = readFile(SPIFFS, "/inputStepLength.txt").toInt(); yourInputStepLength = readFile(SPIFFS, "/inputStepLength.txt").toInt();
yourInputCycleID = readFile(SPIFFS, "/inputCycleID.txt").toInt(); yourInputCycleID = readFile(SPIFFS, "/inputCycleID.txt").toInt();
yourInputNtransmitters = readFile(SPIFFS, "/inputNtransmitters.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 // On restart, keep doing what you were doing before
yourInputMsg_old = yourInputMsg; yourInputMsg_old = yourInputMsg;
@ -385,7 +383,9 @@ void setup() {
if (request->hasParam(PARAM_WPM)) { if (request->hasParam(PARAM_WPM)) {
inputMessage = request->getParam(PARAM_WPM)->value(); inputMessage = request->getParam(PARAM_WPM)->value();
writeFile(SPIFFS, "/inputWPM.txt", inputMessage.c_str()); 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 <ESP_IP>/get?inputMsg=<inputMessage> // GET inputMsg value on <ESP_IP>/get?inputMsg=<inputMessage>
if (request->hasParam(PARAM_MSG)) { if (request->hasParam(PARAM_MSG)) {