set ntp parameters via config file

This commit is contained in:
Emanuele Trabattoni
2025-08-03 12:11:00 +02:00
parent a1a66ebf8e
commit 4a1e944ea2
6 changed files with 39 additions and 20 deletions

View File

@@ -18,9 +18,6 @@ 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 = 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");
}
@@ -163,18 +160,19 @@ namespace drivers
const bool PCF85063::setOffset(const uint8_t ofst)
{
LOG_INFO("RTC set offset [", printHex(ofst).c_str(), "]");
LOG_DEBUG("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();
if (m_i2c.read(m_address, RTC_OFFSET_ADDR, 1, buf))
{
LOG_DEBUG("RTC get offset [", printHex(buf.front()).c_str(), "]");
return buf.front();
}
return {};
return UINT8_MAX;
}
const std::string PCF85063::getTimeStr()