#pragma once #include "fgc/IEnvSensor.h" #include #include #include #include namespace fgc { // Real backend: Adafruit SHT41 temperature/humidity sensor on the // LattePanda's own native I2C bus (NOT the Arduino/motor serial link). // Triggers a high-precision measurement every `period`, sleeps out the ~10ms // conversion delay, and reads back on its own thread so the ~100Hz control // loop is never blocked. CRC-8-checked; a failed checksum discards the // sample rather than reporting a bad reading. class Sht41EnvSensor : public IEnvSensor { public: Sht41EnvSensor(std::string i2c_device, uint8_t addr, std::chrono::milliseconds period); ~Sht41EnvSensor() override; void start() override; void stop() override; bool connected() const override; std::optional sample() override; std::string name() const override { return "SHT41"; } private: struct Impl; std::unique_ptr impl_; }; } // namespace fgc