|
@@ -43,8 +43,8 @@ void DS3231_SetTime(int Second, int Minute, int Hour) {
|
|
|
void DS3231_SetDate(int Day, int Date, int Month, int Year, int Century) {
|
|
|
DS3231_REGS regs = {0};
|
|
|
|
|
|
- regs.Day.Value = DecimalToBCD(Day);
|
|
|
- regs.Date.Value = DecimalToBCD(Date);
|
|
|
+ regs.DayOfWeek.Value = DecimalToBCD(Day);
|
|
|
+ regs.Day.Value = DecimalToBCD(Date);
|
|
|
regs.Month.Value = DecimalToBCD(Month);
|
|
|
regs.Month.Century = DecimalToBCD(Century);
|
|
|
regs.Year.Value = DecimalToBCD(Year);
|
|
@@ -73,26 +73,26 @@ void DS3231_GetDate(int *Day, int *Date, int *Month, int *Year) {
|
|
|
regs.AS_BYTE + FIELD_OFFSET(DS3231_REGS, Day),
|
|
|
FIELD_SIZE_THROUGH(DS3231_REGS, Day, Year));
|
|
|
|
|
|
- *Day = BCDToDecimal(regs.Day.Value);
|
|
|
- *Date = BCDToDecimal(regs.Date.Value);
|
|
|
+ *Day = BCDToDecimal(regs.DayOfWeek.Value);
|
|
|
+ *Date = BCDToDecimal(regs.Day.Value);
|
|
|
*Month = BCDToDecimal(regs.Month.Value);
|
|
|
*Year = BCDToDecimal(regs.Year.Value);
|
|
|
}
|
|
|
|
|
|
-bool IsDst(int Day, int Date, int Month, int Hour_24) {
|
|
|
+bool IsDst(int DayOfWeek, int Day, int Month, int Hour_24) {
|
|
|
|
|
|
if (Month < 3 || Month > 11) return false;
|
|
|
|
|
|
if (Month > 3 && Month < 11) return true;
|
|
|
|
|
|
- int prevSunday = Date - Day;
|
|
|
+ int prevSunday = Day - DayOfWeek;
|
|
|
|
|
|
if (Month == 3) {
|
|
|
if (prevSunday < 8) return false;
|
|
|
if (prevSunday > 14) return true;
|
|
|
- return (Date == prevSunday) ? Hour_24 >= 2 : true;
|
|
|
+ return (Day == prevSunday) ? Hour_24 >= 2 : true;
|
|
|
}
|
|
|
|
|
|
if (prevSunday <= 0) return true;
|
|
|
- return (prevSunday == Date && Date <= 7) ? (Hour_24 < 2) : false;
|
|
|
+ return (prevSunday == Day && Day <= 7) ? (Hour_24 < 2) : false;
|
|
|
}
|