#pragma once

#include <cstdint>
#include <driver/i2c_master.h>
#include <esp_err.h>

class I2cDevice {
 public:
  I2cDevice(i2c_master_bus_handle_t i2c_bus, uint8_t addr);

 protected:
  i2c_master_dev_handle_t i2c_device_;

  void WriteReg(uint8_t reg, uint8_t value);  // 保持原有接口不变
  esp_err_t WriteRegWithError(uint8_t reg, uint8_t value);  // 新增带错误返回的接口
  uint8_t ReadReg(uint8_t reg);
  void ReadRegs(uint8_t reg, uint8_t* buffer, size_t length);
};
