bq27441: Harmonize driver and add test scenario.#52
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR harmonizes the BQ27441 battery fuel gauge driver with project conventions and adds a comprehensive YAML test scenario. It fixes a bug where i2cWriteBytes didn't return True, causing executeControlWord to always return False. The FakeI2C test helper is also updated to accept an optional positional bus_id for MicroPython I2C(1) compatibility.
Changes:
- Refactored BQ27441 driver:
self.bus→self.i2c,utime→time, removed module-levelDEFAULT_I2C_BUS, madei2ca required constructor parameter, and fixedi2cWriteBytesmissing return value - Added YAML test scenario with 7 mock tests and 10 hardware/manual tests
- Updated
FakeI2C.__init__to accept an optional positionalbus_idargument
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lib/bq27441/bq27441/device.py |
Harmonize naming (self.i2c), imports (time), remove global I2C instance, fix i2cWriteBytes return |
lib/bq27441/examples/fuel_gauge.py |
Update variable name from bus to i2c to match driver changes |
tests/scenarios/bq27441.yaml |
New YAML test scenario covering mock register reads and hardware validation |
tests/fake_machine/i2c.py |
Add optional bus_id positional arg and **kwargs to FakeI2C constructor |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Mar 12, 2026
|
🎉 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 #31
Closes #53
Summary
self.bus→self.i2c,utime→time, remove module-levelDEFAULT_I2C_BUS = I2C(1), makei2ca required constructor parameteri2cWriteBytesnot returningTrue(causedexecuteControlWordto always returnFalse)fuel_gauge.pyto usei2cvariable namebus_idargument to FakeI2C for compatibilityTests
Test commands
Test results