examples(lis2mdl): Replace test scripts with practical examples.#251
examples(lis2mdl): Replace test scripts with practical examples.#251
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refreshes the lis2mdl driver’s examples by removing a test-style script and adding practical, real-world usage examples, and then documents those examples in the driver README (closes #185).
Changes:
- Removed
magnet_test.pyfromlib/lis2mdl/examples/(test-like content no longer shipped as an “example”). - Added multiple new usage-focused examples (calibration, tilt-compensated heading, detection, logging, mapping, low-power).
- Updated
lib/lis2mdl/README.mdto list and describe the available examples.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/lis2mdl/examples/basic_read.py | New “getting started” loop reading field + temperature. |
| lib/lis2mdl/examples/calibrate_2d.py | New interactive 2D hard-iron calibration workflow. |
| lib/lis2mdl/examples/tilt_compensated_heading.py | New LIS2MDL + ISM330DL fused heading demo. |
| lib/lis2mdl/examples/metal_detector.py | New magnitude-change detector with buzzer feedback. |
| lib/lis2mdl/examples/door_sensor.py | New baseline + hysteresis door open/close detector. |
| lib/lis2mdl/examples/field_logger.py | New CSV logger to DAPLink flash. |
| lib/lis2mdl/examples/field_map.py | New “field mapping” loop with axis min/max tracking. |
| lib/lis2mdl/examples/low_power_one_shot.py | New low-power one-shot sampling loop. |
| lib/lis2mdl/examples/magnet_test.py | Removed test suite from examples directory. |
| lib/lis2mdl/README.md | Replaced embedded compass snippet with an examples list table. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
nedseb
left a comment
There was a problem hiding this comment.
Les corrections sont acceptees. La reponse sur le README avec la capture d'ecran est bien meilleure, c'est ce que j'attend. Pour le tone() je ferai la correction avant le merge.
Use millisecond-based timing in tone() and adjust frequency range to 150–500 Hz. Previous implementation used microsecond calculations with sleep_ms(), causing incorrect and capped frequencies (~500 Hz max regardless of input). This ensures consistent and predictable buzzer behavior without requiring sleep_us() or PWM.
ca5c2e3 to
b71150b
Compare
|
🎉 This PR is included in version 0.1.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Summary
Replace the monolithic
magnet_test.pywith 8 practical, user-facing examples for the LIS2MDL magnetometer.Closes #185
Changes
Removed
magnet_test.pytests/scenarios/lis2mdl.yamlAdded — 8 practical examples
basic_read.pycalibrate_2d.pytilt_compensated_heading.pyism330dlmetal_detector.pydoor_sensor.pyfield_logger.pydaplink_flashfield_map.pylow_power_one_shot.pypower_off()between readsKept
magnet_compass.pymagnet_fieldForce.pyUpdated
README.mdTest commands
Notes
door_sensor.py: untested on hardware (no magnet available during dev)metal_detector.py: buzzer uses hardware PWM Timer — needs hardware validation (fix(examples): Migrate buzzer tone() to hardware PWM Timer. #254)tilt_compensated_heading.py: limited compensation effect observed, may need calibrationChecklist
magnet_test.pyremovedtests/scenarios/lis2mdl.yamlruff checkpasses