Skip to content

bq27441: remove debug print statements from driver.#22

Merged
nedseb merged 1 commit intomainfrom
fix/bq27441-debug-prints
Mar 11, 2026
Merged

bq27441: remove debug print statements from driver.#22
nedseb merged 1 commit intomainfrom
fix/bq27441-debug-prints

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Mar 11, 2026

Summary

  • Remove all 16 debug print() statements from the BQ27441 driver
  • Simplify battery characteristic methods by removing unnecessary try/except/print patterns
  • Remove unused sys import

Closes #16

@nedseb nedseb requested a review from Copilot March 11, 2026 10:12
@nedseb nedseb changed the title bq27441: remove debug print statements from driver bq27441: remove debug print statements from driver. Mar 11, 2026
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 cleans up the bq27441 MicroPython driver by removing leftover debug console output and simplifying several battery read helpers.

Changes:

  • Removed production print() debug statements throughout the driver.
  • Simplified several battery characteristic wrapper methods by removing try/except + print patterns.
  • Removed unused sys import.

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

Comment on lines 110 to +113
try:
self.set_capacity(self.capacity_mAh)
except Exception as e:
print("Failed to wake up fuel gauge: %s" % e)
sys.print_exception(e)
except Exception:
raise
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

power_up() wraps set_capacity() in try/except Exception: raise, which is a no-op and adds noise. Either remove the try/except entirely, or catch a specific exception type and raise a more informative driver-specific error if you want added context.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment on lines 156 to +162
def current_average(self):
"""Return average current"""
try:
result = self.current(CurrentMeasureType.AVG)
return result
except Exception as e:
print("Failed to get average current (mA): %s" % e)
sys.print_exception(e)
except Exception:
raise
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

current_average() still uses try/except Exception: raise, which is redundant. This can be simplified to a direct return (or, if you intend to translate I2C errors, catch specific exceptions and raise a clearer error).

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Copy Markdown

Copilot AI commented Mar 11, 2026

@nedseb I've opened a new pull request, #23, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
Copy Markdown

Copilot AI commented Mar 11, 2026

@nedseb I've opened a new pull request, #24, to work on those changes. Once the pull request is ready, I'll request review from you.

@nedseb nedseb merged commit 7feacba into main Mar 11, 2026
6 of 8 checks passed
@nedseb nedseb deleted the fix/bq27441-debug-prints branch March 11, 2026 10:28
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.0.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bq27441: Remove debug print statements from driver

3 participants