Skip to content

drivers: Make status() private across all sensor drivers.#157

Merged
nedseb merged 1 commit intofix/standardize-statusfrom
fix/status-private
Mar 15, 2026
Merged

drivers: Make status() private across all sensor drivers.#157
nedseb merged 1 commit intofix/standardize-statusfrom
fix/status-private

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 15, 2026

Closes #150, #151, #152, #153, #154, #155

Summary

Rename status()_status() in 6 sensor drivers. The raw status register is an implementation detail — users should use data_ready() and *_ready() methods instead.

Driver Change
hts221 status()_status()
ism330dl status()_status()
lis2mdl status()_status()
wsen-hids status()_status()
wsen-pads status()_status()
apds9960 status()_status()

BQ27441 status() handled separately in #156 (different semantics).

Also updated all internal callers, tests, examples, and README.

Test plan

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

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

This PR standardizes how several sensor drivers expose the “status register” read helper by renaming status() to _status(), updating YAML scenario tests and examples accordingly, and updating the repo-level Driver API conventions in README.md.

Changes:

  • Renames status()_status() across multiple drivers and updates internal callers (data_ready(), <measurement>_ready()).
  • Updates scenario YAMLs to call _status instead of status.
  • Updates examples and the top-level README’s Driver API conventions to reference _status().

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
tests/scenarios/wsen_pads.yaml Scenario now calls _status instead of status.
tests/scenarios/wsen_hids.yaml Scenario now calls _status instead of status.
tests/scenarios/lis2mdl.yaml Scenario now calls _status instead of status.
tests/scenarios/ism330dl.yaml Scenario script/call now uses _status.
tests/scenarios/hts221.yaml Scenario now calls _status instead of status.
README.md Driver API convention updated to _status() as the status helper.
lib/wsen-pads/wsen_pads/device.py Renames public status() to _status() and updates ready helpers to use it.
lib/wsen-pads/examples/test.py Example now calls _status() where it previously called status().
lib/wsen-hids/wsen_hids/device.py Renames public status() to _status() and updates ready helpers to use it.
lib/wsen-hids/examples/full_test.py Example now calls _status() where it previously called status().
lib/lis2mdl/lis2mdl/device.py Renames public status() to _status() and updates callers.
lib/lis2mdl/examples/magnet_test.py Example now calls _status() where it previously called status().
lib/ism330dl/ism330dl/device.py Renames status() to _status() (currently returns a parsed dict).
lib/hts221/hts221/device.py Renames status() to _status() and updates callers.
lib/apds9960/apds9960/device.py Renames status() to _status().
Comments suppressed due to low confidence (2)

lib/apds9960/apds9960/device.py:89

  • Renaming status() to _status() is a breaking change for APDS9960 users. Suggest keeping status() as a public alias that calls _status() so downstream code doesn’t unexpectedly fail.
    def device_id(self):
        return self.dev_id

    def _status(self):
        return self._read_reg(APDS9960_REG_STATUS)

    def data_ready(self):
        return self.light_ready() and self.proximity_ready()

lib/ism330dl/ism330dl/device.py:260

  • Per the updated repo API guidance, _status() is supposed to be the raw status register value, but here it returns a parsed dict of ready flags. Either adjust _status() to return the raw REG_STATUS_REG byte and add a separate public helper for the parsed flags, or keep this method public as status() and reserve _status() for raw reads for consistency across drivers.
    def _status(self):
        s = self._read_u8(REG_STATUS_REG)
        return {
            "temp_ready": bool(s & STATUS_TDA),
            "gyro_ready": bool(s & STATUS_GDA),
            "accel_ready": bool(s & STATUS_XLDA),
        }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/wsen-pads/wsen_pads/device.py
Comment thread lib/wsen-hids/wsen_hids/device.py
Comment thread lib/lis2mdl/lis2mdl/device.py
Comment thread lib/hts221/hts221/device.py
Comment thread README.md Outdated
Comment thread lib/wsen-pads/examples/test.py Outdated
Comment thread lib/wsen-hids/examples/full_test.py Outdated
Comment thread lib/wsen-hids/examples/full_test.py
Comment thread lib/wsen-hids/examples/full_test.py Outdated
Comment thread lib/lis2mdl/examples/magnet_test.py Outdated
@nedseb nedseb force-pushed the fix/standardize-status branch from afba75e to 57933d6 Compare March 15, 2026 13:36
@nedseb nedseb force-pushed the fix/status-private branch 2 times, most recently from dfa6a85 to 5f8f405 Compare March 15, 2026 13:43
@nedseb nedseb force-pushed the fix/status-private branch from 5f8f405 to 6e0fe68 Compare March 15, 2026 13:59
@nedseb nedseb merged commit bcf3234 into fix/standardize-status Mar 15, 2026
@nedseb nedseb deleted the fix/status-private branch March 15, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

2 participants