diff options
Diffstat (limited to 'platformio/temphum/src/temphum.h')
-rw-r--r-- | platformio/temphum/src/temphum.h | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/platformio/temphum/src/temphum.h b/platformio/temphum/src/temphum.h index 824b9bf..3d8f373 100644 --- a/platformio/temphum/src/temphum.h +++ b/platformio/temphum/src/temphum.h @@ -4,12 +4,34 @@ namespace homekit::temphum { -struct data { - double temp; // celsius - double rh; // relative humidity percentage +struct SensorData { + double temp = 0; // celsius + double rh = 0; // relative humidity percentage }; -void setup(); -struct data read(); + +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) {} +}; }
\ No newline at end of file |