Snapshot.
This commit is contained in:
parent
b0be20087c
commit
50eaf8e973
|
@ -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(
|
|||
<form action="/get" target="hidden-form">
|
||||
inputString (current value %inputString%): <input type="text" name="inputString" value=%inputString%><br>
|
||||
|
||||
Sending program:
|
||||
Sending program (cycle doesn't work yet):
|
||||
<select name="inputSend" id="send-program">
|
||||
<option value="0">Off</option>
|
||||
<option value="1">Continuous</option>
|
||||
<option value="2">Cycle</option>
|
||||
</select><br>
|
||||
|
||||
Message:
|
||||
<select name="inputMsg" id="message">
|
||||
<option value="0">CQ CQ CQ DE W1CDN</option>
|
||||
<option value="1">MOE</option>
|
||||
<option value="2">MOI</option>
|
||||
<option value="3">MOS</option>
|
||||
<option value="4">MOH</option>
|
||||
<option value="5">MO5</option>
|
||||
</select><br>
|
||||
|
||||
WPM (current value %inputWPM%): <input type="number " name="inputWPM" value = %inputWPM%> (doesn't work yet)<br>
|
||||
|
||||
inputFloat (current value %inputFloat%): <input type="number " name="inputFloat" value = %inputFloat%><br>
|
||||
<input type="submit" value="Submit" onclick="submitMessage()">
|
||||
</form>
|
||||
|
@ -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 <ESP_IP>/get?inputWPM=<inputMessage>
|
||||
if (request->hasParam(PARAM_WPM)) {
|
||||
inputMessage = request->getParam(PARAM_WPM)->value();
|
||||
writeFile(SPIFFS, "/inputWPM.txt", inputMessage.c_str());
|
||||
yourInputWPM = inputMessage.toInt();
|
||||
}
|
||||
// GET inputMsg value on <ESP_IP>/get?inputMsg=<inputMessage>
|
||||
if (request->hasParam(PARAM_MSG)) {
|
||||
inputMessage = request->getParam(PARAM_MSG)->value();
|
||||
writeFile(SPIFFS, "/inputMsg.txt", inputMessage.c_str());
|
||||
yourInputMsg = inputMessage.toInt();
|
||||
}
|
||||
// GET inputFloat value on <ESP_IP>/get?inputFloat=<inputMessage>
|
||||
if (request->hasParam(PARAM_FLOAT)) {
|
||||
inputMessage = request->getParam(PARAM_FLOAT)->value();
|
||||
|
@ -353,31 +422,48 @@ void loop() {
|
|||
//arduinomorse
|
||||
//sender.continueSending();
|
||||
|
||||
// See which message we are sending
|
||||
auto morseToSend = JLed(output26);
|
||||
if(yourInputMsg == 0){
|
||||
morseToSend = morseCQ;
|
||||
} else if(yourInputMsg == 1){
|
||||
morseToSend = morseMOE;
|
||||
} else if(yourInputMsg == 2){
|
||||
morseToSend = morseMOI;
|
||||
} else if(yourInputMsg == 3){
|
||||
morseToSend = morseMOS;
|
||||
} else if(yourInputMsg == 4){
|
||||
morseToSend = morseMOH;
|
||||
} else if(yourInputMsg == 5){
|
||||
morseToSend = morseMO5;
|
||||
}
|
||||
|
||||
|
||||
// if you want to send continuous code, and it's not sending, then start it up
|
||||
if((yourInputSend == 1) & (morseLed.IsRunning() == false)){
|
||||
if((yourInputSend == 1) & (morseCQ.IsRunning() == false)){
|
||||
//jled
|
||||
morseLed.Reset().Update();
|
||||
morseCQ.Reset().Update();
|
||||
//morse.send("CQ CQ CQ DE W1CDN K"); //etherkit morse
|
||||
//telegraph26.send("CQ CQ CQ DE W1CDN K"); //telegraph
|
||||
|
||||
// if you want to send continuous code, and it is sending, keep sending
|
||||
} else if((yourInputSend == 1) & (morseLed.IsRunning() == true)){
|
||||
morseLed.Update();
|
||||
} else if((yourInputSend == 1) & (morseCQ.IsRunning() == true)){
|
||||
morseCQ.Update();
|
||||
|
||||
// if you want to send cycle code and it is sending, keep sending
|
||||
} else if((yourInputSend == 2) & (morseLed.IsRunning() == true)){
|
||||
morseLed.Update();
|
||||
} else if((yourInputSend == 2) & (morseCQ.IsRunning() == true)){
|
||||
morseCQ.Update();
|
||||
|
||||
// if you want to send cycle code and it's not sending, then start it up
|
||||
} else if((yourInputSend == 2) & (morseLed.IsRunning() == true)){
|
||||
morseLed.Reset().Update();
|
||||
} else if((yourInputSend == 2) & (morseCQ.IsRunning() == true)){
|
||||
morseCQ.Reset().Update();
|
||||
|
||||
// if you don't want to send code
|
||||
} else {
|
||||
// stop sending and make sure the pin is off
|
||||
morseLed.Stop(JLed::eStopMode::FULL_OFF).Update();
|
||||
morseCQ.Stop(JLed::eStopMode::FULL_OFF).Update();
|
||||
}
|
||||
morseLed.Update();
|
||||
morseCQ.Update();
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user