Cycle start time
+ Current value: , but only day-of-month HH:MM:SS are used.
+ Only applies when Sending Program is set to "2 - Cycle".
+ You cannot set a cycle start date more than a month in advance.
@@ -437,10 +439,10 @@ void setup() {
}
// Are there any RTC alarms set?
- DateTime alarm_two = rtc.getAlarm2(); // Get the current time
- char buff[] = "Alarm 2 set for at hh:mm:ss DDD, DD MMM YYYY";
- Serial.print(alarm_two.toString(buff));
- Serial.println(" (only accurate to day of month)");
+ DateTime alarm_one = rtc.getAlarm1(); // Get the current time
+ char buff[] = "Alarm 1 set for at hh:mm:ss DDD, DD MMM YYYY";
+ Serial.print(alarm_one.toString(buff));
+ Serial.println(" (only HH:MM:SS day-of-month are accurate)");
// Timer example, blink main LED
pinMode(LED_BUILTIN, OUTPUT); // set LED pin to OUTPUT
@@ -575,14 +577,17 @@ void setup() {
Serial.println(yourInputTime);
// update the RTC time
rtc.adjust(DateTime(yourInputTime));
+ DateTime now = rtc.now();
// Might work to fix random errors? If date is far in the future,
// try to update again.
- while(rtc.now().year() > 2040){
+ // replace if with while if you want it to try a bunch...
+ if(now.year() > 2040){
+ Serial.print("Year is ");
+ Serial.println(now.year());
Serial.println("RTC can't set time. Trying again.");
rtc.adjust(DateTime(yourInputTime));
}
-;
- DateTime now = rtc.now();
+
Serial.print("UTC time from browser: ");
Serial.print(now.year(), DEC);
Serial.print('/');
@@ -627,12 +632,12 @@ void setup() {
// Serial.println(active_tasks);
// Use alarm built into RTC
- rtc.setAlarm2(DateTime(yourInputStartTimeUnix), DS3231_A2_Date);
+ rtc.setAlarm1(DateTime(yourInputStartTimeUnix), DS3231_A1_Date);
//rtc.setAlarm1(DateTime(2020, 6, 25, 15, 34, 0), DS3231_A2_Date);
- DateTime alarm_two = rtc.getAlarm2(); // Get the current time
- char buff[] = "Alarm 2 set for at hh:mm:ss DDD, DD MMM YYYY";
- Serial.print(alarm_two.toString(buff));
- Serial.println(" (only accurate to day of month)");
+ DateTime alarm_one = rtc.getAlarm1(); // Get the current alarm time
+ char buff[] = "Alarm 1 set for at hh:mm:ss DDD, DD MMM YYYY";
+ Serial.print(alarm_one.toString(buff));
+ Serial.println(" (only HH:MM:SS day-of-month are accurate)");
}
// else {
// inputMessage = "No message sent";
@@ -659,20 +664,17 @@ void loop() {
// Timers
timer.tick();
- // This function from https://github.com/garrysblog/DS3231-Alarm-With-Adafruit-RTClib-Library/blob/master/DS3231-RTClib-Adafruit-Alarm-Poll-alarmFired/DS3231-RTClib-Adafruit-Alarm-Poll-alarmFired.ino
- // Check if alarm by polling by using alarmFired
- // We don't want old alarms, though.
- //& (rtc.getAlarm2() >= rtc.now())
- // if ((rtc.alarmFired(2) == 1) ){
- if (digitalRead(alarmPin) == LOW) {
-
+ // This statement from https://github.com/garrysblog/DS3231-Alarm-With-Adafruit-RTClib-Library/blob/master/DS3231-RTClib-Adafruit-Alarm-Poll-alarmFired/DS3231-RTClib-Adafruit-Alarm-Poll-alarmFired.ino
+ // Check if alarm by polling SQW alarm pin
+ if (yourInputSend == 2 & digitalRead(alarmPin) == LOW) {
// Print current time and date
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));
// Disable and clear alarm
- rtc.clearAlarm(2);
+ rtc.clearAlarm(1);
+ rtc.clearAlarm(2); // clear the other one just in case
}
// DateTime now = rtc.now();
@@ -742,7 +744,7 @@ void loop() {
morseToSend_blink.Update();
// if you want to send cycle code and it's not sending, then start it up
- } else if((yourInputSend == 2) & (morseToSend.IsRunning() == true)){
+ } else if((yourInputSend == 2) & (morseToSend.IsRunning() == false)){
morseToSend.Reset().Update();
morseToSend_blink.Reset().Update();