Ben
Well-known member
Here's a sketch to recreate my issue. My Win7 machine needs the delay(), sorry:
Arduino 1.8.1, Teensyduino 1.35 on Windows 7 SP1.No errors or warnings during compile/upload (verbose output enabled).
Using library Time at version 1.5 in folder: C:\[...]\arduino\arduino-1.8.1+teensyduino1.35\hardware\teensy\avr\libraries\Time
It seems the internal RTC on the T3.6 gets initialized with the compile time, which only works if compile time == start time. Power cycling the teensy resets the RTC to compile time and timeStatus() still returns "timeSet". What can I do to make the Time library report "timeSet" only after I called setTime()?
Ben
Arduino 1.8.1, Teensyduino 1.35 on Windows 7 SP1.No errors or warnings during compile/upload (verbose output enabled).
Using library Time at version 1.5 in folder: C:\[...]\arduino\arduino-1.8.1+teensyduino1.35\hardware\teensy\avr\libraries\Time
Code:
#include <TimeLib.h>
void setup()
{
Serial.begin(9600);
delay(2000);
setSyncProvider(getTeensy3Time);
if (timeStatus() == timeSet) {
Serial.println("Time is set.");
} else {
Serial.println("Time is not set.");
}
digitalClockDisplay();
}
void loop()
{
}
time_t getTeensy3Time() {
return Teensy3Clock.get();
}
void digitalClockDisplay() {
// digital clock display of the time
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(" ");
Serial.print(day());
Serial.print(" ");
Serial.print(month());
Serial.print(" ");
Serial.print(year());
Serial.println();
}
void printDigits(int digits) {
// utility function for digital clock display: prints preceding colon and leading 0
Serial.print(":");
if (digits < 10)
Serial.print('0');
Serial.print(digits);
}
It seems the internal RTC on the T3.6 gets initialized with the compile time, which only works if compile time == start time. Power cycling the teensy resets the RTC to compile time and timeStatus() still returns "timeSet". What can I do to make the Time library report "timeSet" only after I called setTime()?
Ben