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

solarTimeRTC.ino example prints times without zero padding #9

Open
drf5n opened this issue Apr 18, 2023 · 6 comments
Open

solarTimeRTC.ino example prints times without zero padding #9

drf5n opened this issue Apr 18, 2023 · 6 comments

Comments

@drf5n
Copy link

drf5n commented Apr 18, 2023

The solarTimeRTC example is missing leading zeros on the time elements, and could print ugly times like:

     9:5:1 UTC on Tuesday, April 18, 2023

Serial.print(someTime.Hour);
Serial.print(F(":"));
Serial.print(someTime.Minute);
Serial.print(F(":"));
Serial.print(someTime.Second);
Serial.print(F(" UTC on "));
Serial.print(dayStr(someTime.Wday));
Serial.print(F(", "));
Serial.print(monthStr(someTime.Month));
Serial.print(F(" "));
Serial.print(someTime.Day);
Serial.print(F(", "));
Serial.println(tmYearToCalendar(someTime.Year));

A few lines like this would solve it:

if(someTime.Second<10)Serial.print('0');

Here's a configured simulation:

https://wokwi.com/projects/362382128060882945

image

@KenWillmott
Copy link
Owner

Requires some thought about how to handle this.

@drf5n
Copy link
Author

drf5n commented Apr 20, 2023

Here's a solar tracker simulation with text-based 0 padding and steppers:

https://wokwi.com/projects/362461186756144129

image

And without the zero padding on the times:

image

@KenWillmott
Copy link
Owner

It isn't that I don't understand the issue. I want to have an overview of all the code before just patching it.

@kacza
Copy link

kacza commented Apr 20, 2023

This is just an example and it's up to the programmer to interpret the data.
I am using the library in my solar tracker with no problems so I think discussion of sample code is a waste of time.

@drf5n
Copy link
Author

drf5n commented Apr 20, 2023

I realize it's a nit-picking little thing. Feel free to close with a "won't fix" because the fault lies with Arduino's lack of a Serial.printf("%02d:",0);

I like your library, and am going to use it to build a tracker with steppers like the Wokwi simulation. Thanks.

@KenWillmott
Copy link
Owner

I'm planning to re-write the example using the JeeLabs/Adafruit RTC library because it has a built in function for formatted text output.

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

No branches or pull requests

3 participants