Blink LED while sending CW.

This commit is contained in:
mattbk 2023-09-04 20:23:14 -05:00
parent a3ec425c88
commit 4c6105734e

View File

@ -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; //LED_BUILTIN for on-board (dev);//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();
@ -284,20 +284,36 @@ 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);
// CW for keyer
auto morseTEST = auto morseTEST =
JLed(output26).UserFunc(&morseEffectTEST).DelayAfter(word_space_ms).Forever(); 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 = morseTEST; // 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
// void printTime(time_t t) // void printTime(time_t t)
@ -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 = morseTEST; 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);
@ -540,16 +561,22 @@ void loop() {
//morseToSend.Stop(JLed::eStopMode::FULL_OFF).Update(); //morseToSend.Stop(JLed::eStopMode::FULL_OFF).Update();
if(yourInputMsg == 0){ if(yourInputMsg == 0){
morseToSend = morseTEST; 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 // Keeps the key from locking up
yourInputMsg_old = yourInputMsg; yourInputMsg_old = yourInputMsg;
@ -560,25 +587,30 @@ 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();