- Notifications
You must be signed in to change notification settings - Fork 51
Description
Hello,
I'm using recently updated library.
The library is very comfortable because I don't have to use additional DS3231.
Anyway, I want to talk about the setTime function.
At now, setTime has two types, the first one is setting HH:MM:SS, and another one sets HH:MM:SS:sss AM/PM.
In my opinion, the first one could be changed to setting HH:MM:SS:sss by default.
Of course, there's possibility that someone don't want to initialize the sss = 0, and that would be resolved with the code.
This is my suggestion(It's just an example I use).
In STM32RTC.cpp,
I slightly changed the previous first one setTime to this(It is strange that newline not appears... but there is not really added, I just brought if(subSeconds < 1000) code from the second one, that's the only difference)
void STM32RTC::setTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds) ... syncTime(); if(subSeconds < 1000) { _subSeconds = subSeconds; } ...
and in STM32RTC.h,
void setTime(uint8_t hours, uint8_t minutes, uint8_t seconds, uint32_t subSeconds = 1000);
So, the setTime changes the subSeconds only if the arbitrary subSeconds is set, and unless that, subSeconds will be preserved.
I tried to implement this because I have to daily-network-updated, very precise clock.
I think the setTime can be more generalized with the second setTime, but I'm not an expert to the entire code... Also, in the library it seems that syncTime() must be run before setting the AM/PM so it will involve more edits.
If developers think this is reasonable, I would suggest to adding this and the library could be more specific and comfortable.
Thank you.