Shelve.
This commit is contained in:
parent
fbe5a4a6e0
commit
e706327623
|
@ -53,7 +53,11 @@ int yourInputMsg_old; // to save previous state and check changes
|
|||
float yourInputFloat;
|
||||
uint32_t yourInputTime; //to keep time
|
||||
uint32_t yourInputStartTimeUnix;
|
||||
int yourProgramRunning;
|
||||
bool yourProgramRunning;
|
||||
bool yourProgramRunning_old;
|
||||
int step_length = 30000; // 30 secs
|
||||
int cycle_id = 1; // number of this transmitter in cycle
|
||||
int n_transmitters = 5; //number of transmitters total
|
||||
|
||||
// HTML web page to handle 3 input fields (inputString, inputSend, inputFloat)
|
||||
const char index_html[] PROGMEM = R"rawliteral(
|
||||
|
@ -276,6 +280,7 @@ auto morseMOH =
|
|||
JLed(keyer).UserFunc(&morseEffectMOH).DelayAfter(word_space_ms).Forever();
|
||||
auto morseMO5 =
|
||||
JLed(keyer).UserFunc(&morseEffectMO5).DelayAfter(word_space_ms).Forever();
|
||||
auto morseWait = JLed(keyer).Off().Forever(); // set this up to overwrite later
|
||||
auto morseToSend = morseTEST; // set this up to overwrite later
|
||||
|
||||
// CW for blinker
|
||||
|
@ -291,14 +296,19 @@ 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 morseWait_blink = JLed(blinker).Off().Forever(); // set this up to overwrite later
|
||||
auto morseToSend_blink = morseTEST_blink; // set this up to overwrite later
|
||||
|
||||
// Cycle sequence placeholder
|
||||
JLed morseToSend_sequence_blink[] = {morseToSend_blink, morseWait_blink};
|
||||
auto seq = JLedSequence(JLedSequence::eMode::SEQUENCE, morseToSend_sequence_blink).Forever();
|
||||
|
||||
//================================================================================
|
||||
// start_program(): a function to start the planned program at the planned time
|
||||
//================================================================================
|
||||
bool start_program(){
|
||||
Serial.println("The scheduled program has started.");
|
||||
yourProgramRunning = 1;
|
||||
yourProgramRunning = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -416,7 +426,7 @@ void setup() {
|
|||
yourInputSend = inputMessage.toInt();
|
||||
// if not running a program, set the program running off
|
||||
if(yourInputSend != 2){
|
||||
yourProgramRunning = 0;
|
||||
yourProgramRunning = false;
|
||||
}
|
||||
}
|
||||
// GET inputWPM value on <ESP_IP>/get?inputWPM=<inputMessage>
|
||||
|
@ -523,40 +533,57 @@ 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;
|
||||
|
||||
// Disable and clear alarm
|
||||
rtc.clearAlarm(1);
|
||||
rtc.clearAlarm(2); // clear the other one just in case
|
||||
}
|
||||
|
||||
// Once alarm has started the program, set things up to run
|
||||
if(yourProgramRunning == true){
|
||||
Serial.println("Running program");
|
||||
// cycle instructions go here
|
||||
// Experiment with timing
|
||||
int repeats = step_length / morseEffectTEST.Period();
|
||||
// add morseToSend once blink works
|
||||
// add morseWait once blink works
|
||||
// Send the message the right number of times
|
||||
// put in the right message once this works
|
||||
morseToSend_blink.UserFunc(&morseEffectTEST).DelayAfter(word_space_ms).Repeat(repeats);
|
||||
// Wait the right amount of time
|
||||
int remainder_wait = step_length - (morseEffectTEST.Period() * repeats);
|
||||
int total_wait = ((step_length * (n_transmitters - 1) + remainder_wait));
|
||||
morseWait_blink.Off().DelayAfter(total_wait);
|
||||
// Set up sequence
|
||||
JLed morseToSend_sequence_blink[] = {morseToSend_blink, morseWait_blink};
|
||||
// fix the variable names through here, yikes
|
||||
auto seq = JLedSequence(JLedSequence::eMode::SEQUENCE, morseToSend_sequence_blink).Forever().Update();
|
||||
yourProgramRunning = false;
|
||||
} else
|
||||
// See which message we are sending
|
||||
// Only do this when the message has been updated.
|
||||
if(yourInputMsg != yourInputMsg_old){
|
||||
//morseToSend.Stop(JLed::eStopMode::FULL_OFF).Update();
|
||||
if(yourInputMsg == 0){
|
||||
morseToSend = morseTEST;
|
||||
morseToSend_blink = morseTEST_blink;
|
||||
// Experiment with timing
|
||||
int step_length = 30000; // 30 secs
|
||||
int repeats = step_length / morseEffectTEST.Period();
|
||||
morseToSend_blink.UserFunc(&morseEffectTEST).DelayAfter(word_space_ms).Repeat(repeats);
|
||||
|
||||
} 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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
// Keeps the key from locking up
|
||||
yourInputMsg_old = yourInputMsg;
|
||||
}
|
||||
|
@ -574,14 +601,16 @@ void loop() {
|
|||
morseToSend_blink.Update();
|
||||
|
||||
// if you want to send cycle code and it is sending, keep sending
|
||||
} else if((yourInputSend == 2) & (morseToSend.IsRunning() == true)){
|
||||
} else if((yourInputSend == 2) & (seq.Update() == true)){
|
||||
morseToSend.Update();
|
||||
morseToSend_blink.Update();
|
||||
//morseToSend_blink.Update();
|
||||
seq.Update();
|
||||
|
||||
// if you want to send cycle code and it's not sending, then start it up
|
||||
} else if((yourInputSend == 2) & (morseToSend.IsRunning() == false)){
|
||||
} else if((yourInputSend == 2) & (seq.Update() == false)){
|
||||
morseToSend.Reset().Update();
|
||||
morseToSend_blink.Reset().Update();
|
||||
//morseToSend_blink.Reset().Update();
|
||||
seq.Update();
|
||||
|
||||
// if you don't want to send code
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user