|
|
@ -12,7 +12,7 @@ void DS3231::begin() |
|
|
|
uint8_t DS3231::getSeconds() |
|
|
|
{ |
|
|
|
uint8_t seconds; |
|
|
|
// read minutes
|
|
|
|
// read seconds
|
|
|
|
seconds = getRegister(DS3231_SECONDS); |
|
|
|
return bcdtodec(seconds); |
|
|
|
} |
|
|
@ -305,24 +305,109 @@ void DS3231::decrementYear() |
|
|
|
setYear(year); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t DS3231::getAlarm1Seconds() |
|
|
|
{ |
|
|
|
return bcdtodec(getRegister(DS3231_ALARM1_SECONDS)); |
|
|
|
} |
|
|
|
|
|
|
|
void DS3231::setAlarm1Seconds(uint8_t seonds) |
|
|
|
{ |
|
|
|
setRegister(DS3231_ALARM1_SECONDS, dectobcd(seconds % 60)); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t DS3231::getAlarm1Minutes() |
|
|
|
{ |
|
|
|
return bcdtodec(getRegister(DS3231_ALARM1_MINUTES)); |
|
|
|
} |
|
|
|
|
|
|
|
void DS3231::setAlarm1Minutes(uint8_t minutes) |
|
|
|
{ |
|
|
|
setRegister(DS3231_ALARM1_MINUTES, dectobcd(minutes % 60)); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t DS3231::getAlarm1Hours() |
|
|
|
{ |
|
|
|
return bcdtodec(getRegister(DS3231_ALARM1_HOURS)); |
|
|
|
} |
|
|
|
|
|
|
|
void DS3231::setAlarm1Hours(uint8_t hours) |
|
|
|
{ |
|
|
|
setRegister(DS3231_ALARM1_HOURS, dectobcd(hours % 24)); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t DS3231::getAlarm1Date() |
|
|
|
{ |
|
|
|
return bcdtodec(getRegister(DS3231_ALARM1_DATE)); |
|
|
|
} |
|
|
|
|
|
|
|
void DS3231::setAlarm1Date(uint8_t date) |
|
|
|
{ |
|
|
|
setRegister(DS3231_ALARM1_DATE, dectobcd(data % 31)); |
|
|
|
} |
|
|
|
|
|
|
|
void DS3231::setAlarm1Mask(uint8_t mask) |
|
|
|
{ |
|
|
|
setRegister(DS3231_ALARM1_SECONDS, dectobcd(getAlarm1Seconds()) | ((mask & 0b00000001) << 7)); |
|
|
|
setRegister(DS3231_ALARM1_MINUTES, dectobcd(getAlarm1Minutes()) | ((mask & 0b00000010) << 6)); |
|
|
|
setRegister(DS3231_ALARM1_HOURS, dectobcd(getAlarm1Hours()) | ((mask & 0b00000100) << 5)); |
|
|
|
setRegister(DS3231_ALARM1_DATE, dectobcd(getAlarm1Date()) | ((mask & 0b00001000) << 4)); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t DS3231::getAlarm2Minutes() |
|
|
|
{ |
|
|
|
return bcdtodec(getRegister(DS3231_ALARM2_MINUTES)); |
|
|
|
} |
|
|
|
|
|
|
|
void DS3231::setAlarm2Minutes(uint8_t minutes) |
|
|
|
{ |
|
|
|
setRegister(DS3231_ALARM2_MINUTES, dectobcd(minutes % 60)); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t DS3231::getAlarm2Hours() |
|
|
|
{ |
|
|
|
return bcdtodec(getRegister(DS3231_ALARM2_HOURS)); |
|
|
|
} |
|
|
|
|
|
|
|
void DS3231::setAlarm2Hours(uint8_t hours) |
|
|
|
{ |
|
|
|
setRegister(DS3231_ALARM2_HOURS, dectobcd(hours % 24)); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t DS3231::getAlarm2Date() |
|
|
|
{ |
|
|
|
return bcdtodec(getRegister(DS3231_ALARM2_DATE)); |
|
|
|
} |
|
|
|
|
|
|
|
void DS3231::setAlarm2Date(uint8_t date) |
|
|
|
{ |
|
|
|
setRegister(DS3231_ALARM2_DATE, dectobcd(date % 31)); |
|
|
|
} |
|
|
|
|
|
|
|
void DS3231::setAlarm2Mask(uint8_t mask) |
|
|
|
{ |
|
|
|
setRegister(DS3231_ALARM2_MINUTES, dectobcd(getAlarm2Minutes()) | ((mask & 0b00000001) << 7)); |
|
|
|
setRegister(DS3231_ALARM2_HOURS, dectobcd(getAlarm2Hours()) | ((mask & 0b00000010) << 6)); |
|
|
|
setRegister(DS3231_ALARM2_DATE, dectobcd(getAlarm2Date()) | ((mask & 0b00000100) << 5)); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t DS3231::getControlRegister() |
|
|
|
{ |
|
|
|
return bcdtodec(getRegister(DS3231_CONTROL)); |
|
|
|
return getRegister(DS3231_CONTROL); |
|
|
|
} |
|
|
|
|
|
|
|
void DS3231::setControlRegister(uint8_t value) |
|
|
|
{ |
|
|
|
setRegister(DS3231_CONTROL, dectobcd(value)); |
|
|
|
setRegister(DS3231_CONTROL, value); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t DS3231::getStatusRegister() |
|
|
|
{ |
|
|
|
return bcdtodec(getRegister(DS3231_STATUS)); |
|
|
|
return getRegister(DS3231_STATUS); |
|
|
|
} |
|
|
|
|
|
|
|
void DS3231::setStatusRegister(uint8_t value) |
|
|
|
{ |
|
|
|
setRegister(DS3231_STATUS, dectobcd(value)); |
|
|
|
setRegister(DS3231_STATUS, value); |
|
|
|
} |
|
|
|
|
|
|
|
uint8_t DS3231::getTemperature() |
|
|
|