Start on schedule and able to stop.
This commit is contained in:
parent
dd085635a2
commit
06e69bd8c0
|
@ -304,60 +304,60 @@ auto morseMO5 =
|
|||
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
|
||||
// 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
|
||||
|
||||
// Cycle stuff
|
||||
auto morse_cycle = morseEffectMOS;
|
||||
int period = morse_cycle.Period() + word_space_ms;
|
||||
int repeats = step_length / period;
|
||||
int remainder_wait = step_length - (period * repeats);
|
||||
int total_wait = ((step_length * (n_transmitters - 1) + remainder_wait));
|
||||
auto blinker_continuous = JLed(blinker).UserFunc(&morse_cycle).Repeat(repeats).DelayAfter(word_space_ms);
|
||||
auto blinker_continuous_wait = JLed(blinker).Off(total_wait);
|
||||
JLed morses_blink[] = {
|
||||
blinker_continuous,
|
||||
blinker_continuous_wait
|
||||
};
|
||||
auto morses_sequence_blink = JLedSequence(JLedSequence::eMode::SEQUENCE, morses_blink);
|
||||
// auto morse_cycle = morseEffectMOS;
|
||||
// int period = morse_cycle.Period() + word_space_ms;
|
||||
// int repeats = step_length / period;
|
||||
// int remainder_wait = step_length - (period * repeats);
|
||||
// int total_wait = ((step_length * (n_transmitters - 1) + remainder_wait));
|
||||
// auto blinker_continuous = JLed(blinker).UserFunc(&morse_cycle).Repeat(repeats).DelayAfter(word_space_ms);
|
||||
// auto blinker_continuous_wait = JLed(blinker).Off(total_wait);
|
||||
// JLed morses_blink[] = {
|
||||
// blinker_continuous,
|
||||
// blinker_continuous_wait
|
||||
// };
|
||||
// auto morses_sequence_blink = JLedSequence(JLedSequence::eMode::SEQUENCE, morses_blink);
|
||||
|
||||
|
||||
|
||||
|
||||
JLedSequence* sequence = NULL;
|
||||
JLedSequence* make_sequence(JLedSequence* seq, const char* message, int wpm, int step_length, int n_transmitters){
|
||||
int ms_per_dit = 60;//1000 * (60 / (50 * wpm));
|
||||
int word_space_ms = ms_per_dit * 7;
|
||||
MorseEffect morse_effect(message, ms_per_dit);
|
||||
int period = morse_effect.Period();
|
||||
int repeats = 2;//step_length / period;
|
||||
int remainder_wait = step_length - (period * repeats);
|
||||
int total_wait = ((step_length * (n_transmitters - 1) + remainder_wait));
|
||||
Serial.print("total_wait: "); Serial.println(total_wait);
|
||||
JLed morses_blink[] = {
|
||||
JLed(blinker).UserFunc(&morse_effect).Repeat(repeats).DelayAfter(word_space_ms),
|
||||
JLed(blinker).Off(total_wait)
|
||||
};
|
||||
if (seq){
|
||||
delete seq;
|
||||
//seq = new JLedSequence(JLedSequence::eMode::SEQUENCE, leds);
|
||||
seq = new JLedSequence(JLedSequence::eMode::SEQUENCE, morses_blink);
|
||||
}
|
||||
return seq;
|
||||
}
|
||||
// Initial definition of the sequence
|
||||
JLedSequence* morses_sequence_blink_test = make_sequence(sequence, "MOE", 10, 10000, 2);
|
||||
// JLedSequence* sequence = NULL;
|
||||
// JLedSequence* make_sequence(JLedSequence* seq, const char* message, int wpm, int step_length, int n_transmitters){
|
||||
// int ms_per_dit = 60;//1000 * (60 / (50 * wpm));
|
||||
// int word_space_ms = ms_per_dit * 7;
|
||||
// MorseEffect morse_effect(message, ms_per_dit);
|
||||
// int period = morse_effect.Period();
|
||||
// int repeats = 2;//step_length / period;
|
||||
// int remainder_wait = step_length - (period * repeats);
|
||||
// int total_wait = ((step_length * (n_transmitters - 1) + remainder_wait));
|
||||
// Serial.print("total_wait: "); Serial.println(total_wait);
|
||||
// JLed morses_blink[] = {
|
||||
// JLed(blinker).UserFunc(&morse_effect).Repeat(repeats).DelayAfter(word_space_ms),
|
||||
// JLed(blinker).Off(total_wait)
|
||||
// };
|
||||
// if (seq){
|
||||
// delete seq;
|
||||
// //seq = new JLedSequence(JLedSequence::eMode::SEQUENCE, leds);
|
||||
// seq = new JLedSequence(JLedSequence::eMode::SEQUENCE, morses_blink);
|
||||
// }
|
||||
// return seq;
|
||||
// }
|
||||
// // Initial definition of the sequence
|
||||
// JLedSequence* morses_sequence_blink_test = make_sequence(sequence, "MOE", 10, 10000, 2);
|
||||
|
||||
|
||||
|
||||
|
@ -411,10 +411,10 @@ void setup() {
|
|||
|
||||
// Initialize the output variables as outputs
|
||||
pinMode(keyer, OUTPUT);
|
||||
pinMode(blinker, OUTPUT);
|
||||
//pinMode(blinker, OUTPUT);
|
||||
// Set outputs to LOW
|
||||
digitalWrite(keyer, LOW);
|
||||
digitalWrite(blinker, LOW);
|
||||
//digitalWrite(blinker, LOW);
|
||||
|
||||
// Initialize SPIFFS
|
||||
SPIFFS.begin(true);
|
||||
|
@ -441,30 +441,31 @@ void setup() {
|
|||
// On restart, keep doing what you were doing before
|
||||
yourInputMsg_old = yourInputMsg;
|
||||
if(yourInputMsg == 0){
|
||||
morseToSend = morseTEST;
|
||||
morseToSend_blink = morseTEST_blink;
|
||||
// morseToSend = morseTEST;
|
||||
// morseToSend_blink = morseTEST_blink;
|
||||
sender.setMessage(String("test test test de w1cdn "));
|
||||
} else if(yourInputMsg == 1){
|
||||
morseToSend = morseMOE;
|
||||
morseToSend_blink = morseMOE_blink;
|
||||
// morseToSend = morseMOE;
|
||||
// morseToSend_blink = morseMOE_blink;
|
||||
sender.setMessage(String("moe "));
|
||||
} else if(yourInputMsg == 2){
|
||||
morseToSend = morseMOI;
|
||||
morseToSend_blink = morseMOI_blink;
|
||||
// morseToSend = morseMOI;
|
||||
// morseToSend_blink = morseMOI_blink;
|
||||
sender.setMessage(String("moi "));
|
||||
} else if(yourInputMsg == 3){
|
||||
morseToSend = morseMOS;
|
||||
morseToSend_blink = morseMOS_blink;
|
||||
// morseToSend = morseMOS;
|
||||
// morseToSend_blink = morseMOS_blink;
|
||||
sender.setMessage(String("mos "));
|
||||
} else if(yourInputMsg == 4){
|
||||
morseToSend = morseMOH;
|
||||
morseToSend_blink = morseMOH_blink;
|
||||
// morseToSend = morseMOH;
|
||||
// morseToSend_blink = morseMOH_blink;
|
||||
sender.setMessage(String("moh "));
|
||||
} else if(yourInputMsg == 5){
|
||||
morseToSend = morseMO5;
|
||||
morseToSend_blink = morseMO5_blink;
|
||||
// morseToSend = morseMO5;
|
||||
// morseToSend_blink = morseMO5_blink;
|
||||
sender.setMessage(String("mo5 "));
|
||||
}
|
||||
//sender.startSending();
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, password);
|
||||
|
@ -616,29 +617,29 @@ void loop() {
|
|||
if(yourInputMsg != yourInputMsg_old){
|
||||
//morseToSend.Stop(JLed::eStopMode::FULL_OFF).Update();
|
||||
if(yourInputMsg == 0){
|
||||
morseToSend = morseTEST;
|
||||
morseToSend_blink = morseTEST_blink;
|
||||
// morseToSend = morseTEST;
|
||||
//morseToSend_blink = morseTEST_blink;
|
||||
sender.setMessage(String("test test test de w1cdn "));
|
||||
} else if(yourInputMsg == 1){
|
||||
morseToSend = morseMOE;
|
||||
// morseToSend = morseMOE;
|
||||
sender.setMessage(String("moe "));
|
||||
morseToSend_blink = morseMOE_blink;
|
||||
// morseToSend_blink = morseMOE_blink;
|
||||
} else if(yourInputMsg == 2){
|
||||
morseToSend = morseMOI;
|
||||
// morseToSend = morseMOI;
|
||||
sender.setMessage(String("moi "));
|
||||
morseToSend_blink = morseMOI_blink;
|
||||
// morseToSend_blink = morseMOI_blink;
|
||||
} else if(yourInputMsg == 3){
|
||||
morseToSend = morseMOS;
|
||||
// morseToSend = morseMOS;
|
||||
sender.setMessage(String("mos "));
|
||||
morseToSend_blink = morseMOS_blink;
|
||||
// morseToSend_blink = morseMOS_blink;
|
||||
} else if(yourInputMsg == 4){
|
||||
morseToSend = morseMOH;
|
||||
// morseToSend = morseMOH;
|
||||
sender.setMessage(String("moh "));
|
||||
morseToSend_blink = morseMOH_blink;
|
||||
// morseToSend_blink = morseMOH_blink;
|
||||
} else if(yourInputMsg == 5){
|
||||
morseToSend = morseMO5;
|
||||
// morseToSend = morseMO5;
|
||||
sender.setMessage(String("mo5 "));
|
||||
morseToSend_blink = morseMO5_blink;
|
||||
// morseToSend_blink = morseMO5_blink;
|
||||
}
|
||||
// Keeps the key/led from locking up
|
||||
yourInputMsg_old = yourInputMsg;
|
||||
|
@ -687,27 +688,33 @@ void loop() {
|
|||
// if you want to send continuous code, and it's not sending, then start it up
|
||||
if((yourInputSend == 1) & (morseToSend.IsRunning() == false)){
|
||||
//jled
|
||||
morseToSend.Reset().Update();
|
||||
morseToSend_blink.Reset().Update();
|
||||
// morseToSend.Reset().Update();
|
||||
// morseToSend_blink.Reset().Update();
|
||||
|
||||
// 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) & (programRunning == true)){//&(morses_sequence_blink.Update() == true)
|
||||
//morseToSend.Update();
|
||||
//morseToSend_blink.Update();
|
||||
//morses_sequence_blink.Update();
|
||||
sender.continueSending();
|
||||
|
||||
// if you want to send cycle code and it is sending, keep sending
|
||||
// } else if((yourInputSend == 2) & (programRunning == true)){//&(morses_sequence_blink.Update() == true)
|
||||
// //morseToSend.Update();
|
||||
// //morseToSend_blink.Update();
|
||||
// //morses_sequence_blink.Update();
|
||||
// //Serial.println("Continue cycle");
|
||||
// sender.continueSending();
|
||||
// if you want to send cycle code and it's not sending, then start it up
|
||||
// } else if((yourInputSend == 2) & (programRunning == true) & !sender.continueSending()){//& (morses_sequence_blink.Update() == false)
|
||||
// //morseToSend.Reset().Update();
|
||||
// //morseToSend_blink.Reset().Update();
|
||||
// //morses_sequence_blink.Reset();
|
||||
} else if((yourInputSend == 2) & (programRunning == true)){//& (morses_sequence_blink.Update() == false)
|
||||
//morseToSend.Reset().Update();
|
||||
//morseToSend_blink.Reset().Update();
|
||||
//morses_sequence_blink.Reset();
|
||||
//Serial.println("Start up cycle");
|
||||
// sender.startSending();
|
||||
if (!sender.continueSending())
|
||||
{
|
||||
// Set the internal counters to the message's beginning.
|
||||
// Here, this results in repeating the message indefinitely.
|
||||
sender.startSending();
|
||||
}
|
||||
// if the cycle program is not running
|
||||
} else if((yourInputSend == 2) & (programRunning == false)){
|
||||
//Serial.println("Program is over, stop sending")
|
||||
|
@ -715,12 +722,12 @@ void loop() {
|
|||
//sender.setMessage(String(""));
|
||||
// if you don't want to send code
|
||||
} else {
|
||||
Serial.println("Stop sending");
|
||||
//Serial.println("Stop sending");
|
||||
// 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.Stop(JLed::eStopMode::FULL_OFF).Update();
|
||||
// morseToSend_blink.Stop(JLed::eStopMode::FULL_OFF).Update();
|
||||
//morses_sequence_blink.Stop();
|
||||
sender.setMessage(String(""));
|
||||
//sender.setMessage(String(""));
|
||||
}
|
||||
//morseToSend.Update();
|
||||
//sender.continueSending();
|
||||
|
|
Loading…
Reference in New Issue
Block a user