Fix lockup and message change #21

Merged
W1CDN merged 3 commits from debug-new-message into main 2023-09-04 20:48:14 -05:00
2 changed files with 69 additions and 33 deletions

View File

@ -0,0 +1,2 @@
#define WIFI_SSID "wifi_name"
#define WIFI_PASSWORD "wifi_pass"

View File

@ -76,7 +76,7 @@ const char index_html[] PROGMEM = R"rawliteral(
Message (current value <b>%inputMsg%</b>): Message (current value <b>%inputMsg%</b>):
<select name="inputMsg" id="message"> <select name="inputMsg" id="message">
<option value="0">0 - CQ CQ CQ DE W1CDN</option> <option value="0">0 - TEST TEST TEST DE W1CDN</option>
<option value="1">1 - MOE</option> <option value="1">1 - MOE</option>
<option value="2">2 - MOI</option> <option value="2">2 - MOI</option>
<option value="3">3 - MOS</option> <option value="3">3 - MOS</option>
@ -96,12 +96,12 @@ const char index_html[] PROGMEM = R"rawliteral(
</body></html>)rawliteral"; </body></html>)rawliteral";
// Auxiliary variables to store the current output state // Auxiliary variables to store the current output state
String output26State = "off"; //String output26State = "off";
String output27State = "off"; //String output27State = "off";
// Assign output variables to GPIO pins // Assign output variables to GPIO pins
const int output26 = 32;//26 for LED; //32 for transmitter keyer const int keyer = 32; //LED_BUILTIN for on-board (dev);//26 for LED; //32 for transmitter keyer
const int output27 = 27; const int blinker = LED_BUILTIN;
// Timers // Timers
//auto timer = timer_create_default(); //auto timer = timer_create_default();
@ -277,26 +277,42 @@ float wpm = 10;
float ms_per_dit = 1000 * (60 / (50 * wpm)); float ms_per_dit = 1000 * (60 / (50 * wpm));
int word_space_ms = ms_per_dit * 7; int word_space_ms = ms_per_dit * 7;
// Hardcoding messages and WPM for now, will come back and make it more flexible. // Hardcoding messages and WPM for now, will come back and make it more flexible.
MorseEffect morseEffectCQ("CQ CQ CQ DE W1CDN", ms_per_dit); MorseEffect morseEffectTEST("TEST TEST TEST DE W1CDN", ms_per_dit);
MorseEffect morseEffectMOE("MOE", ms_per_dit); MorseEffect morseEffectMOE("MOE", ms_per_dit);
MorseEffect morseEffectMOI("MOI", ms_per_dit); MorseEffect morseEffectMOI("MOI", ms_per_dit);
MorseEffect morseEffectMOS("MOS", ms_per_dit); MorseEffect morseEffectMOS("MOS", ms_per_dit);
MorseEffect morseEffectMOH("MOH", ms_per_dit); MorseEffect morseEffectMOH("MOH", ms_per_dit);
MorseEffect morseEffectMO5("MO5", ms_per_dit); MorseEffect morseEffectMO5("MO5", ms_per_dit);
auto morseCQ = // CW for keyer
JLed(output26).UserFunc(&morseEffectCQ).DelayAfter(word_space_ms).Forever(); auto morseTEST =
JLed(keyer).UserFunc(&morseEffectTEST).DelayAfter(word_space_ms).Forever();
auto morseMOE = auto morseMOE =
JLed(output26).UserFunc(&morseEffectMOE).DelayAfter(word_space_ms).Forever(); JLed(keyer).UserFunc(&morseEffectMOE).DelayAfter(word_space_ms).Forever();
auto morseMOI = auto morseMOI =
JLed(output26).UserFunc(&morseEffectMOI).DelayAfter(word_space_ms).Forever(); JLed(keyer).UserFunc(&morseEffectMOI).DelayAfter(word_space_ms).Forever();
auto morseMOS = auto morseMOS =
JLed(output26).UserFunc(&morseEffectMOS).DelayAfter(word_space_ms).Forever(); JLed(keyer).UserFunc(&morseEffectMOS).DelayAfter(word_space_ms).Forever();
auto morseMOH = auto morseMOH =
JLed(output26).UserFunc(&morseEffectMOH).DelayAfter(word_space_ms).Forever(); JLed(keyer).UserFunc(&morseEffectMOH).DelayAfter(word_space_ms).Forever();
auto morseMO5 = auto morseMO5 =
JLed(output26).UserFunc(&morseEffectMO5).DelayAfter(word_space_ms).Forever(); JLed(keyer).UserFunc(&morseEffectMO5).DelayAfter(word_space_ms).Forever();
auto morseToSend = morseCQ; // set this up to overwrite later auto morseToSend = morseTEST; // set this up to overwrite later
// CW for blinker
auto morseTEST_blink =
JLed(blinker).UserFunc(&morseEffectTEST).DelayAfter(word_space_ms).Forever();
auto morseMOE_blink =
JLed(blinker).UserFunc(&morseEffectMOE).DelayAfter(word_space_ms).Forever();
auto morseMOI_blink =
JLed(blinker).UserFunc(&morseEffectMOI).DelayAfter(word_space_ms).Forever();
auto morseMOS_blink =
JLed(blinker).UserFunc(&morseEffectMOS).DelayAfter(word_space_ms).Forever();
auto morseMOH_blink =
JLed(blinker).UserFunc(&morseEffectMOH).DelayAfter(word_space_ms).Forever();
auto morseMO5_blink =
JLed(blinker).UserFunc(&morseEffectMO5).DelayAfter(word_space_ms).Forever();
auto morseToSend_blink = morseTEST_blink; // set this up to overwrite later
// format and print a time_t value // format and print a time_t value
@ -348,11 +364,11 @@ void setup() {
//timer.every(1000, toggle_gpio_26); //timer.every(1000, toggle_gpio_26);
// Initialize the output variables as outputs // Initialize the output variables as outputs
pinMode(output26, OUTPUT); pinMode(keyer, OUTPUT);
pinMode(output27, OUTPUT); pinMode(blinker, OUTPUT);
// Set outputs to LOW // Set outputs to LOW
digitalWrite(output26, LOW); digitalWrite(keyer, LOW);
digitalWrite(output27, LOW); digitalWrite(blinker, LOW);
// Initialize SPIFFS // Initialize SPIFFS
SPIFFS.begin(true); SPIFFS.begin(true);
@ -393,21 +409,26 @@ void setup() {
yourInputMsg = readFile(SPIFFS, "/inputMsg.txt").toInt(); yourInputMsg = readFile(SPIFFS, "/inputMsg.txt").toInt();
yourInputFloat = readFile(SPIFFS, "/inputFloat.txt").toFloat(); yourInputFloat = readFile(SPIFFS, "/inputFloat.txt").toFloat();
// On restart, keep doing what you were doing before // On restart, keep doing what you were doing before
yourInputMsg_old = yourInputMsg; yourInputMsg_old = yourInputMsg;
if(yourInputMsg == 0){ if(yourInputMsg == 0){
morseToSend = morseCQ; morseToSend = morseTEST;
morseToSend_blink = morseTEST_blink;
} else if(yourInputMsg == 1){ } else if(yourInputMsg == 1){
morseToSend = morseMOE; morseToSend = morseMOE;
morseToSend_blink = morseMOE_blink;
} else if(yourInputMsg == 2){ } else if(yourInputMsg == 2){
morseToSend = morseMOI; morseToSend = morseMOI;
morseToSend_blink = morseMOI_blink;
} else if(yourInputMsg == 3){ } else if(yourInputMsg == 3){
morseToSend = morseMOS; morseToSend = morseMOS;
morseToSend_blink = morseMOS_blink;
} else if(yourInputMsg == 4){ } else if(yourInputMsg == 4){
morseToSend = morseMOH; morseToSend = morseMOH;
morseToSend_blink = morseMOH_blink;
} else if(yourInputMsg == 5){ } else if(yourInputMsg == 5){
morseToSend = morseMO5; morseToSend = morseMO5;
morseToSend_blink = morseMO5_blink;
} }
WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
@ -539,18 +560,26 @@ void loop() {
if(yourInputMsg != yourInputMsg_old){ if(yourInputMsg != yourInputMsg_old){
//morseToSend.Stop(JLed::eStopMode::FULL_OFF).Update(); //morseToSend.Stop(JLed::eStopMode::FULL_OFF).Update();
if(yourInputMsg == 0){ if(yourInputMsg == 0){
morseToSend = morseCQ; morseToSend = morseTEST;
morseToSend_blink = morseTEST_blink;
} else if(yourInputMsg == 1){ } else if(yourInputMsg == 1){
morseToSend = morseMOE; morseToSend = morseMOE;
morseToSend_blink = morseMOE_blink;
} else if(yourInputMsg == 2){ } else if(yourInputMsg == 2){
morseToSend = morseMOI; morseToSend = morseMOI;
morseToSend_blink = morseMOI_blink;
} else if(yourInputMsg == 3){ } else if(yourInputMsg == 3){
morseToSend = morseMOS; morseToSend = morseMOS;
morseToSend_blink = morseMOS_blink;
} else if(yourInputMsg == 4){ } else if(yourInputMsg == 4){
morseToSend = morseMOH; morseToSend = morseMOH;
morseToSend_blink = morseMOH_blink;
} else if(yourInputMsg == 5){ } else if(yourInputMsg == 5){
morseToSend = morseMO5; morseToSend = morseMO5;
morseToSend_blink = morseMO5_blink;
} }
// Keeps the key from locking up
yourInputMsg_old = yourInputMsg;
} }
@ -558,27 +587,32 @@ void loop() {
if((yourInputSend == 1) & (morseToSend.IsRunning() == false)){ if((yourInputSend == 1) & (morseToSend.IsRunning() == false)){
//jled //jled
morseToSend.Reset().Update(); morseToSend.Reset().Update();
morseToSend_blink.Reset().Update();
//morse.send("CQ CQ CQ DE W1CDN K"); //etherkit morse //morse.send("CQ CQ CQ DE W1CDN K"); //etherkit morse
//telegraph26.send("CQ CQ CQ DE W1CDN K"); //telegraph //telegraph26.send("CQ CQ CQ DE W1CDN K"); //telegraph
// if you want to send continuous code, and it is sending, keep sending // if you want to send continuous code, and it is sending, keep sending
} else if((yourInputSend == 1) & (morseToSend.IsRunning() == true)){ } else if((yourInputSend == 1) & (morseToSend.IsRunning() == true)){
morseToSend.Update(); morseToSend.Update();
morseToSend_blink.Update();
// if you want to send cycle code and it is sending, keep sending // if you want to send cycle code and it is sending, keep sending
} else if((yourInputSend == 2) & (morseToSend.IsRunning() == true)){ } else if((yourInputSend == 2) & (morseToSend.IsRunning() == true)){
morseToSend.Update(); morseToSend.Update();
morseToSend_blink.Update();
// if you want to send cycle code and it's not sending, then start it up // if you want to send cycle code and it's not sending, then start it up
} else if((yourInputSend == 2) & (morseToSend.IsRunning() == true)){ } else if((yourInputSend == 2) & (morseToSend.IsRunning() == true)){
morseToSend.Reset().Update(); morseToSend.Reset().Update();
morseToSend_blink.Reset().Update();
// if you don't want to send code // if you don't want to send code
} else { } else {
// stop sending and make sure the pin is off // stop sending and make sure the pin is off
morseToSend.Stop(JLed::eStopMode::FULL_OFF).Update(); morseToSend.Stop(JLed::eStopMode::FULL_OFF).Update();
morseToSend_blink.Stop(JLed::eStopMode::FULL_OFF).Update();
} }
morseToSend.Update(); //morseToSend.Update();