-
(@RussellSher I moved this question out of the welcome discussion into the QA area where it belongs, not an easy thing to do) Hi - I'm new to the community. I 've started using the library which is very useful. I have a similar question to the above post: In my case I want to set the time from a variable. Something like:
but it doesn't update the ds1302 - the 1302 is fine and the example code works. I am obviously not using the RtcDateTime object argument correctly. Could you advise please? regards Originally posted by @RussellSher in #121 (comment) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@RussellSher First, your example doesn't even compile. if you look at the Wiki for RTC, there is no SetDateTime that takes a string; it takes a RtcDateTime object. If you then look at this Wiki entry on the constructors for RtcDateTime you will notice that RtcDateTime can be initialized without using a string at all. Review the examples, they demonstrate the creation of a RtcDateTime object and just construct one using the |
Beta Was this translation helpful? Give feedback.
-
Why use strings at all? From your example, you have the year, month, day of month, etc already. Don't convert to a string, just supply them when you construct the RtcDateTime.
|
Beta Was this translation helpful? Give feedback.
@RussellSher First, your example doesn't even compile. if you look at the Wiki for RTC, there is no SetDateTime that takes a string; it takes a RtcDateTime object.
If you then look at this Wiki entry on the constructors for RtcDateTime you will notice that RtcDateTime can be initialized without using a string at all.
Review the examples, they demonstrate the creation of a RtcDateTime object and just construct one using the
RtcDateTime(uint16_t year, uint8_t month, uint8_t dayOfMonth, uint8_t hour, uint8_t minute, uint8_t second)
constructor.