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 24 additions and 10 deletions
Showing only changes of commit dc765af473 - Show all commits

View File

@ -27,3 +27,4 @@ lib_deps =
https://github.com/adafruit/RTClib.git ; >=2.1.2 https://github.com/adafruit/RTClib.git ; >=2.1.2
adafruit/Adafruit BusIO@^1.14.3 adafruit/Adafruit BusIO@^1.14.3
;jchristensen/DS3232RTC@^2.0.1 ;jchristensen/DS3232RTC@^2.0.1
monitor_filters = esp32_exception_decoder

View File

@ -333,25 +333,34 @@ JLed morses_blink[] = {
}; };
auto morses_sequence_blink = JLedSequence(JLedSequence::eMode::SEQUENCE, morses_blink); auto morses_sequence_blink = JLedSequence(JLedSequence::eMode::SEQUENCE, morses_blink);
JLedSequence make_sequence(MorseEffect morse_effect, int gpio, int wpm, int step_length, int n_transmitters){
int ms_per_dit = 1000 * (60 / (50 * wpm));
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; int word_space_ms = ms_per_dit * 7;
MorseEffect morse_effect(message, ms_per_dit);
int period = morse_effect.Period(); int period = morse_effect.Period();
int repeats = step_length / period; int repeats = 2;//step_length / period;
int remainder_wait = step_length - (period * repeats); int remainder_wait = step_length - (period * repeats);
int total_wait = ((step_length * (n_transmitters - 1) + remainder_wait)); int total_wait = ((step_length * (n_transmitters - 1) + remainder_wait));
//auto blinker_continuous = JLed(gpio).UserFunc(&morse_effect).Repeat(repeats).DelayAfter(word_space_ms);
//auto blinker_continuous_wait = JLed(gpio).Off(total_wait);
JLed morses_blink[] = { JLed morses_blink[] = {
JLed(gpio).UserFunc(&morse_effect).Repeat(repeats).DelayAfter(word_space_ms), JLed(blinker).UserFunc(&morse_effect).Repeat(repeats).DelayAfter(word_space_ms),
JLed(gpio).Off(total_wait) JLed(blinker).Off(total_wait)
}; };
auto sequence = JLedSequence(JLedSequence::eMode::SEQUENCE, morses_blink); if (seq){
return sequence; 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);
auto morses_sequence_blink_test = make_sequence(morseEffectMOE, blinker, 10, 10000, 2);
//================================================================================ //================================================================================
@ -369,6 +378,8 @@ auto morses_sequence_blink_test = make_sequence(morseEffectMOE, blinker, 10, 100
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
pinMode(alarmPin, INPUT_PULLUP); // Set alarm pin as pullup pinMode(alarmPin, INPUT_PULLUP); // Set alarm pin as pullup
if (! rtc.begin()) { if (! rtc.begin()) {
@ -599,6 +610,8 @@ void loop() {
// Timers // Timers
timer.tick(); timer.tick();
//morses_sequence_blink_test->Forever().Update();
// 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.
if(yourInputMsg != yourInputMsg_old){ if(yourInputMsg != yourInputMsg_old){