From 4c6105734e59582e461b9dc1ed9263c4f42f5eed Mon Sep 17 00:00:00 2001 From: mattbk Date: Mon, 4 Sep 2023 20:23:14 -0500 Subject: [PATCH] Blink LED while sending CW. --- vulpes/src/main.cpp | 86 +++++++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 27 deletions(-) diff --git a/vulpes/src/main.cpp b/vulpes/src/main.cpp index dd50585..09210a8 100644 --- a/vulpes/src/main.cpp +++ b/vulpes/src/main.cpp @@ -96,12 +96,12 @@ const char index_html[] PROGMEM = R"rawliteral( )rawliteral"; // Auxiliary variables to store the current output state -String output26State = "off"; -String output27State = "off"; +//String output26State = "off"; +//String output27State = "off"; // Assign output variables to GPIO pins -const int output26 = 32; //LED_BUILTIN for on-board (dev);//26 for LED; //32 for transmitter keyer -const int output27 = 27; +const int keyer = 32; //LED_BUILTIN for on-board (dev);//26 for LED; //32 for transmitter keyer +const int blinker = LED_BUILTIN; // Timers //auto timer = timer_create_default(); @@ -284,20 +284,36 @@ MorseEffect morseEffectMOS("MOS", ms_per_dit); MorseEffect morseEffectMOH("MOH", ms_per_dit); MorseEffect morseEffectMO5("MO5", ms_per_dit); +// CW for keyer auto morseTEST = - JLed(output26).UserFunc(&morseEffectTEST).DelayAfter(word_space_ms).Forever(); + JLed(keyer).UserFunc(&morseEffectTEST).DelayAfter(word_space_ms).Forever(); auto morseMOE = - JLed(output26).UserFunc(&morseEffectMOE).DelayAfter(word_space_ms).Forever(); + JLed(keyer).UserFunc(&morseEffectMOE).DelayAfter(word_space_ms).Forever(); auto morseMOI = - JLed(output26).UserFunc(&morseEffectMOI).DelayAfter(word_space_ms).Forever(); + JLed(keyer).UserFunc(&morseEffectMOI).DelayAfter(word_space_ms).Forever(); auto morseMOS = - JLed(output26).UserFunc(&morseEffectMOS).DelayAfter(word_space_ms).Forever(); + JLed(keyer).UserFunc(&morseEffectMOS).DelayAfter(word_space_ms).Forever(); auto morseMOH = - JLed(output26).UserFunc(&morseEffectMOH).DelayAfter(word_space_ms).Forever(); + JLed(keyer).UserFunc(&morseEffectMOH).DelayAfter(word_space_ms).Forever(); auto morseMO5 = - JLed(output26).UserFunc(&morseEffectMO5).DelayAfter(word_space_ms).Forever(); + JLed(keyer).UserFunc(&morseEffectMO5).DelayAfter(word_space_ms).Forever(); 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 // void printTime(time_t t) @@ -348,11 +364,11 @@ void setup() { //timer.every(1000, toggle_gpio_26); // Initialize the output variables as outputs - pinMode(output26, OUTPUT); - pinMode(output27, OUTPUT); + pinMode(keyer, OUTPUT); + pinMode(blinker, OUTPUT); // Set outputs to LOW - digitalWrite(output26, LOW); - digitalWrite(output27, LOW); + digitalWrite(keyer, LOW); + digitalWrite(blinker, LOW); // Initialize SPIFFS SPIFFS.begin(true); @@ -393,21 +409,26 @@ void setup() { yourInputMsg = readFile(SPIFFS, "/inputMsg.txt").toInt(); yourInputFloat = readFile(SPIFFS, "/inputFloat.txt").toFloat(); - // On restart, keep doing what you were doing before yourInputMsg_old = yourInputMsg; if(yourInputMsg == 0){ morseToSend = morseTEST; + morseToSend_blink = morseTEST_blink; } else if(yourInputMsg == 1){ morseToSend = morseMOE; + morseToSend_blink = morseMOE_blink; } else if(yourInputMsg == 2){ morseToSend = morseMOI; + morseToSend_blink = morseMOI_blink; } else if(yourInputMsg == 3){ morseToSend = morseMOS; + morseToSend_blink = morseMOS_blink; } else if(yourInputMsg == 4){ morseToSend = morseMOH; + morseToSend_blink = morseMOH_blink; } else if(yourInputMsg == 5){ morseToSend = morseMO5; + morseToSend_blink = morseMO5_blink; } WiFi.mode(WIFI_STA); @@ -539,18 +560,24 @@ void loop() { if(yourInputMsg != yourInputMsg_old){ //morseToSend.Stop(JLed::eStopMode::FULL_OFF).Update(); if(yourInputMsg == 0){ - morseToSend = morseTEST; - } 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; - } + morseToSend = morseTEST; + morseToSend_blink = morseTEST_blink; + } else if(yourInputMsg == 1){ + morseToSend = morseMOE; + morseToSend_blink = morseMOE_blink; + } else if(yourInputMsg == 2){ + morseToSend = morseMOI; + morseToSend_blink = morseMOI_blink; + } else if(yourInputMsg == 3){ + morseToSend = morseMOS; + morseToSend_blink = morseMOS_blink; + } else if(yourInputMsg == 4){ + morseToSend = morseMOH; + morseToSend_blink = morseMOH_blink; + } else if(yourInputMsg == 5){ + morseToSend = morseMO5; + morseToSend_blink = morseMO5_blink; + } // Keeps the key from locking up yourInputMsg_old = yourInputMsg; } @@ -560,25 +587,30 @@ void loop() { if((yourInputSend == 1) & (morseToSend.IsRunning() == false)){ //jled morseToSend.Reset().Update(); + morseToSend_blink.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) & (morseToSend.IsRunning() == true)){ morseToSend.Update(); + morseToSend_blink.Update(); // if you want to send cycle code and it is sending, keep sending } else if((yourInputSend == 2) & (morseToSend.IsRunning() == true)){ morseToSend.Update(); + morseToSend_blink.Update(); // if you want to send cycle code and it's not sending, then start it up } else if((yourInputSend == 2) & (morseToSend.IsRunning() == true)){ morseToSend.Reset().Update(); + morseToSend_blink.Reset().Update(); // if you don't want to send code } else { // stop sending and make sure the pin is off morseToSend.Stop(JLed::eStopMode::FULL_OFF).Update(); + morseToSend_blink.Stop(JLed::eStopMode::FULL_OFF).Update(); } //morseToSend.Update();