While playing with the Teensy 3.6, its internal RTC, and TimeLib, I came across something funny. In
The code below, the first serial.printf prints the month twice, not the weekday and month
Comment out that line, and uncomment the next two that separates the weekday and month into two separate commands, and all is well. It's as if a string buffer is not clearing?
Bug or something stupid on my part.
i've only been experimenting with this for a few days, so I could be missing something obvious.
Any help would be appreciated,
Bruce
The code below, the first serial.printf prints the month twice, not the weekday and month
Comment out that line, and uncomment the next two that separates the weekday and month into two separate commands, and all is well. It's as if a string buffer is not clearing?
Bug or something stupid on my part.
i've only been experimenting with this for a few days, so I could be missing something obvious.
Any help would be appreciated,
Bruce
Code:
/*
Board: Teensy 3.6
USB Type: Serial
CPU Speed: 180 MHz
Optimize: Smallest Code With LTO <-- setting does not matter
Port: (Teensy3.6) Serial
*/
#include "TimeLib.h"
int main()
{
while (!Serial); // Wait for Arduino Serial Monitor to open
delay(100);
tmElements_t rtc;
for (;;)
{
time_t rtc_raw = rtc_get();
breakTime( rtc_raw, rtc );
Serial.printf( F("%s, %s "), dayStr(rtc.Wday), monthStr(rtc.Month) ); // fails -- prints November twice
//Serial.printf( F("%s, "), dayStr(rtc.Wday) ); // works
//Serial.printf( F("%s "), monthStr(rtc.Month) ); // works
Serial.printf( F("%02d, %04d"), rtc.Day, (rtc.Year + 1970) );
Serial.printf( F(" @ %02d:%02d:%02d\r\n"), rtc.Hour, rtc.Minute, rtc.Second );
delay(5000);
}
return 0;
}
//eob: main()