Compare commits

..

5 commits

Author SHA1 Message Date
Tyeth Gundry
2723c39d84 fix(qmc883p): set range to 30G and log xyz until vector supported 2025-08-28 19:23:55 +01:00
Tyeth Gundry
e900680569 fix(huzzah): platformIO ram .text1 section size (iram1_0_seg) 2025-08-27 11:31:33 +01:00
Tyeth Gundry
2a2c2cf579 fix(qmc5883p): use continuous mode instead of normal 2025-08-26 20:50:43 +01:00
Tyeth Gundry
1ef9d169ec add(qmc5883p): initial vectorless result 2025-08-26 20:28:25 +01:00
Tyeth Gundry
a1b412cda4 fix(partitions): 4MB NoOTA in platformIO.ini 2025-08-26 19:21:36 +01:00
9 changed files with 129 additions and 436 deletions

View file

@ -1,5 +1,5 @@
name=Adafruit WipperSnapper name=Adafruit WipperSnapper
version=1.0.0-beta.111 version=1.0.0-beta.110
author=Adafruit author=Adafruit
maintainer=Adafruit <adafruitio@adafruit.com> maintainer=Adafruit <adafruitio@adafruit.com>
sentence=Arduino application for Adafruit.io WipperSnapper sentence=Arduino application for Adafruit.io WipperSnapper
@ -7,4 +7,4 @@ paragraph=Arduino application for Adafruit.io WipperSnapper
category=Communication category=Communication
url=https://github.com/adafruit/Adafruit_Wippersnapper_Arduino url=https://github.com/adafruit/Adafruit_Wippersnapper_Arduino
architectures=* architectures=*
depends=OmronD6T - Community Fork, SdFat - Adafruit Fork, Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit INA260 Library, Adafruit INA237 and INA238 Library, Adafruit LTR329 and LTR303, Adafruit LTR390 Library, Adafruit MCP3421, Adafruit MLX90632 Library, Adafruit NAU7802 Library, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit AS5600 Library, Adafruit BME280 Library, Adafruit BMP280 Library, Adafruit BMP3XX Library, Adafruit DPS310, Adafruit DS248x, Adafruit SCD30, Adafruit SGP30 Sensor, Adafruit SGP40 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, Sensirion I2C SEN66, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MS8607, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit MPL115A2, Adafruit MPRLS Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit VL53L1X, STM32duino VL53L4CD, STM32duino VL53L4CX, Adafruit_VL6180X, Adafruit PM25 AQI Sensor, Adafruit VCNL4020 Library, Adafruit VCNL4040, Adafruit VCNL4200 Library, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit LPS2X, Adafruit LPS28, Adafruit LPS35HW, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit HTU21DF Library, Adafruit HTU31D Library, Adafruit PCT2075, hp_BH1750, ENS160 - Adafruit Fork, Adafruit BusIO, Adafruit Unified Sensor, Sensirion Core, Adafruit GFX Library, Adafruit LED Backpack Library, Adafruit LiquidCrystal, Adafruit SH110X, Adafruit SSD1306 depends=OmronD6T - Community Fork, SdFat - Adafruit Fork, Adafruit NeoPixel, Adafruit SPIFlash, ArduinoJson, Adafruit DotStar, Adafruit HDC302x, Adafruit INA219, Adafruit INA260 Library, Adafruit INA237 and INA238 Library, Adafruit LTR329 and LTR303, Adafruit LTR390 Library, Adafruit MCP3421, Adafruit NAU7802 Library, Adafruit SleepyDog Library, Adafruit TMP117, Adafruit TinyUSB Library, Adafruit AHTX0, Adafruit BME280 Library, Adafruit BMP280 Library, Adafruit BMP3XX Library, Adafruit DPS310, Adafruit DS248x, Adafruit SCD30, Adafruit SGP30 Sensor, Adafruit SGP40 Sensor, Sensirion I2C SCD4x, Sensirion I2C SEN5X, Sensirion I2C SEN66, arduino-sht, Adafruit Si7021 Library, Adafruit MQTT Library, Adafruit MS8607, Adafruit MCP9808 Library, Adafruit MCP9600 Library, Adafruit MPL115A2, Adafruit MPRLS Library, Adafruit TSL2591 Library, Adafruit_VL53L0X, Adafruit VL53L1X, STM32duino VL53L4CD, STM32duino VL53L4CX, Adafruit_VL6180X, Adafruit PM25 AQI Sensor, Adafruit QMC5883P Library, Adafruit VCNL4020 Library, Adafruit VCNL4040, Adafruit VCNL4200 Library, Adafruit VEML7700 Library, Adafruit LC709203F, Adafruit LPS2X, Adafruit LPS28, Adafruit LPS35HW, Adafruit seesaw Library, Adafruit BME680 Library, Adafruit MAX1704X, Adafruit ADT7410 Library, Adafruit HTS221, Adafruit HTU21DF Library, Adafruit HTU31D Library, Adafruit PCT2075, hp_BH1750, ENS160 - Adafruit Fork, Adafruit BusIO, Adafruit Unified Sensor, Sensirion Core, Adafruit GFX Library, Adafruit LED Backpack Library, Adafruit LiquidCrystal, Adafruit SH110X, Adafruit SSD1306

View file

@ -32,7 +32,6 @@ lib_deps =
adafruit/ENS160 - Adafruit Fork adafruit/ENS160 - Adafruit Fork
adafruit/Adafruit SleepyDog Library adafruit/Adafruit SleepyDog Library
adafruit/Adafruit AHTX0 adafruit/Adafruit AHTX0
adafruit/Adafruit AS5600 Library
adafruit/Adafruit BME280 Library adafruit/Adafruit BME280 Library
adafruit/Adafruit BMP280 Library adafruit/Adafruit BMP280 Library
adafruit/Adafruit BMP3XX Library adafruit/Adafruit BMP3XX Library
@ -48,6 +47,7 @@ lib_deps =
adafruit/Adafruit LTR390 Library adafruit/Adafruit LTR390 Library
adafruit/Adafruit LTR329 and LTR303 adafruit/Adafruit LTR329 and LTR303
adafruit/Adafruit PCT2075 adafruit/Adafruit PCT2075
adafruit/Adafruit QMC5883P Library
adafruit/Adafruit SCD30 adafruit/Adafruit SCD30
adafruit/Adafruit SGP30 Sensor adafruit/Adafruit SGP30 Sensor
adafruit/Adafruit SGP40 Sensor adafruit/Adafruit SGP40 Sensor
@ -58,7 +58,6 @@ lib_deps =
adafruit/Adafruit MCP3421 adafruit/Adafruit MCP3421
adafruit/Adafruit MCP9808 Library adafruit/Adafruit MCP9808 Library
adafruit/Adafruit MCP9600 Library adafruit/Adafruit MCP9600 Library
adafruit/Adafruit MLX90632 Library
adafruit/Adafruit MPL115A2 adafruit/Adafruit MPL115A2
adafruit/Adafruit MPRLS Library adafruit/Adafruit MPRLS Library
adafruit/Adafruit MS8607 adafruit/Adafruit MS8607
@ -482,9 +481,10 @@ build_flags =
-DNON32XFER_FAST -DNON32XFER_FAST
-DDEBUG_DISABLED -DDEBUG_DISABLED
-DDEBUG_LEVEL_NONE -DDEBUG_LEVEL_NONE
-DPIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48 ; avoid section `.text1' will not fit in region `iram1_0_seg'
board_build.eesz=4M2M board_build.eesz=4M2M
board_build.filesystem = littlefs board_build.filesystem = littlefs
upload_port = /dev/cu.SLAB_USBtoUART upload_port = COM19
; SAMD51 Boards ; ; SAMD51 Boards ;

View file

@ -142,7 +142,7 @@
#endif #endif
#define WS_VERSION \ #define WS_VERSION \
"1.0.0-beta.111" ///< WipperSnapper app. version (semver-formatted) "1.0.0-beta.110" ///< WipperSnapper app. version (semver-formatted)
// Reserved Adafruit IO MQTT topics // Reserved Adafruit IO MQTT topics
#define TOPIC_IO_THROTTLE "/throttle" ///< Adafruit IO Throttle MQTT Topic #define TOPIC_IO_THROTTLE "/throttle" ///< Adafruit IO Throttle MQTT Topic

View file

@ -236,16 +236,6 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
} }
_ahtx0->configureDriver(msgDeviceInitReq); _ahtx0->configureDriver(msgDeviceInitReq);
drivers.push_back(_ahtx0); drivers.push_back(_ahtx0);
} else if (strcmp("as5600", msgDeviceInitReq->i2c_device_name) == 0) {
_as5600 = new WipperSnapper_I2C_Driver_AS5600(this->_i2c, i2cAddress);
if (!_as5600->begin()) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize AS5600 chip!");
_busStatusResponse =
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
return false;
}
_as5600->configureDriver(msgDeviceInitReq);
drivers.push_back(_as5600);
} else if (strcmp("bh1750", msgDeviceInitReq->i2c_device_name) == 0) { } else if (strcmp("bh1750", msgDeviceInitReq->i2c_device_name) == 0) {
_bh1750 = new WipperSnapper_I2C_Driver_BH1750(this->_i2c, i2cAddress); _bh1750 = new WipperSnapper_I2C_Driver_BH1750(this->_i2c, i2cAddress);
if (!_bh1750->begin()) { if (!_bh1750->begin()) {
@ -547,33 +537,6 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
_mcp9808->configureDriver(msgDeviceInitReq); _mcp9808->configureDriver(msgDeviceInitReq);
drivers.push_back(_mcp9808); drivers.push_back(_mcp9808);
WS_DEBUG_PRINTLN("MCP9808 Initialized Successfully!"); WS_DEBUG_PRINTLN("MCP9808 Initialized Successfully!");
} else if (strcmp("mlx90632b", msgDeviceInitReq->i2c_device_name) == 0 ||
strcmp("mlx90632d_med", msgDeviceInitReq->i2c_device_name) == 0) {
_mlx90632d = new WipperSnapper_I2C_Driver_MLX90632D(this->_i2c, i2cAddress);
if (!_mlx90632d->begin()) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize MLX90632!");
_busStatusResponse =
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
return false;
}
_mlx90632d->configureDriver(msgDeviceInitReq);
drivers.push_back(_mlx90632d);
WS_DEBUG_PRINTLN("MLX90632 Initialized Successfully!");
} else if (strcmp("mlx90632d_ext", msgDeviceInitReq->i2c_device_name) == 0) {
_mlx90632d_ext =
new WipperSnapper_I2C_Driver_MLX90632D(this->_i2c, i2cAddress);
// set extended range
if (!_mlx90632d_ext->begin() ||
!_mlx90632d_ext->ConfigureAndPrintSensorInfo(true)) {
WS_DEBUG_PRINTLN(
"ERROR: Failed to initialize MLX90632D with extended range!");
_busStatusResponse =
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
return false;
}
_mlx90632d_ext->configureDriver(msgDeviceInitReq);
drivers.push_back(_mlx90632d_ext);
WS_DEBUG_PRINTLN("MLX90632D_EXT Initialized Successfully!");
} else if (strcmp("mpl115a2", msgDeviceInitReq->i2c_device_name) == 0) { } else if (strcmp("mpl115a2", msgDeviceInitReq->i2c_device_name) == 0) {
_mpl115a2 = new WipperSnapper_I2C_Driver_MPL115A2(this->_i2c, i2cAddress); _mpl115a2 = new WipperSnapper_I2C_Driver_MPL115A2(this->_i2c, i2cAddress);
if (!_mpl115a2->begin()) { if (!_mpl115a2->begin()) {
@ -774,6 +737,17 @@ bool WipperSnapper_Component_I2C::initI2CDevice(
_pm25->configureDriver(msgDeviceInitReq); _pm25->configureDriver(msgDeviceInitReq);
drivers.push_back(_pm25); drivers.push_back(_pm25);
WS_DEBUG_PRINTLN("PM2.5 AQI Sensor Initialized Successfully!"); WS_DEBUG_PRINTLN("PM2.5 AQI Sensor Initialized Successfully!");
} else if (strcmp("qmc5883p", msgDeviceInitReq->i2c_device_name) == 0) {
_qmc5883p = new WipperSnapper_I2C_Driver_QMC5883P(this->_i2c, i2cAddress);
if (!_qmc5883p->begin()) {
WS_DEBUG_PRINTLN("ERROR: Failed to initialize QMC5883P Sensor!");
_busStatusResponse =
wippersnapper_i2c_v1_BusResponse_BUS_RESPONSE_DEVICE_INIT_FAIL;
return false;
}
_qmc5883p->configureDriver(msgDeviceInitReq);
drivers.push_back(_qmc5883p);
WS_DEBUG_PRINTLN("QMC5883P Sensor Initialized Successfully!");
} else if (strcmp("lc709203f", msgDeviceInitReq->i2c_device_name) == 0) { } else if (strcmp("lc709203f", msgDeviceInitReq->i2c_device_name) == 0) {
_lc = new WipperSnapper_I2C_Driver_LC709203F(this->_i2c, i2cAddress); _lc = new WipperSnapper_I2C_Driver_LC709203F(this->_i2c, i2cAddress);
if (!_lc->begin()) { if (!_lc->begin()) {

View file

@ -22,7 +22,6 @@
#include "drivers/WipperSnapper_I2C_Driver.h" #include "drivers/WipperSnapper_I2C_Driver.h"
#include "drivers/WipperSnapper_I2C_Driver_ADT7410.h" #include "drivers/WipperSnapper_I2C_Driver_ADT7410.h"
#include "drivers/WipperSnapper_I2C_Driver_AHTX0.h" #include "drivers/WipperSnapper_I2C_Driver_AHTX0.h"
#include "drivers/WipperSnapper_I2C_Driver_AS5600.h"
#include "drivers/WipperSnapper_I2C_Driver_BH1750.h" #include "drivers/WipperSnapper_I2C_Driver_BH1750.h"
#include "drivers/WipperSnapper_I2C_Driver_BME280.h" #include "drivers/WipperSnapper_I2C_Driver_BME280.h"
#include "drivers/WipperSnapper_I2C_Driver_BME680.h" #include "drivers/WipperSnapper_I2C_Driver_BME680.h"
@ -51,7 +50,6 @@
#include "drivers/WipperSnapper_I2C_Driver_MAX17048.h" #include "drivers/WipperSnapper_I2C_Driver_MAX17048.h"
#include "drivers/WipperSnapper_I2C_Driver_MCP3421.h" #include "drivers/WipperSnapper_I2C_Driver_MCP3421.h"
#include "drivers/WipperSnapper_I2C_Driver_MCP9808.h" #include "drivers/WipperSnapper_I2C_Driver_MCP9808.h"
#include "drivers/WipperSnapper_I2C_Driver_MLX90632D.h"
#include "drivers/WipperSnapper_I2C_Driver_MPL115A2.h" #include "drivers/WipperSnapper_I2C_Driver_MPL115A2.h"
#include "drivers/WipperSnapper_I2C_Driver_MPRLS.h" #include "drivers/WipperSnapper_I2C_Driver_MPRLS.h"
#include "drivers/WipperSnapper_I2C_Driver_MS8607.h" #include "drivers/WipperSnapper_I2C_Driver_MS8607.h"
@ -64,6 +62,7 @@
#include "drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h" #include "drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h"
#include "drivers/WipperSnapper_I2C_Driver_PCT2075.h" #include "drivers/WipperSnapper_I2C_Driver_PCT2075.h"
#include "drivers/WipperSnapper_I2C_Driver_PM25.h" #include "drivers/WipperSnapper_I2C_Driver_PM25.h"
#include "drivers/WipperSnapper_I2C_Driver_QMC5883P.h"
#include "drivers/WipperSnapper_I2C_Driver_SCD30.h" #include "drivers/WipperSnapper_I2C_Driver_SCD30.h"
#include "drivers/WipperSnapper_I2C_Driver_SCD4X.h" #include "drivers/WipperSnapper_I2C_Driver_SCD4X.h"
#include "drivers/WipperSnapper_I2C_Driver_SEN5X.h" #include "drivers/WipperSnapper_I2C_Driver_SEN5X.h"
@ -95,6 +94,7 @@ class WipperSnapper_I2C_Driver_INA260;
class WipperSnapper_I2C_Driver_INA237; class WipperSnapper_I2C_Driver_INA237;
class WipperSnapper_I2C_Driver_INA238; class WipperSnapper_I2C_Driver_INA238;
class WipperSnapper_I2C_Driver_INA228; class WipperSnapper_I2C_Driver_INA228;
class WipperSnapper_I2C_Driver_QMC5883P;
/**************************************************************************/ /**************************************************************************/
/*! /*!
@ -159,7 +159,6 @@ private:
_drivers_out; ///< List of i2c output drivers _drivers_out; ///< List of i2c output drivers
// Sensor driver objects // Sensor driver objects
WipperSnapper_I2C_Driver_AHTX0 *_ahtx0 = nullptr; WipperSnapper_I2C_Driver_AHTX0 *_ahtx0 = nullptr;
WipperSnapper_I2C_Driver_AS5600 *_as5600 = nullptr;
WipperSnapper_I2C_Driver_D6T1A *_d6t1a = nullptr; WipperSnapper_I2C_Driver_D6T1A *_d6t1a = nullptr;
WipperSnapper_I2C_Driver_DPS310 *_dps310 = nullptr; WipperSnapper_I2C_Driver_DPS310 *_dps310 = nullptr;
WipperSnapper_I2C_Driver_DS2484 *_ds2484 = nullptr; WipperSnapper_I2C_Driver_DS2484 *_ds2484 = nullptr;
@ -183,8 +182,6 @@ private:
WipperSnapper_I2C_Driver_LTR390 *_ltr390 = nullptr; WipperSnapper_I2C_Driver_LTR390 *_ltr390 = nullptr;
WipperSnapper_I2C_Driver_MCP3421 *_mcp3421 = nullptr; WipperSnapper_I2C_Driver_MCP3421 *_mcp3421 = nullptr;
WipperSnapper_I2C_Driver_MCP9808 *_mcp9808 = nullptr; WipperSnapper_I2C_Driver_MCP9808 *_mcp9808 = nullptr;
WipperSnapper_I2C_Driver_MLX90632D *_mlx90632d = nullptr;
WipperSnapper_I2C_Driver_MLX90632D *_mlx90632d_ext = nullptr;
WipperSnapper_I2C_Driver_MPL115A2 *_mpl115a2 = nullptr; WipperSnapper_I2C_Driver_MPL115A2 *_mpl115a2 = nullptr;
WipperSnapper_I2C_Driver_MPRLS *_mprls = nullptr; WipperSnapper_I2C_Driver_MPRLS *_mprls = nullptr;
WipperSnapper_I2C_Driver_MS8607 *_ms8607 = nullptr; WipperSnapper_I2C_Driver_MS8607 *_ms8607 = nullptr;
@ -202,6 +199,7 @@ private:
WipperSnapper_I2C_Driver_SGP40 *_sgp40 = nullptr; WipperSnapper_I2C_Driver_SGP40 *_sgp40 = nullptr;
WipperSnapper_I2C_Driver_PCT2075 *_pct2075 = nullptr; WipperSnapper_I2C_Driver_PCT2075 *_pct2075 = nullptr;
WipperSnapper_I2C_Driver_PM25 *_pm25 = nullptr; WipperSnapper_I2C_Driver_PM25 *_pm25 = nullptr;
WipperSnapper_I2C_Driver_QMC5883P *_qmc5883p = nullptr;
WipperSnapper_I2C_Driver_SI7021 *_si7021 = nullptr; WipperSnapper_I2C_Driver_SI7021 *_si7021 = nullptr;
WipperSnapper_I2C_Driver_SHT4X *_sht4x = nullptr; WipperSnapper_I2C_Driver_SHT4X *_sht4x = nullptr;
WipperSnapper_I2C_Driver_SHT3X *_sht3x = nullptr; WipperSnapper_I2C_Driver_SHT3X *_sht3x = nullptr;

View file

@ -1,155 +0,0 @@
/*!
* @file WipperSnapper_I2C_Driver_AS5600.h
*
* Device driver for the AS5600 Magnetic Angle sensor.
*
* Adafruit invests time and resources providing this open source code,
* please support Adafruit and open-source hardware by purchasing
* products from Adafruit!
*
* Copyright (c) Tyeth Gundry 2024 for Adafruit Industries.
*
* MIT license, all text here must be included in any redistribution.
*
*/
#ifndef WipperSnapper_I2C_Driver_AS5600_H
#define WipperSnapper_I2C_Driver_AS5600_H
#include <Adafruit_AS5600.h>
#include "WipperSnapper_I2C_Driver.h"
#include "Wippersnapper.h"
/**************************************************************************/
/*!
@brief Class that provides a driver interface for a AS5600 sensor.
*/
/**************************************************************************/
class WipperSnapper_I2C_Driver_AS5600 : public WipperSnapper_I2C_Driver {
public:
/*******************************************************************************/
/*!
@brief Constructor for the AS5600 sensor.
@param i2c
The I2C interface.
@param sensorAddress
7-bit device address.
*/
/*******************************************************************************/
WipperSnapper_I2C_Driver_AS5600(TwoWire *i2c, uint16_t sensorAddress)
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {
_as5600 = nullptr;
_angle = 0;
}
/*******************************************************************************/
/*!
@brief Destructor for an AS5600 sensor.
*/
/*******************************************************************************/
~WipperSnapper_I2C_Driver_AS5600() {
if (_as5600) {
delete _as5600;
_as5600 = nullptr;
}
}
/*******************************************************************************/
/*!
@brief Initializes the AS5600 sensor and begins I2C.
@returns True if initialized successfully, False otherwise.
*/
/*******************************************************************************/
bool begin() {
_as5600 = new Adafruit_AS5600();
if (!_as5600->begin((uint8_t)_sensorAddress, _i2c)) {
WS_DEBUG_PRINTLN("Failed to find AS5600 chip");
return false;
}
if (!configureSensor()) {
WS_DEBUG_PRINTLN("Failed to configure AS5600 sensor");
return false;
}
return true;
}
/*******************************************************************************/
/*!
@brief Configures the AS5600 sensor.
@returns True if the sensor was configured successfully, False otherwise.
*/
/*******************************************************************************/
bool configureSensor() {
return _as5600->enableWatchdog(false) &&
// Normal (high) power mode
_as5600->setPowerMode(AS5600_POWER_MODE_NOM) &&
// No Hysteresis
_as5600->setHysteresis(AS5600_HYSTERESIS_OFF) &&
// analog output (0-VCC for 0-360 degrees)
_as5600->setOutputStage(AS5600_OUTPUT_STAGE_ANALOG_FULL) &&
// setup filters
_as5600->setSlowFilter(AS5600_SLOW_FILTER_16X) &&
_as5600->setFastFilterThresh(AS5600_FAST_FILTER_THRESH_SLOW_ONLY) &&
// Reset position settings to defaults
_as5600->setZPosition(0) && _as5600->setMPosition(4095) &&
_as5600->setMaxAngle(4095);
}
/*******************************************************************************/
/*!
@brief Reads the Angle sensor.
@returns True if the sensor was read successfully, False otherwise.
*/
/*******************************************************************************/
bool readSensor() {
if (!_as5600->isMagnetDetected()) {
WS_DEBUG_PRINTLN("Magnet not detected!");
return false;
}
// Continuously read and display angle values
uint16_t rawAngle = _as5600->getRawAngle();
uint16_t angle = _as5600->getAngle();
WS_DEBUG_PRINT("AS5600 Raw: ");
WS_DEBUG_PRINT(rawAngle);
WS_DEBUG_PRINT(" | Scaled: ");
WS_DEBUG_PRINT(angle);
// Check status conditions
if (_as5600->isAGCminGainOverflow()) {
WS_DEBUG_PRINTLN(" | MH: magnet too strong");
return false;
}
if (_as5600->isAGCmaxGainOverflow()) {
WS_DEBUG_PRINTLN(" | ML: magnet too weak");
return false;
}
_angle = ((float)angle / 4095.0) * 360.0;
return true;
}
/*******************************************************************************/
/*!
@brief Reads the Angle sensor with short wait for data.
@param rawEvent
Angle sensor reading
@returns True if the sensor event was obtained successfully, False
otherwise.
*/
/*******************************************************************************/
bool getEventRaw(sensors_event_t *rawEvent) {
if (!readSensor()) {
return false;
}
rawEvent->data[0] = _angle;
return true;
}
protected:
float _angle; ///< Current angle reading from the AS5600 sensor
Adafruit_AS5600 *_as5600; ///< Pointer to AS5600 sensor object
};
#endif // WipperSnapper_I2C_Driver_AS5600

View file

@ -1,233 +0,0 @@
/*!
* @file WipperSnapper_I2C_Driver_MLX90632D.h
*
* 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
* products from Adafruit!
*
* Copyright (c) Tyeth Gundry 2025 for Adafruit Industries.
*
* MIT license, all text here must be included in any redistribution.
*
*/
#ifndef WipperSnapper_I2C_Driver_MLX90632D_H
#define WipperSnapper_I2C_Driver_MLX90632D_H
#include <Adafruit_MLX90632.h>
#include "WipperSnapper_I2C_Driver.h"
/**************************************************************************/
/*!
@brief Sensor driver for the Melexis MLX90632-D temperature sensor.
*/
/**************************************************************************/
class WipperSnapper_I2C_Driver_MLX90632D : public WipperSnapper_I2C_Driver {
public:
/*******************************************************************************/
/*!
@brief Constructor for an MLX90632 sensor.
@param i2c
The I2C interface.
@param sensorAddress
7-bit device address.
*/
/*******************************************************************************/
WipperSnapper_I2C_Driver_MLX90632D(TwoWire *i2c, uint16_t sensorAddress)
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {
_i2c = i2c;
_sensorAddress = sensorAddress;
_mlx90632 = nullptr;
_deviceTemp = NAN;
_objectTemp = NAN;
_lastRead = 0;
}
/*******************************************************************************/
/*!
@brief Destructor for an MLX90632 sensor.
*/
/*******************************************************************************/
~WipperSnapper_I2C_Driver_MLX90632D() {
if (_mlx90632) {
delete _mlx90632;
_mlx90632 = nullptr;
}
}
/*******************************************************************************/
/*!
@brief Initializes the MLX90632 sensor and begins I2C.
@returns True if initialized successfully, False otherwise.
*/
/*******************************************************************************/
bool begin() {
if (_mlx90632) {
delete _mlx90632;
_mlx90632 = nullptr;
}
_mlx90632 = new Adafruit_MLX90632();
// attempt to initialize MLX90632
if (!_mlx90632->begin(_sensorAddress, _i2c))
return false;
return ConfigureAndPrintSensorInfo();
}
/*******************************************************************************/
/*!
@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 extendedInsteadOfMedicalRange = false) {
// Reset the device
if (!_mlx90632->reset()) {
WS_DEBUG_PRINTLN(F("Device reset failed"));
return false;
}
uint16_t productCode = _mlx90632->getProductCode();
// Decode product code bits
uint8_t fov = (productCode >> 8) & 0x3;
uint8_t package = (productCode >> 5) & 0x7;
uint8_t accuracy = productCode & 0x1F;
if (!_mlx90632->setMode(MLX90632_MODE_CONTINUOUS)) {
WS_DEBUG_PRINTLN(F("Failed to set mode"));
return false;
}
// set accuracy mode based on medical if detected
if (accuracy == 1) {
// Set and get measurement select (medical)
if (!extendedInsteadOfMedicalRange &&
!_mlx90632->setMeasurementSelect(MLX90632_MEAS_MEDICAL)) {
WS_DEBUG_PRINTLN(F("Failed to set measurement select to Medical"));
return false;
} else if (extendedInsteadOfMedicalRange &&
!_mlx90632->setMeasurementSelect(
MLX90632_MEAS_EXTENDED_RANGE)) {
WS_DEBUG_PRINTLN(
F("Failed to set measurement select to Extended Range"));
return false;
}
}
// Set and get refresh rate (default to 2Hz)
if (!_mlx90632->setRefreshRate(MLX90632_REFRESH_2HZ)) {
WS_DEBUG_PRINTLN(F("Failed to set refresh rate to 2Hz"));
return false;
}
if (!_mlx90632->resetNewData()) {
WS_DEBUG_PRINTLN(F("Failed to reset new data flag"));
return false;
}
return true;
}
/*******************************************************************************/
/*!
@brief Checks if sensor was read within last 1s, or is the first read.
@returns True if the sensor was recently read, False otherwise.
*/
/*******************************************************************************/
bool HasBeenReadInLast200ms() {
return _lastRead != 0 && millis() - _lastRead < 200;
}
/*******************************************************************************/
/*!
@brief Reads the sensor.
@returns True if the sensor was read successfully, False otherwise.
*/
/*******************************************************************************/
bool ReadSensorData() {
bool result = false;
if (HasBeenReadInLast200ms()) {
WS_DEBUG_PRINTLN(F("Sensor was read recently, using cached data"));
return true;
}
// Check if we need to trigger a new measurement for step modes
mlx90632_mode_t currentMode = _mlx90632->getMode();
if (currentMode == MLX90632_MODE_STEP ||
currentMode == MLX90632_MODE_SLEEPING_STEP) {
// Trigger single measurement (SOC bit) for step modes
if (!_mlx90632->startSingleMeasurement()) {
WS_DEBUG_PRINTLN(F("Failed to start single measurement"));
return false;
}
delay(510); // Wait for measurement to complete @ 2Hz
}
// Only check new data flag - much more efficient for continuous mode
if (_mlx90632->isNewData()) {
_deviceTemp = _mlx90632->getAmbientTemperature();
_objectTemp = _mlx90632->getObjectTemperature();
if (isnan(_objectTemp)) {
WS_DEBUG_PRINTLN(F("NaN (invalid cycle position)"));
return false;
}
result = true;
_lastRead = millis();
// Reset new data flag after reading
if (!_mlx90632->resetNewData()) {
WS_DEBUG_PRINTLN(F("Failed to reset new data flag"));
}
} else {
WS_DEBUG_PRINTLN(F("No new data available, skipping read"));
}
return result;
}
/*******************************************************************************/
/*!
@brief Gets the MLX90632's current temperature.
@param tempEvent
Pointer to an Adafruit_Sensor event.
@returns True if the temperature was obtained successfully, False
otherwise.
*/
/*******************************************************************************/
bool getEventAmbientTemp(sensors_event_t *tempEvent) {
if (ReadSensorData() && _deviceTemp != NAN) {
tempEvent->temperature = _deviceTemp;
return true;
}
return false; // sensor not read recently, return false
}
/*******************************************************************************/
/*!
@brief Gets the MLX90632's object temperature.
@param tempEvent
Pointer to an Adafruit_Sensor event.
@returns True if the temperature was obtained successfully, False
otherwise.
*/
/*******************************************************************************/
bool getEventObjectTemp(sensors_event_t *tempEvent) {
if (ReadSensorData() && _objectTemp != NAN) {
tempEvent->temperature = _objectTemp;
return true;
}
return false; // sensor not read recently, return false
}
protected:
double _deviceTemp; ///< Device temperature in Celsius
double _objectTemp; ///< Object temperature in Celsius
uint32_t _lastRead; ///< Last time the sensor was read in milliseconds
Adafruit_MLX90632 *_mlx90632 = nullptr; ///< MLX90632 object
};
#endif // WipperSnapper_I2C_Driver_MLX90632D_H

View file

@ -0,0 +1,81 @@
/*!
* @file WipperSnapper_I2C_Driver_QMC5883P.cpp
*
* Implementation for the Adafruit QMC5883P magnetometer wrapper.
*/
#include "WipperSnapper_I2C_Driver_QMC5883P.h"
#include <Adafruit_QMC5883P.h>
#include <math.h>
WipperSnapper_I2C_Driver_QMC5883P::WipperSnapper_I2C_Driver_QMC5883P(
TwoWire *i2c, uint16_t sensorAddress)
: WipperSnapper_I2C_Driver(i2c, sensorAddress) {}
WipperSnapper_I2C_Driver_QMC5883P::~WipperSnapper_I2C_Driver_QMC5883P() {
if (_qmc) {
delete _qmc;
}
}
bool WipperSnapper_I2C_Driver_QMC5883P::begin() {
_qmc = new Adafruit_QMC5883P();
if (!_qmc->begin(_sensorAddress, _i2c)) {
return false;
}
// Set to continuous mode
_qmc->setMode(QMC5883P_MODE_CONTINUOUS);
// Set ODR (Output Data Rate) to 50Hz
_qmc->setODR(QMC5883P_ODR_50HZ);
// Set OSR (Over Sample Ratio) to 4
_qmc->setOSR(QMC5883P_OSR_4);
// Set DSR (Downsample Ratio) to 2
_qmc->setDSR(QMC5883P_DSR_2);
// Set Range to 30G
_qmc->setRange(QMC5883P_RANGE_30G);
// Set SetReset mode to On
_qmc->setSetResetMode(QMC5883P_SETRESET_ON);
return true;
}
bool WipperSnapper_I2C_Driver_QMC5883P::getEventRaw(sensors_event_t *magEvent) {
if (!_qmc->isDataReady()) {
return false;
}
int16_t x, y, z;
float gx, gy, gz;
// Get raw magnetic data
if (!_qmc->getRawMagnetic(&x, &y, &z)) {
WS_DEBUG_PRINTLN("Failed to read raw magnetic data");
return false;
}
// Get Gauss field data
if (!_qmc->getGaussField(&gx, &gy, &gz)) {
WS_DEBUG_PRINTLN("Failed to read Gauss field data");
WS_DEBUG_PRINT("Raw X: "); WS_DEBUG_PRINTLN(x);
WS_DEBUG_PRINT("Raw Y: "); WS_DEBUG_PRINTLN(y);
WS_DEBUG_PRINT("Raw Z: "); WS_DEBUG_PRINTLN(z);
return false;
} else {
WS_DEBUG_PRINT("Gauss X: "); WS_DEBUG_PRINTLN(gx);
WS_DEBUG_PRINT("Gauss Y: "); WS_DEBUG_PRINTLN(gy);
WS_DEBUG_PRINT("Gauss Z: "); WS_DEBUG_PRINTLN(gz);
}
// Check for overflow
if (_qmc->isOverflow()) {
WS_DEBUG_PRINTLN("QMC5883P data overflow - skipping reading");
return false;
}
// Calculate magnitude in Gauss
float magnitude_G = sqrtf(gx * gx + gy * gy + gz * gz);
magEvent->data[0] = magnitude_G;
return true;
}

View file

@ -0,0 +1,28 @@
/*!
* @file WipperSnapper_I2C_Driver_QMC5883P.h
*
* Driver wrapper for the Adafruit QMC5883P 3-axis magnetometer.
*
* Publishes magnetic field magnitude in Gauss as SENSOR_TYPE_MAGNETIC_FIELD.
*/
#ifndef WipperSnapper_I2C_Driver_QMC5883P_H
#define WipperSnapper_I2C_Driver_QMC5883P_H
#include "WipperSnapper_I2C_Driver.h"
#include "Wippersnapper.h"
class Adafruit_QMC5883P; // forward
class WipperSnapper_I2C_Driver_QMC5883P : public WipperSnapper_I2C_Driver {
public:
WipperSnapper_I2C_Driver_QMC5883P(TwoWire *i2c, uint16_t sensorAddress);
~WipperSnapper_I2C_Driver_QMC5883P();
bool begin();
bool getEventRaw(sensors_event_t *magEvent);
private:
Adafruit_QMC5883P *_qmc = nullptr;
};
#endif // WipperSnapper_I2C_Driver_QMC5883P_H