clock correction
This commit is contained in:
BIN
docs/ESP32_clock_adjust.xlsx
Normal file
BIN
docs/ESP32_clock_adjust.xlsx
Normal file
Binary file not shown.
@@ -17,6 +17,9 @@ namespace drivers
|
||||
const uint8_t def_conf2 = RTC_CTRL_2_DEFAULT | RTC_CTRL_2_MI; // enable 1 minute interrupt
|
||||
success &= m_i2c.write(m_address, RTC_CTRL_2_ADDR, {def_conf2});
|
||||
}
|
||||
// set clock correction pulses
|
||||
const uint8_t correction = 0b10000011; // fast mode +3 correction pulses, because clock is beyond
|
||||
success &= m_i2c.write(m_address, RTC_OFFSET_ADDR, {correction});
|
||||
if (!success)
|
||||
LOG_ERROR("RTC Init Failure");
|
||||
}
|
||||
@@ -182,16 +185,17 @@ namespace drivers
|
||||
{
|
||||
tm dtime = datetime2tm(datetime);
|
||||
const std::string buf(std::asctime(&dtime));
|
||||
return buf.substr(0, std::min(buf.find('\n'),buf.find('\r')));
|
||||
return buf.substr(0, std::min(buf.find('\n'), buf.find('\r')));
|
||||
}
|
||||
|
||||
const std::string PCF85063::tm2str(const std::tm &datetime)
|
||||
{
|
||||
const std::string buf(std::asctime(&datetime));
|
||||
return buf.substr(0, std::min(buf.find('\n'),buf.find('\r')));
|
||||
return buf.substr(0, std::min(buf.find('\n'), buf.find('\r')));
|
||||
}
|
||||
|
||||
const std::tm PCF85063::datetime2tm(const datetime_t& datetime) {
|
||||
const std::tm PCF85063::datetime2tm(const datetime_t &datetime)
|
||||
{
|
||||
tm dtime;
|
||||
dtime.tm_sec = datetime.second;
|
||||
dtime.tm_min = datetime.minute;
|
||||
|
||||
Reference in New Issue
Block a user