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

RP2040 fix RTC get/set time methods #2609

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Sming/Arch/Rp2040/Platform/RTC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ uint32_t RtcClass::getRtcSeconds()
checkInit();

datetime_t t;
rtc_get_datetime(&t);
if(!rtc_get_datetime(&t)) {
return 0;
}

DateTime dt;
dt.setTime(t.sec, t.min, t.hour, t.day, t.month, t.year);
dt.setTime(t.sec, t.min, t.hour, t.day, t.month - 1, t.year);

return time_t(dt);
}
Expand All @@ -67,7 +69,7 @@ bool RtcClass::setRtcSeconds(uint32_t seconds)

datetime_t t = {
.year = int16_t(dt.Year),
.month = int8_t(dt.Month),
.month = int8_t(1 + dt.Month),
.day = int8_t(dt.Day),
.dotw = int8_t(dt.DayofWeek),
.hour = int8_t(dt.Hour),
Expand Down