apds9960: Auto-enable sensor when reading without active mode.#75
Merged
apds9960: Auto-enable sensor when reading without active mode.#75
Conversation
8 tasks
d7c61ce to
1a5629a
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds “auto-enable on read” behavior to the APDS9960 driver so light/proximity read methods work even if the corresponding sensor (or power) hasn’t been explicitly enabled, and extends the scenario suite to cover the intended behavior.
Changes:
- Add internal helpers to auto-enable the light/proximity engines before reads.
- Call those helpers from
readAmbientLight/read{Red,Green,Blue}Light/readProximity. - Add new YAML scenario cases intended to validate auto-enable behavior in mock mode.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
lib/apds9960/apds9960/device.py |
Introduces _ensure_*_enabled() and uses them in read methods to auto-enable sensors. |
tests/scenarios/apds9960.yaml |
Adds new scenario tests for “read without explicit enable” and “no re-enable when already active”. |
💡 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 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #72
Summary
Reading light or proximity data now automatically enables the sensor if it was disabled, instead of returning stale/zero values.
_ensure_light_enabled()— checks AEN and PON bits in ENABLE register; if not set, callsenableLightSensor()and polls AVALID (up to 500ms)_ensure_proximity_enabled()— checks PEN and PON bits; if not set, callsenableProximitySensor()and waits 50msreadAmbientLight(),readRedLight(),readGreenLight(),readBlueLight(),readProximity()Follows the auto-trigger convention from #44.
Test plan
Mock tests (no hardware)
python3 -m pytest tests/ -k "apds9960 and mock" -vHardware tests (STeaMi board connected)
python3 -m pytest tests/ --port /dev/ttyACM0 -k "apds9960 and hardware" -s -v