RTC fix time lag correction
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "PCF85063_Driver.h"
|
||||
#include <ctime>
|
||||
#include <utils.h>
|
||||
|
||||
namespace drivers
|
||||
{
|
||||
@@ -18,7 +19,7 @@ namespace drivers
|
||||
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
|
||||
const uint8_t correction = 0xE7; // fast mode -25 correction pulses, because clock is beyond
|
||||
success &= m_i2c.write(m_address, RTC_OFFSET_ADDR, {correction});
|
||||
if (!success)
|
||||
LOG_ERROR("RTC Init Failure");
|
||||
@@ -160,6 +161,22 @@ namespace drivers
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool PCF85063::setOffset(const uint8_t ofst)
|
||||
{
|
||||
LOG_INFO("RTC set offset [", printHex(ofst).c_str(), "]");
|
||||
return m_i2c.write(m_address, RTC_OFFSET_ADDR, {ofst});
|
||||
}
|
||||
|
||||
const uint8_t PCF85063::getOffset()
|
||||
{
|
||||
std::vector<uint8_t> buf;
|
||||
if (m_i2c.read(m_address, RTC_OFFSET_ADDR, 1, buf)) {
|
||||
LOG_INFO("RTC get offset [", printHex(buf.front()).c_str(), "]");
|
||||
return buf.front();
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
const std::string PCF85063::getTimeStr()
|
||||
{
|
||||
datetime_t dt;
|
||||
|
||||
Reference in New Issue
Block a user