From 54ee1a632a183dc165330e33e5a5fade93e8b82e Mon Sep 17 00:00:00 2001 From: tyeth Date: Wed, 20 Aug 2025 14:13:45 +0100 Subject: [PATCH] refactor(mlx90632): use -d model distinction for medical --- src/components/i2c/WipperSnapper_I2C.cpp | 5 +++-- src/components/i2c/WipperSnapper_I2C.h | 2 +- .../drivers/WipperSnapper_I2C_Driver_MLX90632.h | 14 ++++++++------ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/components/i2c/WipperSnapper_I2C.cpp b/src/components/i2c/WipperSnapper_I2C.cpp index 6078dfb1..c301eaeb 100644 --- a/src/components/i2c/WipperSnapper_I2C.cpp +++ b/src/components/i2c/WipperSnapper_I2C.cpp @@ -537,8 +537,9 @@ bool WipperSnapper_Component_I2C::initI2CDevice( _mcp9808->configureDriver(msgDeviceInitReq); drivers.push_back(_mcp9808); WS_DEBUG_PRINTLN("MCP9808 Initialized Successfully!"); - } else if (strcmp("mlx90632", msgDeviceInitReq->i2c_device_name) == 0) { - _mlx90632 = new WipperSnapper_I2C_Driver_MLX90632(this->_i2c, i2cAddress); + } else if (strcmp("mlx90632d_med", msgDeviceInitReq->i2c_device_name) == 0 || + strcmp("mlx90632d_ext", msgDeviceInitReq->i2c_device_name) == 0) { + _mlx90632 = new WipperSnapper_I2C_Driver_MLX90632D(this->_i2c, i2cAddress); if (!_mlx90632->begin()) { WS_DEBUG_PRINTLN("ERROR: Failed to initialize MLX90632!"); _busStatusResponse = diff --git a/src/components/i2c/WipperSnapper_I2C.h b/src/components/i2c/WipperSnapper_I2C.h index 67e8f3b4..33f9fdc7 100644 --- a/src/components/i2c/WipperSnapper_I2C.h +++ b/src/components/i2c/WipperSnapper_I2C.h @@ -181,7 +181,7 @@ private: WipperSnapper_I2C_Driver_LTR390 *_ltr390 = nullptr; WipperSnapper_I2C_Driver_MCP3421 *_mcp3421 = nullptr; WipperSnapper_I2C_Driver_MCP9808 *_mcp9808 = nullptr; - WipperSnapper_I2C_Driver_MLX90632 *_mlx90632 = nullptr; + WipperSnapper_I2C_Driver_MLX90632D *_mlx90632 = nullptr; WipperSnapper_I2C_Driver_MPL115A2 *_mpl115a2 = nullptr; WipperSnapper_I2C_Driver_MPRLS *_mprls = nullptr; WipperSnapper_I2C_Driver_MS8607 *_ms8607 = nullptr; diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_MLX90632.h b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_MLX90632.h index b229fca4..bb90062a 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_MLX90632.h +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_MLX90632.h @@ -1,7 +1,7 @@ /*! * @file WipperSnapper_I2C_Driver_MLX90632.h * - * Device driver for a Melexis MLX90632 thermal FIR sensor. + * Device driver for a Melexis MLX90632-D (medical) thermal FIR sensor. * * Adafruit invests time and resources providing this open source code, * please support Adafruit and open-source hardware by purchasing @@ -22,10 +22,10 @@ /**************************************************************************/ /*! - @brief Sensor driver for the Melexis MLX90632 temperature sensor. + @brief Sensor driver for the Melexis MLX90632-D temperature sensor. */ /**************************************************************************/ -class WipperSnapper_I2C_Driver_MLX90632 : public WipperSnapper_I2C_Driver { +class WipperSnapper_I2C_Driver_MLX90632D : public WipperSnapper_I2C_Driver { public: /*******************************************************************************/ /*! @@ -36,7 +36,7 @@ public: 7-bit device address. */ /*******************************************************************************/ - WipperSnapper_I2C_Driver_MLX90632(TwoWire *i2c, uint16_t sensorAddress) + WipperSnapper_I2C_Driver_MLX90632D(TwoWire *i2c, uint16_t sensorAddress) : WipperSnapper_I2C_Driver(i2c, sensorAddress) { _i2c = i2c; _sensorAddress = sensorAddress; @@ -50,7 +50,7 @@ public: @brief Destructor for an MLX90632 sensor. */ /*******************************************************************************/ - ~WipperSnapper_I2C_Driver_MLX90632() { delete _mlx90632; } + ~WipperSnapper_I2C_Driver_MLX90632D() { delete _mlx90632; } /*******************************************************************************/ /*! @@ -70,10 +70,12 @@ public: /*******************************************************************************/ /*! @brief Configures the MLX90632 sensor and prints its information. + @param extendedInsteadOfMedicalRange + If true, configures the sensor for extended temperature range/acc. @returns True if configuration fetching and setting were successful. */ /*******************************************************************************/ - bool ConfigureAndPrintSensorInfo() { + bool ConfigureAndPrintSensorInfo(bool extendedInsteadOfMedicalRange = false) { // Reset the device if (!_mlx90632->reset()) { WS_PRINTER.println(F("Device reset failed"));