#ifndef TMP36_MOCK_H #define TMP36_MOCK_H #include "tmp36.h" /* * TMP36 -- Test mock with programmable values. * * Use this in tests to control exactly what temperature your * application sees, without any real hardware. * * Example: * Tmp36Mock sensor; * sensor.setTemperature(30.0f); * * ThermostatApp app(&sim, &sensor); * app.update(); * * EXPECT_EQ(sim.getPin(FAN_PIN), HIGH); // fan should be on * * You can also track how many times the sensor was read: * sensor.resetReadCount(); * app.update(); * EXPECT_EQ(sensor.readCount(), 1); */ class Tmp36Mock : public TempSensor { public: /// Set the temperature that readCelsius() returns. void setTemperature(float celsius) { temp_c_ = celsius; } /// Set the raw ADC value that readRaw() returns. void setRaw(int raw) { raw_ = raw; } float readCelsius() override { ++read_count_; return temp_c_; } int readRaw() override { ++read_count_; return raw_; } /// How many times has the sensor been read? int readCount() const { return read_count_; } /// Reset the read counter. void resetReadCount() { read_count_ = 0; } private: float temp_c_ = 22.0f; // Default: room temperature int raw_ = 153; // ~22 C at 5V reference int read_count_ = 0; }; #endif // TMP36_MOCK_H