Only send cycles when program is running.

This commit is contained in:
mattbk 2023-09-09 16:01:41 -05:00
parent 2127d4a75a
commit 70decbbcca

View File

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