Skip to content

drivers: Standardize status and data ready method naming.#149

Merged
nedseb merged 4 commits intomainfrom
fix/standardize-status
Mar 15, 2026
Merged

drivers: Standardize status and data ready method naming.#149
nedseb merged 4 commits intomainfrom
fix/standardize-status

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 15, 2026

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

Driver Before After
apds9960 is_light_available(), is_proximity_available() _status(), data_ready(), light_ready(), proximity_ready()
bq27441 status() _control_status() (different semantics)
hts221 status() _status() + data_ready(), temperature_ready(), humidity_ready()
ism330dl status() (returned dict) _status() (returns int) + data_ready(), accel_ready(), gyro_ready(), temperature_ready()
lis2mdl read_status(), data_ready() _status(), data_ready()
vl53l1x _is_data_ready() data_ready() (public)
wsen-hids status() _status()
wsen-pads status(), is_ready(), pressure_available(), temperature_available() _status(), data_ready(), pressure_ready(), temperature_ready()

Final state

Driver _status() data_ready() Per-channel
apds9960 light_ready(), proximity_ready()
bq27441 _control_status() N/A (always active)
hts221 temperature_ready(), humidity_ready()
ism330dl accel_ready(), gyro_ready(), temperature_ready()
lis2mdl
mcp23009e N/A (GPIO expander)
ssd1327 N/A (display)
vl53l1x
wsen-hids temperature_ready(), humidity_ready()
wsen-pads pressure_ready(), temperature_ready()

All *_ready() methods delegate to _status() for consistency. Examples updated to use public helpers instead of _status().

Test plan

ruff check lib/                          # All checks passed
python3 -m pytest tests/ -k "mock" -v    # 115 passed

@nedseb nedseb requested a review from Copilot March 15, 2026 13:06
@nedseb nedseb self-assigned this Mar 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 adds data_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 in tests/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.

Comment thread README.md Outdated
Comment thread lib/hts221/hts221/device.py
Comment thread lib/hts221/hts221/device.py Outdated
Comment thread lib/ism330dl/ism330dl/device.py Outdated
Comment thread lib/lis2mdl/lis2mdl/device.py
Comment thread lib/wsen-pads/wsen_pads/device.py
Comment thread lib/ism330dl/ism330dl/device.py Outdated
Comment thread lib/apds9960/apds9960/device.py Outdated
@nedseb nedseb force-pushed the fix/standardize-status branch from c571c16 to afba75e Compare March 15, 2026 13:12
@nedseb nedseb added the enhancement New feature or request label Mar 15, 2026
@nedseb nedseb force-pushed the fix/standardize-status branch from afba75e to 57933d6 Compare March 15, 2026 13:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in bq27441 to _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, status is set to sensor.data_ready() (bool) but printed using STATUS=0x{:02X} which implies a register dump. Either print data_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() sets status = sensor.data_ready() (bool) but then compares helper methods against STATUS_* bit masks (status & STATUS_H_DA, etc.). This logic can never correctly validate the helper methods because status is 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.

Comment thread lib/apds9960/apds9960/device.py Outdated
Comment thread lib/wsen-hids/examples/full_test.py Outdated
Comment thread lib/lis2mdl/examples/magnet_test.py Outdated
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.0.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

drivers: Standardize status and data ready method naming.

2 participants