KenWillmott / SolarPosition

Arduino Library to calculate the position of the sun relative to geographic coordinates
71 stars 21 forks source link

solarTimeRTC.ino example prints times without zero padding #9

Open drf5n opened 1 year ago

drf5n commented 1 year ago

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

https://github.com/KenWillmott/SolarPosition/blob/ba19df4b971837592b78930d4baed061b2b45ac8/examples/solarTimeRTC/solarTimeRTC.ino#L80-L92

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 commented 1 year ago

Requires some thought about how to handle this.

drf5n commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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.