Only send cycles when program is running.
This commit is contained in:
parent
2127d4a75a
commit
70decbbcca
|
@ -53,8 +53,8 @@ int yourInputMsg_old; // to save previous state and check changes
|
||||||
float yourInputFloat;
|
float yourInputFloat;
|
||||||
uint32_t yourInputTime; //to keep time
|
uint32_t yourInputTime; //to keep time
|
||||||
uint32_t yourInputStartTimeUnix;
|
uint32_t yourInputStartTimeUnix;
|
||||||
bool yourProgramRunning;
|
bool startProgram;
|
||||||
bool yourProgramRunning_old;
|
bool programRunning;
|
||||||
int step_length = 30000; // 30 secs
|
int step_length = 30000; // 30 secs
|
||||||
int cycle_id = 1; // number of this transmitter in cycle
|
int cycle_id = 1; // number of this transmitter in cycle
|
||||||
int n_transmitters = 2; //number of transmitters total
|
int n_transmitters = 2; //number of transmitters total
|
||||||
|
@ -318,7 +318,7 @@ auto morses_sequence = JLedSequence(JLedSequence::eMode::SEQUENCE, morses);
|
||||||
//================================================================================
|
//================================================================================
|
||||||
bool start_program(){
|
bool start_program(){
|
||||||
Serial.println("The scheduled program has started.");
|
Serial.println("The scheduled program has started.");
|
||||||
yourProgramRunning = true;
|
startProgram = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,7 +436,8 @@ void setup() {
|
||||||
yourInputSend = inputMessage.toInt();
|
yourInputSend = inputMessage.toInt();
|
||||||
// if not running a program, set the program running off
|
// if not running a program, set the program running off
|
||||||
if(yourInputSend != 2){
|
if(yourInputSend != 2){
|
||||||
yourProgramRunning = false;
|
startProgram = false;
|
||||||
|
programRunning = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// GET inputWPM value on <ESP_IP>/get?inputWPM=<inputMessage>
|
// GET inputWPM value on <ESP_IP>/get?inputWPM=<inputMessage>
|
||||||
|
@ -543,7 +544,7 @@ void loop() {
|
||||||
DateTime now = rtc.now(); // Get the current time
|
DateTime now = rtc.now(); // Get the current time
|
||||||
char buff[] = "Alarm triggered at hh:mm:ss DDD, DD MMM YYYY";
|
char buff[] = "Alarm triggered at hh:mm:ss DDD, DD MMM YYYY";
|
||||||
Serial.println(now.toString(buff));
|
Serial.println(now.toString(buff));
|
||||||
yourProgramRunning = true;
|
startProgram = true;
|
||||||
|
|
||||||
// Disable and clear alarm
|
// Disable and clear alarm
|
||||||
rtc.clearAlarm(1);
|
rtc.clearAlarm(1);
|
||||||
|
@ -551,9 +552,10 @@ void loop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Once alarm has started the program, set things up to run
|
// Once alarm has started the program, set things up to run
|
||||||
if(yourProgramRunning == true){
|
if(startProgram == true){
|
||||||
morses_sequence.Forever().Update();
|
morses_sequence.Forever().Update();
|
||||||
yourProgramRunning = false;
|
programRunning = true;
|
||||||
|
startProgram = false;
|
||||||
} else
|
} else
|
||||||
// See which message we are sending
|
// See which message we are sending
|
||||||
// Only do this when the message has been updated.
|
// Only do this when the message has been updated.
|
||||||
|
@ -578,7 +580,7 @@ void loop() {
|
||||||
morseToSend = morseMO5;
|
morseToSend = morseMO5;
|
||||||
morseToSend_blink = morseMO5_blink;
|
morseToSend_blink = morseMO5_blink;
|
||||||
}
|
}
|
||||||
// Keeps the key from locking up
|
// Keeps the key/led from locking up
|
||||||
yourInputMsg_old = yourInputMsg;
|
yourInputMsg_old = yourInputMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,22 +597,25 @@ void loop() {
|
||||||
morseToSend_blink.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) & (morses_sequence.Update() == true)){
|
} else if((yourInputSend == 2) & (programRunning == true) &(morses_sequence.Update() == true)){
|
||||||
morseToSend.Update();
|
morseToSend.Update();
|
||||||
//morseToSend_blink.Update();
|
//morseToSend_blink.Update();
|
||||||
morses_sequence.Update();
|
morses_sequence.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) & (morses_sequence.Update() == false)){
|
} else if((yourInputSend == 2) & (programRunning == true) & (morses_sequence.Update() == false)){
|
||||||
morseToSend.Reset().Update();
|
morseToSend.Reset().Update();
|
||||||
//morseToSend_blink.Reset().Update();
|
//morseToSend_blink.Reset().Update();
|
||||||
morses_sequence.Reset();
|
morses_sequence.Reset();
|
||||||
|
// if the cycle program is not running
|
||||||
|
} else if((yourInputSend == 2 & (programRunning == false))){
|
||||||
|
morses_sequence.Stop();
|
||||||
// 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_blink.Stop(JLed::eStopMode::FULL_OFF).Update();
|
||||||
|
morses_sequence.Stop();
|
||||||
}
|
}
|
||||||
//morseToSend.Update();
|
//morseToSend.Update();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user