Hello,
I'm working on a project mod of this great instructable: http://www.instructables.com/id/Kids-Kitchen-That-Says-BEEP/
The original project uses 2 buttons to set the timer - I've switched this out with an encoder. This work fine. Now I want to add the ability to adjust the time of the DS3231. For this I've added a new state: adjustTime, which is entered if the encoder button is held down. So my issue is that I do not understand the TimeLib and DS1307RTC libraries well enough to be able to adjust the time.
I'm using 3 tmElements_t objects (one for time two for timer):
#include <DS1307RTC.h>
#include <TimeLib.h>
#include <Wire.h>
// Create RTC time object
tmElements_t RTC_time;
// Create RTC timer objects to hold the timer
// prevTimes is used to determine whether the timer has changed
tmElements_t Timer, prevTimer;
The idea is to have a function that adds one minute to the current time for each encoder 'tick'. So something like this:
void adjustTimeEnc(int deltaTime){ // deltaTime is an integer from -4(negative 4) to 4(positive 4) (excl. 0) depending on the acceleration of the encoder
adjustTime(60*deltaTime);
}
I am in doubt about the following:
-
The 'adjustTime' function above - should that somehow be pointed to the RTC_Time object? If so how do I do that? RTC_Time.adjustTime(), throws compile error: 'struct tmElements_t' has no member named 'adjustTime'. The documentation and examples for this function seems very limited.
-
How do I make sure the RTC actually updates to the adjusted time? My understanding is that I should use: RTC.set(), however I'm not sure what the argument should be in this case?
I'm sorry if I've completely misunderstood how this works, but I must admit the TimeLib and DS1307RTC libraries are a bit difficult for me to understand. Let me know if you need any more info about my code or setup. And please let me know if I'm going a completely wrong direction.
Thanks in advance
mathies