#ifndef GRF500_H #define GRF500_H #include #include #define SDA_PIN (16) /**< I2C data line pin */ #define SCL_PIN (17) /**< I2C clock line pin */ #define RANGEFINDER_GRF500_MAX_DISTANCE (50000) /** * @brief The GRF500 class handles interaction with the GRF500 altimeter sensor. * * Provides initialization of I2C, register-mode activation and * periodic distance measurement in a FreeRTOS task. */ class GRF500 { public: /** * @brief Construct a new GRF500 instance * @param addr I2C address (default 0x66) */ explicit GRF500(uint8_t addr = 0x66); ~GRF500() = default; /** * @brief FreeRTOS task entry point (static) * @param pvParameters Pointer to TaskCreator instance */ static void Task(void *pvParameters); /** * @brief Initialize device: start I2C, scan and enable register-mode * @return true on success, false otherwise */ bool begin(); /** * @brief Read and log measurements when available */ void update(); /** * @brief Last measured distance (meters) */ static double distance; private: static uint8_t address; /**< I2C address stored globally */ bool registerModeActivated{false}; uint32_t lastReadMs{0}; /**< Timestamp of last read */ bool scan(uint8_t addr); void enableRegisterMode(); bool checkRegisterMode(); void readDistance(); void readMeasurements(); }; #endif // GRF500_H