Migrate MLX90614 sensor driver to new I2C API conventions#279
Open
voldemort9999 wants to merge 1 commit intofossasia:mainfrom
Open
Migrate MLX90614 sensor driver to new I2C API conventions#279voldemort9999 wants to merge 1 commit intofossasia:mainfrom
voldemort9999 wants to merge 1 commit intofossasia:mainfrom
Conversation
- Rename camelCase methods to snake_case - Add type hints and NumPy-style docstrings - Replace print() with logging - Return None instead of False on read failures - Remove dead commented-out old API code - Accept optional device parameter in __init__ - Add 20 mock-based unit tests Closes fossasia#182
There was a problem hiding this comment.
Sorry @voldemort9999, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
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.
While looking at the sensor drivers, I noticed that the MLX90614 module was left in a half-migrated state — it inherits from I2CSlave (which is great), but the rest of the code still followed the old conventions: camelCase methods,
print()instead of logging,return Falseinstead of properNonereturns, and no type hints or documentation.Since this was flagged in #182, I went through and did a full cleanup to bring it in line with the rest of the codebase.
Closes #182
Changes
self.read(), so I inlined it directlyprint()withlogging.info()in read_regNoneinstead ofFalseon failed reads (more Pythonic, better for type checkers)self.I2C.configI2C()APIUsage
Tests
Added tests/test_mlx90614.py with 20 unit tests covering initialization, source selection, temperature conversion math, error handling, logging output, return types, and class attributes. All tests are mock-based and run without hardware.