ism330dl: Auto-trigger conversion when reading after power down.#124
ism330dl: Auto-trigger conversion when reading after power down.#124
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds auto-trigger conversion support to the ISM330DL driver when the sensor is in power-down mode. After power_down() is called, reading acceleration, gyroscope, or temperature data now automatically restores the previous ODR configuration and waits for fresh data instead of returning stale values.
Changes:
- Added
_is_power_down()and_ensure_data()methods plus_accel_odr/_gyro_odrtracking fields to auto-restore sensor configuration on read after power-down - Hooked
_ensure_data()intoacceleration_raw(),gyroscope_raw(), andtemperature_raw() - Added 4 mock test scenarios verifying read-after-power-down behavior and ODR restoration
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/ism330dl/ism330dl/device.py |
Adds ODR tracking, _is_power_down(), _ensure_data(), and hooks them into raw read methods |
tests/scenarios/ism330dl.yaml |
Adds 4 mock test scenarios for auto-trigger behavior after power down |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR adds auto-trigger conversion support for the ISM330DL driver. When the sensor is in power-down mode, reading acceleration, gyroscope, or temperature data now automatically restores the previous ODR/scale configuration and waits for fresh data before returning values. This follows the established convention used in WSEN-PADS, WSEN-HIDS, and HTS221 drivers.
Changes:
- Added
_is_power_down()and_ensure_data()methods plus_accel_odr/_gyro_odrstate tracking to enable auto-trigger on read after power down. - Hooked
_ensure_data()intoacceleration_raw(),gyroscope_raw(), andtemperature_raw(). - Added 8 new YAML test scenarios covering auto-trigger behavior in both mock and hardware modes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/ism330dl/ism330dl/device.py |
Added ODR tracking fields, _is_power_down(), _ensure_data(), and calls in raw reading methods. |
tests/scenarios/ism330dl.yaml |
Added mock and hardware test scenarios for read-after-power-down behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
🎉 This PR is included in version 0.0.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Closes #123
Summary
When the ISM330DL is in power-down mode (
power_down()called), reading acceleration, gyroscope, or temperature data now automatically restores the previous ODR configuration and waits for fresh data, instead of returning stale values._is_power_down()— checks if both CTRL1_XL and CTRL2_G have ODR=0_ensure_data()— restores saved ODR/scale and waits 100ms for data ready_accel_odr/_gyro_odr— track the last non-zero ODR to enable restorationacceleration_raw(),gyroscope_raw(),temperature_raw()Follows the same convention as WSEN-PADS, WSEN-HIDS, and HTS221 (#44).
Test plan
Mock tests (no hardware)
python3 -m pytest tests/ -k "ism330dl and mock" -vHardware tests (STeaMi board connected)
python3 -m pytest tests/ --port /dev/ttyACM0 -k "ism330dl and hardware" -s -v