drivers: Add micropython.const() wrapper to all const.py files.#66
Merged
drivers: Add micropython.const() wrapper to all const.py files.#66
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request updates remaining driver const.py modules to use micropython.const() so MicroPython can inline integer constants and reduce RAM usage across these drivers.
Changes:
- Add
from micropython import constto the remainingconst.pymodules. - Wrap integer register/bitmask/timing constants in
const(...)forapds9960,bq27441, andwsen-pads.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/apds9960/apds9960/const.py | Imports const and wraps integer constants for APDS9960 registers/bitfields/defaults. |
| lib/bq27441/bq27441/const.py | Imports const and wraps integer constants for commands/flags/opconfig bits/timeouts. |
| lib/wsen-pads/wsen_pads/const.py | Imports const and wraps integer constants for I2C addr/regs/bitmasks/ODR values/delays. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
🎉 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.
Summary
Add
from micropython import constand wrap all integer constants withconst()in the three remaining const.py files:APDS9960_DEV_IDand constants referencing other names left unwrapped)1 << Nbit-shift expressions)This enables MicroPython to inline constant values at compile time, reducing RAM usage.
Closes #58
Hardware test results
Test plan
ruff checkpassespytest tests/ -k mock— 41 passed)