#pragma once #include namespace homekit::temphum { struct SensorData { double temp = 0; // celsius double rh = 0; // relative humidity percentage }; class BaseSensor { protected: int dev_addr; public: explicit BaseSensor(int dev) : dev_addr(dev) {} void setup() const; void writeCommand(int reg) const; virtual SensorData read() = 0; }; class Si7021 : public BaseSensor { public: SensorData read() override; Si7021() : BaseSensor(0x40) {} }; class DHT12 : public BaseSensor { public: SensorData read() override; DHT12() : BaseSensor(0x5c) {} }; }