Implement setting RTC date
This commit is contained in:
parent
92096b6101
commit
cd5317db5b
16
ds3231.hpp
16
ds3231.hpp
@ -2,6 +2,8 @@
|
||||
|
||||
#include "../clock.hpp"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "../i2c/i2c.hpp"
|
||||
#include "../type/type.hpp"
|
||||
|
||||
@ -85,7 +87,19 @@ class DS3231 {
|
||||
return dateTime;
|
||||
}
|
||||
|
||||
static void setDate(const Date &date) {}
|
||||
static void setDate(const Date &date)
|
||||
{
|
||||
detail::TimeReg timeReg;
|
||||
timeReg.setYear(date.year);
|
||||
timeReg.setMonth(date.month);
|
||||
timeReg.setDate(date.day);
|
||||
if constexpr (SetDayOfWeek) {
|
||||
timeReg.setDay(calcDayOfWeek(date.year, date.month, date.day) + 1);
|
||||
}
|
||||
|
||||
constexpr auto DATE_OFFSET = offsetof(detail::TimeReg, day);
|
||||
writePartialRegister<TIME_REG_ADDR, DATE_OFFSET>(timeReg);
|
||||
}
|
||||
static void setTime(const Time &time) {}
|
||||
static void setDateTime(const DateTime &dateTime) {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user