Set up scheduled program cycles #24

Merged
W1CDN merged 41 commits from program-cycle into main 2023-09-15 16:51:45 -05:00
2 changed files with 34 additions and 34 deletions
Showing only changes of commit 1bde39e148 - Show all commits

View File

@ -22,7 +22,7 @@ lib_deps =
me-no-dev/ESP Async WebServer@^1.2.3
contrem/arduino-timer@^3.0.1
;kj7rrv/Telegraph@^1.0.0
jandelgado/JLed@^4.13.0
jandelgado/JLed@^4.13.1
;adafruit/RTClib@^2.1.1
https://github.com/adafruit/RTClib.git ; >=2.1.2
adafruit/Adafruit BusIO@^1.14.3

View File

@ -136,17 +136,17 @@ const char index_html[] PROGMEM = R"rawliteral(
</select></p>
<h2>Cycle Settings</h2>
<p>Only applies when <em>Sending Program</em> is set to "2 - Cycle". You cannot set a cycle start date more than a month in advance.</p>
<p>Cycle start time <input type="datetime-local" id="js_start_time_unix_entry" /><br>
Current value: <b><span id=current-start></span></b>, but only day-of-month HH:MM:SS are used.
Only applies when <em>Sending Program</em> is set to "2 - Cycle".
You cannot set a cycle start date more than a month in advance.
Current value: <b><span id=current-start></span></b>
<!-- JS converts the entered start time to a unix timestamp, and copies that value
to this hidden field so the user doesn't have to see it. -->
<input type="hidden" name="inputStartTimeUnix" id="js_start_time_unix" /></p>
<p>
Step length: <input type="number" name="inputStepLength" value = %inputStepLength%><br>
Cycle ID: <input type="number" name="inputCycleID" value = %inputCycleID%><br>
Number of transmitters: <input type="number" name="inputNtransmitters" value = %inputNtransmitters%><br>
Step length: <input type="number" name="inputStepLength" min=1000 step=1000 value = %inputStepLength%> milliseconds <br>
Cycle ID: <input type="number" name="inputCycleID" min=1 value = %inputCycleID%><br>
Number of transmitters: <input type="number" name="inputNtransmitters" min=1 value = %inputNtransmitters%><br>
</p>
<!-- This field is hidden so people don't change the submit time (it will be wrong).
@ -321,27 +321,26 @@ auto morseToSend_blink = morseTEST_blink; // set this up to overwrite later
// Cycle stuff
auto morse_cycle = morseEffectMOS;
int period = morse_cycle.Period();
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[] = {
// WOW it looks like you can't do Repeat() and DelayAfter() at the same time?
// Opened https://github.com/jandelgado/jled/issues/122
JLed(blinker).UserFunc(&morse_cycle).Repeat(repeats),
//JLed(blinker).FadeOn(1000).Repeat(3)
JLed(blinker).Off(total_wait)
blinker_continuous,
blinker_continuous_wait
};
auto morses_sequence_blink = JLedSequence(JLedSequence::eMode::SEQUENCE, morses_blink);
//================================================================================
// start_program(): a function to start the planned program at the planned time
//================================================================================
bool start_program(){
Serial.println("The scheduled program has started.");
startProgram = true;
return false;
}
// bool start_program(){
// Serial.println("The scheduled program has started.");
// startProgram = true;
// return false;
// }
//================================================================================
// setup(): stuff that only gets done once, after power up (KB1OIQ's description)
@ -623,16 +622,17 @@ void loop() {
// Once alarm has started the program, set things up to run
if(startProgram == true){
//auto morse_cycle = morseEffectMOS;
int period = morse_cycle.Period();
int repeats = step_length / period;
int remainder_wait = step_length - (period * repeats);
int total_wait = ((step_length * (n_transmitters - 1) + remainder_wait));
//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));
// Nothing makes it out of this scope...
blinker_continuous = JLed(blinker).UserFunc(&morse_cycle).Repeat(repeats).DelayAfter(word_space_ms);
blinker_continuous_wait = JLed(blinker).Off(total_wait);
JLed morses_blink[] = {
// WOW it looks like you can't do Repeat() and DelayAfter() at the same time?
// Opened https://github.com/jandelgado/jled/issues/122
JLed(blinker).UserFunc(&morse_cycle).Repeat(repeats),
//JLed(blinker).FadeOn(1000).Repeat(3)
JLed(blinker).Off(total_wait)
blinker_continuous,
blinker_continuous_wait
};
auto morses_sequence_blink = JLedSequence(JLedSequence::eMode::SEQUENCE, morses_blink);