Snapshot.

This commit is contained in:
mattbk 2023-09-08 08:39:14 -05:00
parent a69128397a
commit af4920d634

View File

@ -165,8 +165,8 @@ Timer<1> timer;
// Example from https://github.com/contrem/arduino-timer#examples
bool toggle_led(void *) {
Serial.print("Timer time: ");
Serial.println(rtc.now().timestamp());
//Serial.print("Timer time: ");
//Serial.println(rtc.now().timestamp());
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN)); // toggle the LED
return true; // keep timer active? true
}
@ -562,7 +562,7 @@ void setup() {
rtc.adjust(DateTime(yourInputTime));
// Might work to fix random errors? If date is far in the future,
// try to update again.
while(rtc.now().year() > 2100){
while(rtc.now().year() > 2040){
Serial.println("RTC can't set time. Trying again.");
rtc.adjust(DateTime(yourInputTime));
}
@ -604,10 +604,16 @@ void setup() {
//}
Serial.println(yourInputStartTimeUnix);
timer.at(millis() + 10000, toggle_led);
Serial.println(millis());
auto active_tasks = timer.size();
Serial.println(active_tasks);
// We can't use arduino-timer for starting a program because
// it relies on millis(), which reset on power cycle.
// timer.at(millis() + 10000, toggle_led);
// Serial.println(millis());
// auto active_tasks = timer.size();
// Serial.println(active_tasks);
// Use alarm built into RTC
rtc.setAlarm2(DateTime(yourInputStartTimeUnix), DS3231_A2_Date);
//rtc.setAlarm1(DateTime(2020, 6, 25, 15, 34, 0), DS3231_A2_Date);
}
// else {
// inputMessage = "No message sent";
@ -634,6 +640,21 @@ 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) ){
// // 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);
// }
// DateTime now = rtc.now();
// Serial.print(now.year(), DEC);
// Serial.print('/');