diff --git a/esphome/components/pcf85063/pcf85063.cpp b/esphome/components/pcf85063/pcf85063.cpp index debc007..941278d 100644 --- a/esphome/components/pcf85063/pcf85063.cpp +++ b/esphome/components/pcf85063/pcf85063.cpp @@ -81,6 +81,16 @@ void PCF85063Component::write_time() { this->write_rtc_(); } +void PCF85063Component::write_nvram(uint8_t data) { + this->pcf85063_.reg.nvram = data; + this->write_bytes(0x03, &this->pcf85063_.raw[0x03], 1); +} + +uint8_t PCF85063Component::read_nvram() { + this->read_bytes(0x03, &this->pcf85063_.raw[0x03], 1); + return this->pcf85063_.reg.nvram; +} + bool PCF85063Component::read_rtc_() { if (!this->read_bytes(0, this->pcf85063_.raw, sizeof(this->pcf85063_.raw))) { ESP_LOGE(TAG, "Can't read I2C data."); diff --git a/esphome/components/pcf85063/pcf85063.h b/esphome/components/pcf85063/pcf85063.h index cbe9e2a..3d3589c 100644 --- a/esphome/components/pcf85063/pcf85063.h +++ b/esphome/components/pcf85063/pcf85063.h @@ -27,6 +27,8 @@ class PCF85063Component : public time::RealTimeClock, public i2c::I2CDevice { float get_setup_priority() const override; void read_time(); void write_time(); + void write_nvram(uint8_t); + uint8_t read_nvram(); protected: bool read_rtc_();