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

Setting minutes and hours dont wrap properly #47

Open
jacky4566 opened this issue May 31, 2019 · 1 comment
Open

Setting minutes and hours dont wrap properly #47

jacky4566 opened this issue May 31, 2019 · 1 comment

Comments

@jacky4566
Copy link

jacky4566 commented May 31, 2019

I notice there is some weirdness when using the setMinutes, setHours functions.

Using the function
rtc.setHours(rtc.getHours()+1);

allows for setting time between 0 and 32. Shouldn't this wrap around at 24?

Code example:

#include <RTCZero.h>

RTCZero rtc;

void setup() {
  rtc.begin(); // initialize RTC
}

void loop() {
  Serial.print(rtc.getHours());
  Serial.print(":");
  Serial.print(rtc.getMinutes());
  Serial.print(":");
  Serial.print(rtc.getSeconds());
  Serial.println();

  rtc.setHours(rtc.getHours() + 1);
  delay(1000);
}

Output

18:05:33
19:05:34
20:05:35
21:05:36
22:05:37
23:05:38
24:05:39 <-- Not a valid time
25:05:40
26:05:41
27:05:42
28:05:43
29:05:44
30:05:45
31:05:46
00:05:47
01:05:48
@Inv3nt0r1
Copy link

Inv3nt0r1 commented Mar 27, 2020

Hello @jacky4566,
Can you please test and tell me what happens when you pass a value of more than 32?

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

2 participants