Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This fixes the Serial.print commands in the loop block of PCSynch.ino #2

Merged
merged 2 commits into from
Apr 24, 2017

Conversation

mfindley
Copy link

I was using the PCSynch.ino sketch to set the real time clock (RTC) on my Mayfly board (V0.5) and was confused by the output to the Arduino IDE's serial monitor window. In part, the sketch is supposed to print a user-friendly version of date and time to the Mayfly's serial port every second, but the text in the Arduino serial monitor was slightly garbled. I found errors in two Serial.print commands in the loop() block of the sketch. This pull request only changes the formatting on the serial output in the sketch. It doesn't mess with any of the code that sets or reads data from the RTC or synchronizes with a PC's or time server's clock.

As a side effect, it also fixes the time/date format appearing in the output for PCSynch.exe.

In the loop section of this sketch, there are a series of commands that print the RTC's time and date to the serial pins.  It is updated with the current time every second.  The text output is supposed to be (for example):
    Current RTC Date/Time: Sunday, April 23, 2017 10:10:10 (1492888806) 
When I ran the code after setting the clock, the output was more like:
   Current RTC Date/Time: December, April 22112962017 10:10:10 (1492888806)
The source of the non-sense number between month and year was traced one of the Serial.print commands that used single quotes for the string instead of double quotes.  I fixed it and the date appears to be printing correctly now.
This is a simple change that doesn't affect how the RTC is set or read.  It only changes the printed output for the code.
In the loop section of this sketch, there are a series of commands that print the RTC's time and date to the serial pins.  It is updated with the current time every second.  The text output is supposed to be (for example):
    Current RTC Date/Time: Sunday, April 23, 2017 10:10:10 (1492888806) 
When I ran the code after setting the clock, the output was more like:
   Current RTC Date/Time: December, April 22112962017 10:10:10 (1492888806)
The source of the bug that printed "December" instead of the day-of-the-week was traced one of the Serial.print commands were we subtracted 1 from now.dayOfWeek().  dayOfWeek already used zero-based indexing for the array (i.e. Sunday was index position 0), so didn't need to have anything subtracted from it.  I fixed it and the day of week appears to be printing correctly now.
This is a simple change that doesn't affect how the RTC is set or read.  It only changes the printed output for the code.
@SRGDamia1
Copy link

Thank you!

@SRGDamia1 SRGDamia1 merged commit 04f5e72 into EnviroDIY:master Apr 24, 2017
@mfindley
Copy link
Author

Glad to be a contributor. ... never submitted a pull request before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants