drivers: Standardize status and data ready method naming.#149
Conversation
There was a problem hiding this comment.
Pull request overview
Standardizes driver “status” and “data-ready” method naming to a consistent convention across multiple sensor drivers, and updates supporting docs/examples/tests to match.
Changes:
- Renames several “available/ready” helpers (e.g., APDS9960, LIS2MDL, WSEN-PADS) to the new
*_ready()naming. - Adds
data_ready()and per-channel ready helpers to HTS221, and addsdata_ready()to ISM330DL. - Documents the convention in the repo README and updates a LIS2MDL scenario + examples.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/scenarios/lis2mdl.yaml | Updates scenario to call status() instead of read_status(). |
| lib/wsen-pads/wsen_pads/device.py | Renames WSEN-PADS ready helpers to pressure_ready() / temperature_ready() / data_ready(). |
| lib/wsen-pads/examples/test.py | Updates example output to use renamed WSEN-PADS helpers. |
| lib/lis2mdl/lis2mdl/device.py | Renames read_status() → status() and updates internal call sites. |
| lib/lis2mdl/examples/magnet_test.py | Updates example to call status(). |
| lib/ism330dl/ism330dl/device.py | Adds data_ready() helper based on STATUS bits. |
| lib/hts221/hts221/device.py | Adds data_ready(), temperature_ready(), humidity_ready() helpers. |
| lib/apds9960/apds9960/device.py | Renames light/proximity availability helpers to light_ready() / proximity_ready(). |
| README.md | Documents the new status/data-ready naming convention. |
Comments suppressed due to low confidence (1)
lib/wsen-pads/wsen_pads/device.py:174
- These status helpers were renamed/added, but there doesn’t appear to be scenario coverage that calls them (e.g., no
pressure_ready()/temperature_ready()/data_ready()checks intests/scenarios/wsen_pads.yaml). Adding a small mock test that asserts each helper matches the corresponding STATUS bits would prevent regressions.
def data_ready(self):
"""
Return True when both pressure and temperature data are available.
This is mainly useful in continuous mode.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c571c16 to
afba75e
Compare
afba75e to
57933d6
Compare
There was a problem hiding this comment.
Pull request overview
Standardizes “status/data-ready” helper naming across the driver library to align with the documented convention (_status() raw register (private), data_ready() aggregate readiness, and per-channel <measurement>_ready() helpers). This brings consistency across drivers, tests, and example scripts.
Changes:
- Renames/introduces readiness helpers across multiple drivers (e.g.,
*_ready(),data_ready(),_status()), including a semantic rename inbq27441to_control_status(). - Updates scenario tests to call the new methods (including
_status()where applicable). - Updates README driver API convention and adjusts several example scripts to use the new readiness helpers.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/scenarios/wsen_pads.yaml | Update scenario to call _status instead of status. |
| tests/scenarios/wsen_hids.yaml | Update scenario to call _status instead of status. |
| tests/scenarios/vl53l1x.yaml | Update scenario to use public data_ready() instead of private _is_data_ready(). |
| tests/scenarios/lis2mdl.yaml | Update scenario to call _status instead of read_status. |
| tests/scenarios/ism330dl.yaml | Update mock scenario to validate _status() (int), per-channel *_ready(), and data_ready(). |
| tests/scenarios/hts221.yaml | Add/adjust mock scenario checks for _status(), data_ready(), and per-channel ready helpers. |
| lib/wsen-pads/wsen_pads/device.py | Rename status/readiness helpers to _status(), data_ready(), and *_ready(). |
| lib/wsen-pads/examples/test.py | Update example output to use data_ready() / *_ready() naming. |
| lib/wsen-hids/wsen_hids/device.py | Make raw status private via _status() and update readiness helpers to use it. |
| lib/wsen-hids/examples/full_test.py | Updates status usage in example (currently introduces incorrect “STATUS” handling). |
| lib/vl53l1x/vl53l1x/device.py | Expose data_ready() publicly and update internal polling to use it. |
| lib/lis2mdl/lis2mdl/device.py | Rename read_status() to _status() and update internal callers. |
| lib/lis2mdl/examples/magnet_test.py | Updates example status/readiness calls (currently prints bool as hex “STATUS”). |
| lib/ism330dl/ism330dl/device.py | Make raw status private (_status) and add per-channel ready methods plus data_ready(). |
| lib/hts221/hts221/device.py | Make raw status private (_status) and add data_ready() plus per-channel readiness helpers. |
| lib/bq27441/bq27441/device.py | Rename status() to _control_status() to avoid semantic clash with sensor status conventions. |
| lib/apds9960/apds9960/device.py | Add _status(), data_ready(), and rename readiness methods to light_ready() / proximity_ready(). |
| README.md | Document the new status/readiness naming convention (_status, data_ready, <measurement>_ready). |
Comments suppressed due to low confidence (2)
lib/wsen-hids/examples/full_test.py:248
- In the continuous-mode loop,
statusis set tosensor.data_ready()(bool) but printed usingSTATUS=0x{:02X}which implies a register dump. Either printdata_ready()as a boolean (and change the label), or read the raw status register for the hex output.
status = sensor.data_ready()
print(
"#{:d} H={:.2f} %RH T={:.2f} °C STATUS=0x{:02X}".format(
i + 1,
lib/wsen-hids/examples/full_test.py:299
test_status_helpers()setsstatus = sensor.data_ready()(bool) but then compares helper methods againstSTATUS_*bit masks (status & STATUS_H_DA, etc.). This logic can never correctly validate the helper methods becausestatusis not the raw register value. Read the actual STATUS register for the bitmask checks, or change the test to compare booleans consistently (e.g.,ready/data_ready()only).
status = sensor.data_ready()
h_avail = sensor.humidity_ready()
t_avail = sensor.temperature_ready()
ready = sensor.data_ready()
print("STATUS = 0x{:02X}".format(status))
print("humidity_ready() =", h_avail)
💡 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 #79, #150, #151, #152, #153, #154, #155, #156
Summary
Standardize status and data-ready methods across all drivers, and make
status()private.Convention:
_status()— raw status register (private, returns int)data_ready()— True when all channels have new data<measurement>_ready()— per-channel (e.g.temperature_ready(),pressure_ready())Changes
is_light_available(),is_proximity_available()_status(),data_ready(),light_ready(),proximity_ready()status()_control_status()(different semantics)status()_status()+data_ready(),temperature_ready(),humidity_ready()status()(returned dict)_status()(returns int) +data_ready(),accel_ready(),gyro_ready(),temperature_ready()read_status(),data_ready()_status(),data_ready()_is_data_ready()data_ready()(public)status()_status()status(),is_ready(),pressure_available(),temperature_available()_status(),data_ready(),pressure_ready(),temperature_ready()Final state
_status()data_ready()light_ready(),proximity_ready()_control_status()temperature_ready(),humidity_ready()accel_ready(),gyro_ready(),temperature_ready()temperature_ready(),humidity_ready()pressure_ready(),temperature_ready()All
*_ready()methods delegate to_status()for consistency. Examples updated to use public helpers instead of_status().Test plan