From a1b412cda4690ff1cf7ea709612f556fc370320a Mon Sep 17 00:00:00 2001 From: Tyeth Gundry Date: Tue, 26 Aug 2025 19:16:38 +0100 Subject: [PATCH 1/9] fix(partitions): 4MB NoOTA in platformIO.ini --- platformio.ini | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/platformio.ini b/platformio.ini index 28f065116..c11e6f6a5 100644 --- a/platformio.ini +++ b/platformio.ini @@ -203,7 +203,8 @@ board_build.partitions = min_spiffs.csv extends = common:esp32 board = featheresp32-s2 build_flags = -DARDUINO_ADAFRUIT_FEATHER_ESP32S2 -DBOARD_HAS_PSRAM -board_build.partitions = tinyuf2-partitions-4MB.csv +;set partition to tinyuf2-partitions-4MB-noota.csv as of CPY 10 +board_build.partitions = tinyuf2-partitions-4MB-noota.csv extra_scripts = pre:rename_usb_config.py ; Adafruit Feather ESP32-S2 TFT @@ -211,7 +212,8 @@ extra_scripts = pre:rename_usb_config.py extends = common:esp32 board = adafruit_feather_esp32s2_tft build_flags = -DARDUINO_ADAFRUIT_FEATHER_ESP32S2_TFT -DBOARD_HAS_PSRAM -board_build.partitions = tinyuf2-partitions-4MB.csv +;set partition to tinyuf2-partitions-4MB-noota.csv as of CPY 10 +board_build.partitions = tinyuf2-partitions-4MB-noota.csv extra_scripts = pre:rename_usb_config.py ; Adafruit Feather ESP32-S2 Reverse TFT @@ -219,7 +221,8 @@ extra_scripts = pre:rename_usb_config.py extends = common:esp32 board = adafruit_feather_esp32s2_reversetft build_flags = -DARDUINO_ADAFRUIT_FEATHER_ESP32S2_REVTFT -DBOARD_HAS_PSRAM -board_build.partitions = tinyuf2-partitions-4MB.csv +;set partition to tinyuf2-partitions-4MB-noota.csv as of CPY 10 +board_build.partitions = tinyuf2-partitions-4MB-noota.csv extra_scripts = pre:rename_usb_config.py ; Adafruit Feather ESP32-S3 2MB PSRAM @@ -227,8 +230,8 @@ extra_scripts = pre:rename_usb_config.py extends = common:esp32 board = adafruit_feather_esp32s3 build_flags = -DARDUINO_ADAFRUIT_FEATHER_ESP32S3 -DBOARD_HAS_PSRAM -;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1 -board_build.partitions = tinyuf2-partitions-4MB.csv +;set partition to tinyuf2-partitions-4MB-noota.csv as of CPY 10 +board_build.partitions = tinyuf2-partitions-4MB-noota.csv extra_scripts = pre:rename_usb_config.py ; Adafruit Feather ESP32-S3 NO PSRAM @@ -246,8 +249,8 @@ build_type = debug debug_tool = esp-builtin board = adafruit_feather_esp32s3_tft build_flags = -DARDUINO_ADAFRUIT_FEATHER_ESP32S3_TFT -DBOARD_HAS_PSRAM -;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1 -board_build.partitions = tinyuf2-partitions-4MB.csv +;set partition to tinyuf2-partitions-4MB-noota.csv as of CPY 10 +board_build.partitions = tinyuf2-partitions-4MB-noota.csv extra_scripts = pre:rename_usb_config.py ; Adafruit Feather ESP32-S3 Reverse TFT @@ -255,8 +258,8 @@ extra_scripts = pre:rename_usb_config.py extends = common:esp32 board = adafruit_feather_esp32s3_reversetft build_flags = -DARDUINO_ADAFRUIT_FEATHER_ESP32S3_REVTFT -DBOARD_HAS_PSRAM -;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1 -board_build.partitions = tinyuf2-partitions-4MB.csv +;set partition to tinyuf2-partitions-4MB-noota.csv as of CPY 10 +board_build.partitions = tinyuf2-partitions-4MB-noota.csv extra_scripts = pre:rename_usb_config.py ; Adafruit Magtag ESP32-S2 @@ -264,8 +267,8 @@ extra_scripts = pre:rename_usb_config.py extends = common:esp32 board = adafruit_magtag29_esp32s2 build_flags = -DARDUINO_MAGTAG29_ESP32S2 -DBOARD_HAS_PSRAM -;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1 -board_build.partitions = tinyuf2-partitions-4MB.csv +;set partition to tinyuf2-partitions-4MB-noota.csv as of CPY 10 +board_build.partitions = tinyuf2-partitions-4MB-noota.csv extra_scripts = pre:rename_usb_config.py ; Adafruit Metro ESP32-S2 @@ -273,9 +276,12 @@ extra_scripts = pre:rename_usb_config.py extends = common:esp32 board = adafruit_metro_esp32s2 build_flags = -DARDUINO_METRO_ESP32S2 -DBOARD_HAS_PSRAM -;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1 -board_build.partitions = tinyuf2-partitions-4MB.csv +;set partition to tinyuf2-partitions-4MB-noota.csv as of CPY 10 +board_build.partitions = tinyuf2-partitions-4MB-noota.csv extra_scripts = pre:rename_usb_config.py +; debug_tool = jlink +; upload_protocol = jlink +; debug_init_break = tbreak WipperSnapper_I2C_Driver_MLX90632D ; Adafruit Metro ESP32-S3 [env:adafruit_metro_esp32s3] @@ -285,13 +291,14 @@ build_flags = -DARDUINO_METRO_ESP32S3 -DBOARD_HAS_PSRAM ;set partition to tinyuf2-partitions-16MB.csv as of idf 5.1 board_build.partitions = tinyuf2-partitions-16MB.csv extra_scripts = pre:rename_usb_config.py +debug_tool = jlink ; Adafruit Funhouse ESP32-S2 [env:adafruit_funhouse_esp32s2] extends = common:esp32 board = adafruit_funhouse_esp32s2 build_flags = -DARDUINO_FUNHOUSE -DBOARD_HAS_PSRAM -;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1 +;set partition to tinyuf2-partitions-4MB-noota.csv as of CPY 10 board_build.partitions = tinyuf2-partitions-4MB-noota.csv extra_scripts = pre:rename_usb_config.py @@ -320,7 +327,7 @@ build_flags = -DLV_LOG_PRINTF=1 -DLV_LOG_COLOR=1 -DLV_LOG_LEVEL=LV_LOG_LEVEL_TRACE -;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1 +;set partition to tinyuf2-partitions-4MB-noota.csv as of CPY 10 board_build.partitions = tinyuf2-partitions-4MB-noota.csv extra_scripts = pre:rename_usb_config.py @@ -362,8 +369,8 @@ board_build.partitions = min_spiffs.csv extends = common:esp32 board = adafruit_qtpy_esp32s2 build_flags = -DARDUINO_ADAFRUIT_QTPY_ESP32S2 -DBOARD_HAS_PSRAM -;set partition to tinyuf2-partitions-4MB.csv as of idf 5.1 -board_build.partitions = tinyuf2-partitions-4MB.csv +;set partition to tinyuf2-partitions-4MB-noota.csv as of CPY 10 +board_build.partitions = tinyuf2-partitions-4MB-noota.csv extra_scripts = pre:rename_usb_config.py ; Adafruit QT Py ESP32-S3 NO PSRAM @@ -379,12 +386,14 @@ extra_scripts = pre:rename_usb_config.py extends = common:esp32 board = adafruit_qtpy_esp32s3_n4r2 build_flags = -DARDUINO_ADAFRUIT_QTPY_ESP32S3_N4R2 -DBOARD_HAS_PSRAM +;set partition to tinyuf2-partitions-4MB-noota.csv as of CPY 10 board_build.partitions = tinyuf2-partitions-4MB-noota.csv extra_scripts = pre:rename_usb_config.py [env:adafruit_qtpy_esp32s3_with_psram_debug] extends = common:esp32 board = adafruit_qtpy_esp32s3_n4r2 +;set partition to tinyuf2-partitions-4MB-noota.csv as of CPY 10 board_build.partitions = tinyuf2-partitions-4MB-noota.csv build_type = debug build_flags = From 1ef9d169ecd56af5c42d48a7905dbcc5dd5f7e81 Mon Sep 17 00:00:00 2001 From: Tyeth Gundry Date: Tue, 26 Aug 2025 19:30:16 +0100 Subject: [PATCH 2/9] add(qmc5883p): initial vectorless result --- library.properties | 2 +- platformio.ini | 1 + src/components/i2c/WipperSnapper_I2C.cpp | 11 +++ src/components/i2c/WipperSnapper_I2C.h | 3 + .../WipperSnapper_I2C_Driver_QMC5883P.cpp | 72 +++++++++++++++++++ .../WipperSnapper_I2C_Driver_QMC5883P.h | 28 ++++++++ 6 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp create mode 100644 src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.h diff --git a/library.properties b/library.properties index 9ef6dc4a2..89b85ee08 100644 --- a/library.properties +++ b/library.properties @@ -7,4 +7,4 @@ paragraph=Arduino application for Adafruit.io WipperSnapper category=Communication url=https://github.com/adafruit/Adafruit_Wippersnapper_Arduino 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 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 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 diff --git a/platformio.ini b/platformio.ini index c11e6f6a5..a84519447 100644 --- a/platformio.ini +++ b/platformio.ini @@ -47,6 +47,7 @@ lib_deps = adafruit/Adafruit LTR390 Library adafruit/Adafruit LTR329 and LTR303 adafruit/Adafruit PCT2075 + adafruit/Adafruit QMC5883P Library adafruit/Adafruit SCD30 adafruit/Adafruit SGP30 Sensor adafruit/Adafruit SGP40 Sensor diff --git a/src/components/i2c/WipperSnapper_I2C.cpp b/src/components/i2c/WipperSnapper_I2C.cpp index a074e7f74..021e2cd2c 100644 --- a/src/components/i2c/WipperSnapper_I2C.cpp +++ b/src/components/i2c/WipperSnapper_I2C.cpp @@ -737,6 +737,17 @@ bool WipperSnapper_Component_I2C::initI2CDevice( _pm25->configureDriver(msgDeviceInitReq); drivers.push_back(_pm25); 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) { _lc = new WipperSnapper_I2C_Driver_LC709203F(this->_i2c, i2cAddress); if (!_lc->begin()) { diff --git a/src/components/i2c/WipperSnapper_I2C.h b/src/components/i2c/WipperSnapper_I2C.h index c594e0bf5..7af5e2c66 100644 --- a/src/components/i2c/WipperSnapper_I2C.h +++ b/src/components/i2c/WipperSnapper_I2C.h @@ -62,6 +62,7 @@ #include "drivers/WipperSnapper_I2C_Driver_Out_Ssd1306.h" #include "drivers/WipperSnapper_I2C_Driver_PCT2075.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_SCD4X.h" #include "drivers/WipperSnapper_I2C_Driver_SEN5X.h" @@ -93,6 +94,7 @@ class WipperSnapper_I2C_Driver_INA260; class WipperSnapper_I2C_Driver_INA237; class WipperSnapper_I2C_Driver_INA238; class WipperSnapper_I2C_Driver_INA228; +class WipperSnapper_I2C_Driver_QMC5883P; /**************************************************************************/ /*! @@ -197,6 +199,7 @@ class WipperSnapper_Component_I2C { WipperSnapper_I2C_Driver_SGP40 *_sgp40 = nullptr; WipperSnapper_I2C_Driver_PCT2075 *_pct2075 = nullptr; WipperSnapper_I2C_Driver_PM25 *_pm25 = nullptr; + WipperSnapper_I2C_Driver_QMC5883P *_qmc5883p = nullptr; WipperSnapper_I2C_Driver_SI7021 *_si7021 = nullptr; WipperSnapper_I2C_Driver_SHT4X *_sht4x = nullptr; WipperSnapper_I2C_Driver_SHT3X *_sht3x = nullptr; diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp new file mode 100644 index 000000000..6e58c523b --- /dev/null +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp @@ -0,0 +1,72 @@ +/*! + * @file WipperSnapper_I2C_Driver_QMC5883P.cpp + * + * Implementation for the Adafruit QMC5883P magnetometer wrapper. + */ + +#include "WipperSnapper_I2C_Driver_QMC5883P.h" + +#include +#include + +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 normal mode + _qmc->setMode(QMC5883P_MODE_NORMAL); + // 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 8G + _qmc->setRange(QMC5883P_RANGE_8G); + // 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)) { + return false; + } + + // Get Gauss field data + if (!_qmc->getGaussField(&gx, &gy, &gz)) { + return false; + } + + // 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; +} diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.h b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.h new file mode 100644 index 000000000..158117c48 --- /dev/null +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.h @@ -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 From 2a2c2cf579734022379fad22131987c6038e72f0 Mon Sep 17 00:00:00 2001 From: Tyeth Gundry Date: Tue, 26 Aug 2025 20:50:43 +0100 Subject: [PATCH 3/9] fix(qmc5883p): use continuous mode instead of normal --- .../i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp index 6e58c523b..b45e23b88 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp @@ -25,8 +25,8 @@ bool WipperSnapper_I2C_Driver_QMC5883P::begin() { return false; } - // Set to normal mode - _qmc->setMode(QMC5883P_MODE_NORMAL); + // 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 From e90068056970aeab9ae9e8d8a4bf6f5d893d8db1 Mon Sep 17 00:00:00 2001 From: Tyeth Gundry Date: Wed, 27 Aug 2025 11:31:33 +0100 Subject: [PATCH 4/9] fix(huzzah): platformIO ram .text1 section size (iram1_0_seg) --- platformio.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index a84519447..b6fe4a1eb 100644 --- a/platformio.ini +++ b/platformio.ini @@ -481,9 +481,10 @@ build_flags = -DNON32XFER_FAST -DDEBUG_DISABLED -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.filesystem = littlefs -upload_port = /dev/cu.SLAB_USBtoUART +upload_port = COM19 ; SAMD51 Boards ; From 2723c39d844609dfa6f87d57e00924e8bfd84890 Mon Sep 17 00:00:00 2001 From: Tyeth Gundry Date: Thu, 28 Aug 2025 19:23:55 +0100 Subject: [PATCH 5/9] fix(qmc883p): set range to 30G and log xyz until vector supported --- .../drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp index b45e23b88..cf864ca76 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp @@ -33,8 +33,8 @@ bool WipperSnapper_I2C_Driver_QMC5883P::begin() { _qmc->setOSR(QMC5883P_OSR_4); // Set DSR (Downsample Ratio) to 2 _qmc->setDSR(QMC5883P_DSR_2); - // Set Range to 8G - _qmc->setRange(QMC5883P_RANGE_8G); + // Set Range to 30G + _qmc->setRange(QMC5883P_RANGE_30G); // Set SetReset mode to On _qmc->setSetResetMode(QMC5883P_SETRESET_ON); @@ -51,12 +51,21 @@ bool WipperSnapper_I2C_Driver_QMC5883P::getEventRaw(sensors_event_t *magEvent) { // 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 From 9520701185de8bd23ade4dfd9fc67575758821cd Mon Sep 17 00:00:00 2001 From: Tyeth Gundry Date: Fri, 29 Aug 2025 21:22:46 +0100 Subject: [PATCH 6/9] chore(qmc5883p): clang format --- .../WipperSnapper_I2C_Driver_QMC5883P.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp index cf864ca76..c574badb5 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp @@ -58,14 +58,20 @@ bool WipperSnapper_I2C_Driver_QMC5883P::getEventRaw(sensors_event_t *magEvent) { // 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); + 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); + 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 From 284263adb4cc344a4570cb8c31b55172050ef228 Mon Sep 17 00:00:00 2001 From: tyeth Date: Wed, 3 Sep 2025 11:58:13 +0100 Subject: [PATCH 7/9] chore(qmc5883p): doxygen --- .../WipperSnapper_I2C_Driver_QMC5883P.cpp | 21 +++++++++++++++++++ .../WipperSnapper_I2C_Driver_QMC5883P.h | 7 ++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp index c574badb5..9b78de415 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp @@ -9,16 +9,31 @@ #include #include + +/*! + * @brief Constructor for a QMC5883P sensor. + * @param i2c + * The I2C interface. + * @param sensorAddress + * The 7-bit I2C address of the sensor. + */ WipperSnapper_I2C_Driver_QMC5883P::WipperSnapper_I2C_Driver_QMC5883P( TwoWire *i2c, uint16_t sensorAddress) : WipperSnapper_I2C_Driver(i2c, sensorAddress) {} +/*! + * @brief Destructor for a QMC5883P sensor. + */ WipperSnapper_I2C_Driver_QMC5883P::~WipperSnapper_I2C_Driver_QMC5883P() { if (_qmc) { delete _qmc; } } +/*! + * @brief Initializes the QMC5883P sensor and begins I2C. + * @return True if initialized successfully, False otherwise. + */ bool WipperSnapper_I2C_Driver_QMC5883P::begin() { _qmc = new Adafruit_QMC5883P(); if (!_qmc->begin(_sensorAddress, _i2c)) { @@ -41,6 +56,12 @@ bool WipperSnapper_I2C_Driver_QMC5883P::begin() { return true; } +/*! + * @brief Get the magnetometer's sensor event. + * @param magEvent + * Pointer to the magnetometer sensor event. + * @return True if the event was obtained successfully, False otherwise. + */ bool WipperSnapper_I2C_Driver_QMC5883P::getEventRaw(sensors_event_t *magEvent) { if (!_qmc->isDataReady()) { return false; diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.h b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.h index 158117c48..7d706fa69 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.h +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.h @@ -13,6 +13,11 @@ class Adafruit_QMC5883P; // forward +/**************************************************************************/ +/*! +@brief Class that provides a driver interface for a QMC5883P sensor. +*/ +/**************************************************************************/ class WipperSnapper_I2C_Driver_QMC5883P : public WipperSnapper_I2C_Driver { public: WipperSnapper_I2C_Driver_QMC5883P(TwoWire *i2c, uint16_t sensorAddress); @@ -22,7 +27,7 @@ class WipperSnapper_I2C_Driver_QMC5883P : public WipperSnapper_I2C_Driver { bool getEventRaw(sensors_event_t *magEvent); private: - Adafruit_QMC5883P *_qmc = nullptr; + Adafruit_QMC5883P *_qmc = nullptr; ///< Pointer to the QMC5883P sensor object }; #endif // WipperSnapper_I2C_Driver_QMC5883P_H From aa4ef3c8528ea48d0346e6664c0ac29094662e0f Mon Sep 17 00:00:00 2001 From: tyeth Date: Wed, 3 Sep 2025 12:11:53 +0100 Subject: [PATCH 8/9] chore(qmc5883p): clang format --- src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp index 9b78de415..d59052614 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp @@ -9,7 +9,6 @@ #include #include - /*! * @brief Constructor for a QMC5883P sensor. * @param i2c From b338a56f2d482707e422e20cf7293461218974d6 Mon Sep 17 00:00:00 2001 From: tyeth Date: Thu, 4 Sep 2025 20:20:10 +0100 Subject: [PATCH 9/9] refactor(includes): move math.h to WipperSnapper.h --- src/Wippersnapper.h | 2 ++ .../i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Wippersnapper.h b/src/Wippersnapper.h index 136b529c1..e40638312 100644 --- a/src/Wippersnapper.h +++ b/src/Wippersnapper.h @@ -19,6 +19,8 @@ #define WIPPERSNAPPER_H // Cpp STD +#include + #include // Nanopb dependencies diff --git a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp index d59052614..8cae1bc2e 100644 --- a/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp +++ b/src/components/i2c/drivers/WipperSnapper_I2C_Driver_QMC5883P.cpp @@ -7,7 +7,6 @@ #include "WipperSnapper_I2C_Driver_QMC5883P.h" #include -#include /*! * @brief Constructor for a QMC5883P sensor.